Exemple #1
0
        /// <summary>Snippet for CreateInstance</summary>
        public void CreateInstance()
        {
            // Snippet: CreateInstance(ProjectName,InstanceName,Instance,CallSettings)
            // Create client
            InstanceAdminClient instanceAdminClient = InstanceAdminClient.Create();
            // Initialize request argument(s)
            ProjectName  parent     = new ProjectName("[PROJECT]");
            InstanceName instanceId = new InstanceName("[PROJECT]", "[INSTANCE]");
            Instance     instance   = new Instance();
            // Make the request
            Operation <Instance, CreateInstanceMetadata> response =
                instanceAdminClient.CreateInstance(parent, instanceId, instance);

            // Poll until the returned long-running operation is complete
            Operation <Instance, CreateInstanceMetadata> completedResponse =
                response.PollUntilCompleted();
            // 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 =
                instanceAdminClient.PollOnceCreateInstance(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
        }
Exemple #2
0
        public void CreateInstance_RequestObject()
        {
            // Snippet: CreateInstance(CreateInstanceRequest,CallSettings)
            // Create client
            InstanceAdminClient instanceAdminClient = InstanceAdminClient.Create();
            // Initialize request argument(s)
            CreateInstanceRequest request = new CreateInstanceRequest
            {
                Parent     = new ProjectName("[PROJECT]").ToString(),
                InstanceId = "",
                Instance   = new Instance(),
            };
            // Make the request
            Operation <Instance> response =
                instanceAdminClient.CreateInstance(request);

            // Poll until the returned long-running operation is complete
            Operation <Instance> completedResponse =
                response.PollUntilCompleted();
            // 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 =
                instanceAdminClient.PollOnceCreateInstance(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
        }