/// <summary>Snippet for DeleteIndexAsync</summary> public async Task DeleteIndexResourceNamesAsync() { // Snippet: DeleteIndexAsync(IndexName, CallSettings) // Additional: DeleteIndexAsync(IndexName, CancellationToken) // Create client IndexServiceClient indexServiceClient = await IndexServiceClient.CreateAsync(); // Initialize request argument(s) IndexName name = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"); // Make the request Operation <Empty, DeleteOperationMetadata> response = await indexServiceClient.DeleteIndexAsync(name); // Poll until the returned long-running operation is complete Operation <Empty, DeleteOperationMetadata> 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, DeleteOperationMetadata> retrievedResponse = await indexServiceClient.PollOnceDeleteIndexAsync(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 DeleteIndex</summary> public void DeleteIndexRequestObject() { // Snippet: DeleteIndex(DeleteIndexRequest, CallSettings) // Create client IndexServiceClient indexServiceClient = IndexServiceClient.Create(); // Initialize request argument(s) DeleteIndexRequest request = new DeleteIndexRequest { IndexName = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"), }; // Make the request Operation <Empty, DeleteOperationMetadata> response = indexServiceClient.DeleteIndex(request); // 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 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 GetIndexAsync</summary> public async Task GetIndexResourceNamesAsync() { // Snippet: GetIndexAsync(IndexName, CallSettings) // Additional: GetIndexAsync(IndexName, CancellationToken) // Create client IndexServiceClient indexServiceClient = await IndexServiceClient.CreateAsync(); // Initialize request argument(s) IndexName name = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"); // Make the request gcav::Index response = await indexServiceClient.GetIndexAsync(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 }
public async stt::Task GetIndexRequestObjectAsync() { moq::Mock <IndexService.IndexServiceClient> mockGrpcClient = new moq::Mock <IndexService.IndexServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetIndexRequest request = new GetIndexRequest { IndexName = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"), }; Index expectedResponse = new Index { IndexName = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"), DisplayName = "display_name137f65c2", Description = "description2cf9da67", MetadataSchemaUri = "metadata_schema_uric874bf0a", Metadata = new wkt::Value(), DeployedIndexes = { new DeployedIndexRef(), }, Etag = "etage8ad7218", Labels = { { "key8a0b6e3c", "value60c16320" }, }, CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), }; mockGrpcClient.Setup(x => x.GetIndexAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Index>(stt::Task.FromResult(expectedResponse), null, null, null, null)); IndexServiceClient client = new IndexServiceClientImpl(mockGrpcClient.Object, null); Index responseCallSettings = await client.GetIndexAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Index responseCancellationToken = await client.GetIndexAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetIndexResourceNames() { moq::Mock <IndexService.IndexServiceClient> mockGrpcClient = new moq::Mock <IndexService.IndexServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetIndexRequest request = new GetIndexRequest { IndexName = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"), }; Index expectedResponse = new Index { IndexName = IndexName.FromProjectLocationIndex("[PROJECT]", "[LOCATION]", "[INDEX]"), DisplayName = "display_name137f65c2", Description = "description2cf9da67", MetadataSchemaUri = "metadata_schema_uric874bf0a", Metadata = new wkt::Value(), DeployedIndexes = { new DeployedIndexRef(), }, Etag = "etage8ad7218", Labels = { { "key8a0b6e3c", "value60c16320" }, }, CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), }; mockGrpcClient.Setup(x => x.GetIndex(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); IndexServiceClient client = new IndexServiceClientImpl(mockGrpcClient.Object, null); Index response = client.GetIndex(request.IndexName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }