示例#1
0
        /// <summary>Snippet for InsertAsync</summary>
        public async Task InsertAsync()
        {
            // Snippet: InsertAsync(string, string, TargetInstance, CallSettings)
            // Additional: InsertAsync(string, string, TargetInstance, CancellationToken)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            string         project = "";
            string         zone    = "";
            TargetInstance targetInstanceResource = new TargetInstance();
            // Make the request
            lro::Operation <Operation, Operation> response = await targetInstancesClient.InsertAsync(project, zone, targetInstanceResource);

            // Poll until the returned long-running operation is complete
            lro::Operation <Operation, Operation> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            Operation 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
            lro::Operation <Operation, Operation> retrievedResponse = await targetInstancesClient.PollOnceInsertAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Operation retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }
示例#2
0
        /// <summary>Snippet for AggregatedListAsync</summary>
        public async Task AggregatedListRequestObjectAsync()
        {
            // Snippet: AggregatedListAsync(AggregatedListTargetInstancesRequest, CallSettings)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            AggregatedListTargetInstancesRequest request = new AggregatedListTargetInstancesRequest
            {
                OrderBy              = "",
                Project              = "",
                Filter               = "",
                IncludeAllScopes     = false,
                ReturnPartialSuccess = false,
            };
            // Make the request
            PagedAsyncEnumerable <TargetInstanceAggregatedList, KeyValuePair <string, TargetInstancesScopedList> > response = targetInstancesClient.AggregatedListAsync(request);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((KeyValuePair <string, TargetInstancesScopedList> item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((TargetInstanceAggregatedList page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (KeyValuePair <string, TargetInstancesScopedList> 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 <KeyValuePair <string, TargetInstancesScopedList> > singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (KeyValuePair <string, TargetInstancesScopedList> 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
        }
示例#3
0
        /// <summary>Snippet for AggregatedListAsync</summary>
        public async Task AggregatedListAsync()
        {
            // Snippet: AggregatedListAsync(string, CallSettings)
            // Additional: AggregatedListAsync(string, CancellationToken)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            string project = "";
            // Make the request
            TargetInstanceAggregatedList response = await targetInstancesClient.AggregatedListAsync(project);

            // End snippet
        }
示例#4
0
        /// <summary>Snippet for InsertAsync</summary>
        public async Task InsertAsync()
        {
            // Snippet: InsertAsync(string, string, TargetInstance, CallSettings)
            // Additional: InsertAsync(string, string, TargetInstance, CancellationToken)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            string         project = "";
            string         zone    = "";
            TargetInstance targetInstanceResource = new TargetInstance();
            // Make the request
            Operation response = await targetInstancesClient.InsertAsync(project, zone, targetInstanceResource);

            // End snippet
        }
示例#5
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetAsync()
        {
            // Snippet: GetAsync(string, string, string, CallSettings)
            // Additional: GetAsync(string, string, string, CancellationToken)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            string project        = "";
            string zone           = "";
            string targetInstance = "";
            // Make the request
            TargetInstance response = await targetInstancesClient.GetAsync(project, zone, targetInstance);

            // End snippet
        }
示例#6
0
        /// <summary>Snippet for ListAsync</summary>
        public async Task ListAsync()
        {
            // Snippet: ListAsync(string, string, string, int?, CallSettings)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            string project = "";
            string zone    = "";
            // Make the request
            PagedAsyncEnumerable <TargetInstanceList, TargetInstance> response = targetInstancesClient.ListAsync(project, zone);

            // Iterate over all response items, lazily performing RPCs as required
            await response.ForEachAsync((TargetInstance item) =>
            {
                // Do something with each item
                Console.WriteLine(item);
            });

            // Or iterate over pages (of server-defined size), performing one RPC per page
            await response.AsRawResponses().ForEachAsync((TargetInstanceList page) =>
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (TargetInstance 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 <TargetInstance> singlePage = await response.ReadPageAsync(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (TargetInstance 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
        }
示例#7
0
        /// <summary>Snippet for GetAsync</summary>
        public async Task GetRequestObjectAsync()
        {
            // Snippet: GetAsync(GetTargetInstanceRequest, CallSettings)
            // Additional: GetAsync(GetTargetInstanceRequest, CancellationToken)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            GetTargetInstanceRequest request = new GetTargetInstanceRequest
            {
                Zone           = "",
                TargetInstance = "",
                Project        = "",
            };
            // Make the request
            TargetInstance response = await targetInstancesClient.GetAsync(request);

            // End snippet
        }
示例#8
0
        /// <summary>Snippet for InsertAsync</summary>
        public async Task InsertRequestObjectAsync()
        {
            // Snippet: InsertAsync(InsertTargetInstanceRequest, CallSettings)
            // Additional: InsertAsync(InsertTargetInstanceRequest, CancellationToken)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            InsertTargetInstanceRequest request = new InsertTargetInstanceRequest
            {
                Zone      = "",
                RequestId = "",
                TargetInstanceResource = new TargetInstance(),
                Project = "",
            };
            // Make the request
            Operation response = await targetInstancesClient.InsertAsync(request);

            // End snippet
        }
示例#9
0
        /// <summary>Snippet for AggregatedListAsync</summary>
        public async Task AggregatedListRequestObjectAsync()
        {
            // Snippet: AggregatedListAsync(AggregatedListTargetInstancesRequest, CallSettings)
            // Additional: AggregatedListAsync(AggregatedListTargetInstancesRequest, CancellationToken)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            AggregatedListTargetInstancesRequest request = new AggregatedListTargetInstancesRequest
            {
                PageToken            = "",
                MaxResults           = 0U,
                Filter               = "",
                IncludeAllScopes     = false,
                OrderBy              = "",
                Project              = "",
                ReturnPartialSuccess = false,
            };
            // Make the request
            TargetInstanceAggregatedList response = await targetInstancesClient.AggregatedListAsync(request);

            // End snippet
        }
示例#10
0
        /// <summary>Snippet for ListAsync</summary>
        public async Task ListRequestObjectAsync()
        {
            // Snippet: ListAsync(ListTargetInstancesRequest, CallSettings)
            // Additional: ListAsync(ListTargetInstancesRequest, CancellationToken)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            ListTargetInstancesRequest request = new ListTargetInstancesRequest
            {
                Zone                 = "",
                PageToken            = "",
                MaxResults           = 0U,
                Filter               = "",
                OrderBy              = "",
                Project              = "",
                ReturnPartialSuccess = false,
            };
            // Make the request
            TargetInstanceList response = await targetInstancesClient.ListAsync(request);

            // End snippet
        }
示例#11
0
        /// <summary>Snippet for DeleteAsync</summary>
        public async Task DeleteRequestObjectAsync()
        {
            // Snippet: DeleteAsync(DeleteTargetInstanceRequest, CallSettings)
            // Additional: DeleteAsync(DeleteTargetInstanceRequest, CancellationToken)
            // Create client
            TargetInstancesClient targetInstancesClient = await TargetInstancesClient.CreateAsync();

            // Initialize request argument(s)
            DeleteTargetInstanceRequest request = new DeleteTargetInstanceRequest
            {
                Zone           = "",
                RequestId      = "",
                Project        = "",
                TargetInstance = "",
            };
            // Make the request
            lro::Operation <Operation, Operation> response = await targetInstancesClient.DeleteAsync(request);

            // Poll until the returned long-running operation is complete
            lro::Operation <Operation, Operation> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            Operation 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
            lro::Operation <Operation, Operation> retrievedResponse = await targetInstancesClient.PollOnceDeleteAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Operation retrievedResult = retrievedResponse.Result;
            }
            // End snippet
        }