/// <summary>Snippet for InsertAsync</summary> public async Task InsertAsync() { // Snippet: InsertAsync(string, string, ResourcePolicy, CallSettings) // Additional: InsertAsync(string, string, ResourcePolicy, CancellationToken) // Create client ResourcePoliciesClient resourcePoliciesClient = await ResourcePoliciesClient.CreateAsync(); // Initialize request argument(s) string project = ""; string region = ""; ResourcePolicy resourcePolicyResource = new ResourcePolicy(); // Make the request lro::Operation <Operation, Operation> response = await resourcePoliciesClient.InsertAsync(project, region, resourcePolicyResource); // 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 resourcePoliciesClient.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 }
/// <summary>Snippet for AggregatedListAsync</summary> public async Task AggregatedListRequestObjectAsync() { // Snippet: AggregatedListAsync(AggregatedListResourcePoliciesRequest, CallSettings) // Create client ResourcePoliciesClient resourcePoliciesClient = await ResourcePoliciesClient.CreateAsync(); // Initialize request argument(s) AggregatedListResourcePoliciesRequest request = new AggregatedListResourcePoliciesRequest { OrderBy = "", Project = "", Filter = "", IncludeAllScopes = false, ReturnPartialSuccess = false, }; // Make the request PagedAsyncEnumerable <ResourcePolicyAggregatedList, KeyValuePair <string, ResourcePoliciesScopedList> > response = resourcePoliciesClient.AggregatedListAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((KeyValuePair <string, ResourcePoliciesScopedList> 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((ResourcePolicyAggregatedList page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (KeyValuePair <string, ResourcePoliciesScopedList> 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, ResourcePoliciesScopedList> > 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, ResourcePoliciesScopedList> 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 }
/// <summary>Snippet for AggregatedListAsync</summary> public async Task AggregatedListAsync() { // Snippet: AggregatedListAsync(string, CallSettings) // Additional: AggregatedListAsync(string, CancellationToken) // Create client ResourcePoliciesClient resourcePoliciesClient = await ResourcePoliciesClient.CreateAsync(); // Initialize request argument(s) string project = ""; // Make the request ResourcePolicyAggregatedList response = await resourcePoliciesClient.AggregatedListAsync(project); // End snippet }
/// <summary>Snippet for InsertAsync</summary> public async Task InsertAsync() { // Snippet: InsertAsync(string, string, ResourcePolicy, CallSettings) // Additional: InsertAsync(string, string, ResourcePolicy, CancellationToken) // Create client ResourcePoliciesClient resourcePoliciesClient = await ResourcePoliciesClient.CreateAsync(); // Initialize request argument(s) string project = ""; string region = ""; ResourcePolicy resourcePolicyResource = new ResourcePolicy(); // Make the request Operation response = await resourcePoliciesClient.InsertAsync(project, region, resourcePolicyResource); // End snippet }
/// <summary>Snippet for GetIamPolicyAsync</summary> public async Task GetIamPolicyAsync() { // Snippet: GetIamPolicyAsync(string, string, string, CallSettings) // Additional: GetIamPolicyAsync(string, string, string, CancellationToken) // Create client ResourcePoliciesClient resourcePoliciesClient = await ResourcePoliciesClient.CreateAsync(); // Initialize request argument(s) string project = ""; string region = ""; string resource = ""; // Make the request Policy response = await resourcePoliciesClient.GetIamPolicyAsync(project, region, resource); // End snippet }
/// <summary>Snippet for TestIamPermissionsAsync</summary> public async Task TestIamPermissionsAsync() { // Snippet: TestIamPermissionsAsync(string, string, string, TestPermissionsRequest, CallSettings) // Additional: TestIamPermissionsAsync(string, string, string, TestPermissionsRequest, CancellationToken) // Create client ResourcePoliciesClient resourcePoliciesClient = await ResourcePoliciesClient.CreateAsync(); // Initialize request argument(s) string project = ""; string region = ""; string resource = ""; TestPermissionsRequest testPermissionsRequestResource = new TestPermissionsRequest(); // Make the request TestPermissionsResponse response = await resourcePoliciesClient.TestIamPermissionsAsync(project, region, resource, testPermissionsRequestResource); // End snippet }
/// <summary>Snippet for ListAsync</summary> public async Task ListAsync() { // Snippet: ListAsync(string, string, string, int?, CallSettings) // Create client ResourcePoliciesClient resourcePoliciesClient = await ResourcePoliciesClient.CreateAsync(); // Initialize request argument(s) string project = ""; string region = ""; // Make the request PagedAsyncEnumerable <ResourcePolicyList, ResourcePolicy> response = resourcePoliciesClient.ListAsync(project, region); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((ResourcePolicy 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((ResourcePolicyList page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (ResourcePolicy 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 <ResourcePolicy> 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 (ResourcePolicy 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 }
/// <summary>Snippet for GetAsync</summary> public async Task GetRequestObjectAsync() { // Snippet: GetAsync(GetResourcePolicyRequest, CallSettings) // Additional: GetAsync(GetResourcePolicyRequest, CancellationToken) // Create client ResourcePoliciesClient resourcePoliciesClient = await ResourcePoliciesClient.CreateAsync(); // Initialize request argument(s) GetResourcePolicyRequest request = new GetResourcePolicyRequest { Region = "", ResourcePolicy = "", Project = "", }; // Make the request ResourcePolicy response = await resourcePoliciesClient.GetAsync(request); // End snippet }
/// <summary>Snippet for TestIamPermissionsAsync</summary> public async Task TestIamPermissionsRequestObjectAsync() { // Snippet: TestIamPermissionsAsync(TestIamPermissionsResourcePolicyRequest, CallSettings) // Additional: TestIamPermissionsAsync(TestIamPermissionsResourcePolicyRequest, CancellationToken) // Create client ResourcePoliciesClient resourcePoliciesClient = await ResourcePoliciesClient.CreateAsync(); // Initialize request argument(s) TestIamPermissionsResourcePolicyRequest request = new TestIamPermissionsResourcePolicyRequest { Region = "", TestPermissionsRequestResource = new TestPermissionsRequest(), Resource = "", Project = "", }; // Make the request TestPermissionsResponse response = await resourcePoliciesClient.TestIamPermissionsAsync(request); // End snippet }
/// <summary>Snippet for InsertAsync</summary> public async Task InsertRequestObjectAsync() { // Snippet: InsertAsync(InsertResourcePolicyRequest, CallSettings) // Additional: InsertAsync(InsertResourcePolicyRequest, CancellationToken) // Create client ResourcePoliciesClient resourcePoliciesClient = await ResourcePoliciesClient.CreateAsync(); // Initialize request argument(s) InsertResourcePolicyRequest request = new InsertResourcePolicyRequest { RequestId = "", ResourcePolicyResource = new ResourcePolicy(), Region = "", Project = "", }; // Make the request Operation response = await resourcePoliciesClient.InsertAsync(request); // End snippet }
/// <summary>Snippet for SetIamPolicyAsync</summary> public async Task SetIamPolicyRequestObjectAsync() { // Snippet: SetIamPolicyAsync(SetIamPolicyResourcePolicyRequest, CallSettings) // Additional: SetIamPolicyAsync(SetIamPolicyResourcePolicyRequest, CancellationToken) // Create client ResourcePoliciesClient resourcePoliciesClient = await ResourcePoliciesClient.CreateAsync(); // Initialize request argument(s) SetIamPolicyResourcePolicyRequest request = new SetIamPolicyResourcePolicyRequest { Region = "", Resource = "", Project = "", RegionSetPolicyRequestResource = new RegionSetPolicyRequest(), }; // Make the request Policy response = await resourcePoliciesClient.SetIamPolicyAsync(request); // End snippet }
/// <summary>Snippet for AggregatedListAsync</summary> public async Task AggregatedListRequestObjectAsync() { // Snippet: AggregatedListAsync(AggregatedListResourcePoliciesRequest, CallSettings) // Additional: AggregatedListAsync(AggregatedListResourcePoliciesRequest, CancellationToken) // Create client ResourcePoliciesClient resourcePoliciesClient = await ResourcePoliciesClient.CreateAsync(); // Initialize request argument(s) AggregatedListResourcePoliciesRequest request = new AggregatedListResourcePoliciesRequest { PageToken = "", MaxResults = 0U, Filter = "", IncludeAllScopes = false, OrderBy = "", Project = "", ReturnPartialSuccess = false, }; // Make the request ResourcePolicyAggregatedList response = await resourcePoliciesClient.AggregatedListAsync(request); // End snippet }
/// <summary>Snippet for DeleteAsync</summary> public async Task DeleteRequestObjectAsync() { // Snippet: DeleteAsync(DeleteResourcePolicyRequest, CallSettings) // Additional: DeleteAsync(DeleteResourcePolicyRequest, CancellationToken) // Create client ResourcePoliciesClient resourcePoliciesClient = await ResourcePoliciesClient.CreateAsync(); // Initialize request argument(s) DeleteResourcePolicyRequest request = new DeleteResourcePolicyRequest { RequestId = "", Region = "", ResourcePolicy = "", Project = "", }; // Make the request lro::Operation <Operation, Operation> response = await resourcePoliciesClient.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 resourcePoliciesClient.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 }