/// <summary>Snippet for CreateInstanceAsync</summary> public async Task CreateInstanceAsync_RequestObject() { // Snippet: CreateInstanceAsync(CreateInstanceRequest,CallSettings) // Create client CloudRedisClient cloudRedisClient = await CloudRedisClient.CreateAsync(); // Initialize request argument(s) CreateInstanceRequest request = new CreateInstanceRequest { ParentAsLocationName = new LocationName("[PROJECT]", "[LOCATION]"), InstanceId = "test_instance", Instance = new Instance { Tier = Instance.Types.Tier.Basic, MemorySizeGb = 1, }, }; // Make the request Operation <Instance, OperationMetadata> response = await cloudRedisClient.CreateInstanceAsync(request); // Poll until the returned long-running operation is complete Operation <Instance, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result Instance 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 <Instance, OperationMetadata> retrievedResponse = await cloudRedisClient.PollOnceCreateInstanceAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result Instance retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for CreateInstanceAsync</summary> public async Task CreateInstanceAsync() { // Snippet: CreateInstanceAsync(string,string,Instance,CallSettings) // Additional: CreateInstanceAsync(string,string,Instance,CancellationToken) // Create client CloudRedisClient cloudRedisClient = await CloudRedisClient.CreateAsync(); // Initialize request argument(s) string formattedParent = new LocationName("[PROJECT]", "[LOCATION]").ToString(); string instanceId = "test_instance"; Instance instance = new Instance { Tier = Instance.Types.Tier.Basic, MemorySizeGb = 1, }; // Make the request Operation <Instance, Any> response = await cloudRedisClient.CreateInstanceAsync(formattedParent, instanceId, instance); // Poll until the returned long-running operation is complete Operation <Instance, Any> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result Instance 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 <Instance, Any> retrievedResponse = await cloudRedisClient.PollOnceCreateInstanceAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result Instance retrievedResult = retrievedResponse.Result; } // End snippet }