Beispiel #1
0
        /// <summary>Snippet for CreateInstanceAsync</summary>
        public async Task CreateInstanceAsync_RequestObject()
        {
            // Snippet: CreateInstanceAsync(CreateInstanceRequest,CallSettings)
            // Create client
            InstanceAdminClient instanceAdminClient = await InstanceAdminClient.CreateAsync();

            // Initialize request argument(s)
            CreateInstanceRequest request = new CreateInstanceRequest
            {
                ParentAsProjectName      = new ProjectName("[PROJECT]"),
                InstanceIdAsInstanceName = new InstanceName("[PROJECT]", "[INSTANCE]"),
                Instance = new Instance(),
            };
            // Make the request
            Operation <Instance, CreateInstanceMetadata> response =
                await instanceAdminClient.CreateInstanceAsync(request);

            // Poll until the returned long-running operation is complete
            Operation <Instance, CreateInstanceMetadata> 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, CreateInstanceMetadata> retrievedResponse =
                await instanceAdminClient.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
        }
Beispiel #2
0
        public async Task CreateInstanceAsync()
        {
            // Snippet: CreateInstanceAsync(string,string,Instance,CallSettings)
            // Additional: CreateInstanceAsync(string,string,Instance,CancellationToken)
            // Create client
            InstanceAdminClient instanceAdminClient = await InstanceAdminClient.CreateAsync();

            // Initialize request argument(s)
            string   formattedParent = new ProjectName("[PROJECT]").ToString();
            string   instanceId      = "";
            Instance instance        = new Instance();
            // Make the request
            Operation <Instance> response =
                await instanceAdminClient.CreateInstanceAsync(formattedParent, instanceId, instance);

            // Poll until the returned long-running operation is complete
            Operation <Instance> 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> retrievedResponse =
                await instanceAdminClient.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
        }