/// <summary>Snippet for UpdateIndex</summary> public void UpdateIndex() { // Snippet: UpdateIndex(Index, FieldMask, CallSettings) // Create client IndexServiceClient indexServiceClient = IndexServiceClient.Create(); // Initialize request argument(s) gcav::Index index = new gcav::Index(); FieldMask updateMask = new FieldMask(); // Make the request Operation <gcav::Index, UpdateIndexOperationMetadata> response = indexServiceClient.UpdateIndex(index, updateMask); // Poll until the returned long-running operation is complete Operation <gcav::Index, UpdateIndexOperationMetadata> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result gcav::Index 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 <gcav::Index, UpdateIndexOperationMetadata> retrievedResponse = indexServiceClient.PollOnceUpdateIndex(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result gcav::Index retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for DeleteIndex</summary> public void DeleteIndexResourceNames() { // Snippet: DeleteIndex(IndexName, CallSettings) // Create client IndexServiceClient indexServiceClient = IndexServiceClient.Create(); // Initialize request argument(s) IndexName name = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"); // Make the request Operation <Empty, DeleteOperationMetadata> response = indexServiceClient.DeleteIndex(name); // Poll until the returned long-running operation is complete Operation <Empty, DeleteOperationMetadata> completedResponse = response.PollUntilCompleted(); // 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, DeleteOperationMetadata> retrievedResponse = indexServiceClient.PollOnceDeleteIndex(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 }
/// <summary>Snippet for CreateIndex</summary> public void CreateIndexRequestObject() { // Snippet: CreateIndex(CreateIndexRequest, CallSettings) // Create client IndexServiceClient indexServiceClient = IndexServiceClient.Create(); // Initialize request argument(s) CreateIndexRequest request = new CreateIndexRequest { ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Index = new gcav::Index(), }; // Make the request Operation <gcav::Index, CreateIndexOperationMetadata> response = indexServiceClient.CreateIndex(request); // Poll until the returned long-running operation is complete Operation <gcav::Index, CreateIndexOperationMetadata> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result gcav::Index 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 <gcav::Index, CreateIndexOperationMetadata> retrievedResponse = indexServiceClient.PollOnceCreateIndex(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result gcav::Index retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for GetIndex</summary> public void GetIndexResourceNames() { // Snippet: GetIndex(IndexName, CallSettings) // Create client IndexServiceClient indexServiceClient = IndexServiceClient.Create(); // Initialize request argument(s) IndexName name = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"); // Make the request gcav::Index response = indexServiceClient.GetIndex(name); // End snippet }
/// <summary>Snippet for GetIndex</summary> public void GetIndex() { // Snippet: GetIndex(string, CallSettings) // Create client IndexServiceClient indexServiceClient = IndexServiceClient.Create(); // Initialize request argument(s) string name = "projects/[PROJECT]/locations/[LOCATION]/indexes/[INDEX]"; // Make the request gcav::Index response = indexServiceClient.GetIndex(name); // End snippet }
/// <summary>Snippet for GetIndex</summary> public void GetIndexRequestObject() { // Snippet: GetIndex(GetIndexRequest, CallSettings) // Create client IndexServiceClient indexServiceClient = IndexServiceClient.Create(); // Initialize request argument(s) GetIndexRequest request = new GetIndexRequest { IndexName = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"), }; // Make the request gcav::Index response = indexServiceClient.GetIndex(request); // End snippet }
/// <summary>Snippet for ListIndexes</summary> public void ListIndexesRequestObject() { // Snippet: ListIndexes(ListIndexesRequest, CallSettings) // Create client IndexServiceClient indexServiceClient = IndexServiceClient.Create(); // Initialize request argument(s) ListIndexesRequest request = new ListIndexesRequest { ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), Filter = "", ReadMask = new FieldMask(), }; // Make the request PagedEnumerable <ListIndexesResponse, gcav::Index> response = indexServiceClient.ListIndexes(request); // Iterate over all response items, lazily performing RPCs as required foreach (gcav::Index 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 (ListIndexesResponse page in response.AsRawResponses()) { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (gcav::Index 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 <gcav::Index> 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 (gcav::Index 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 }