Beispiel #1
0
        /// <summary>Snippet for DebugInstance</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void DebugInstanceRequestObject()
        {
            // Create client
            InstancesClient instancesClient = InstancesClient.Create();
            // Initialize request argument(s)
            DebugInstanceRequest request = new DebugInstanceRequest {
                Name = "", SshKey = "",
            };
            // Make the request
            Operation <Instance, OperationMetadataV1> response = instancesClient.DebugInstance(request);

            // Poll until the returned long-running operation is complete
            Operation <Instance, OperationMetadataV1> 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, OperationMetadataV1> retrievedResponse = instancesClient.PollOnceDebugInstance(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;
            }
        }
 /// <summary>Snippet for GetInstance</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetInstanceRequestObject()
 {
     // Create client
     InstancesClient instancesClient = InstancesClient.Create();
     // Initialize request argument(s)
     GetInstanceRequest request = new GetInstanceRequest {
         Name = "",
     };
     // Make the request
     Instance response = instancesClient.GetInstance(request);
 }
Beispiel #3
0
        private void CleanUpInstances()
        {
            var client           = InstancesClient.Create();
            var list             = client.List(ProjectId, Zone);
            var fixtureInstances = list
                                   .Select(instance => instance.Name)
                                   .Where(name => name.StartsWith(ResourcePrefix));

            foreach (var instanceToDelete in fixtureInstances)
            {
                client.Delete(ProjectId, Zone, instanceToDelete);
            }
        }
Beispiel #4
0
 /// <summary>Snippet for GetInstance</summary>
 public void GetInstanceRequestObject()
 {
     // Snippet: GetInstance(GetInstanceRequest, CallSettings)
     // Create client
     InstancesClient instancesClient = InstancesClient.Create();
     // Initialize request argument(s)
     GetInstanceRequest request = new GetInstanceRequest {
         Name = "",
     };
     // Make the request
     Instance response = instancesClient.GetInstance(request);
     // End snippet
 }
Beispiel #5
0
        /// <summary>Snippet for ListInstances</summary>
        public void ListInstancesRequestObject()
        {
            // Snippet: ListInstances(ListInstancesRequest, CallSettings)
            // Create client
            InstancesClient instancesClient = InstancesClient.Create();
            // Initialize request argument(s)
            ListInstancesRequest request = new ListInstancesRequest {
                Parent = "",
            };
            // Make the request
            PagedEnumerable <ListInstancesResponse, Instance> response = instancesClient.ListInstances(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (Instance 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 (ListInstancesResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (Instance 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 <Instance> 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 (Instance 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
        }