/// <summary>Snippet for SetLabelsAsync</summary> public async Task SetLabelsAsync() { // Snippet: SetLabelsAsync(string, string, GlobalSetLabelsRequest, CallSettings) // Additional: SetLabelsAsync(string, string, GlobalSetLabelsRequest, CancellationToken) // Create client SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync(); // Initialize request argument(s) string project = ""; string resource = ""; GlobalSetLabelsRequest globalSetLabelsRequestResource = new GlobalSetLabelsRequest(); // Make the request lro::Operation <Operation, Operation> response = await snapshotsClient.SetLabelsAsync(project, resource, globalSetLabelsRequestResource); // 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 snapshotsClient.PollOnceSetLabelsAsync(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 ListAsync</summary> public async Task ListRequestObjectAsync() { // Snippet: ListAsync(ListSnapshotsRequest, CallSettings) // Create client SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync(); // Initialize request argument(s) ListSnapshotsRequest request = new ListSnapshotsRequest { OrderBy = "", Project = "", Filter = "", ReturnPartialSuccess = false, }; // Make the request PagedAsyncEnumerable <SnapshotList, Snapshot> response = snapshotsClient.ListAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((Snapshot 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((SnapshotList page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Snapshot 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 <Snapshot> 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 (Snapshot 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 ListAsync</summary> public async Task ListAsync() { // Snippet: ListAsync(string, CallSettings) // Additional: ListAsync(string, CancellationToken) // Create client SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync(); // Initialize request argument(s) string project = ""; // Make the request SnapshotList response = await snapshotsClient.ListAsync(project); // End snippet }
/// <summary>Snippet for GetIamPolicyAsync</summary> public async Task GetIamPolicyAsync() { // Snippet: GetIamPolicyAsync(string, string, CallSettings) // Additional: GetIamPolicyAsync(string, string, CancellationToken) // Create client SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync(); // Initialize request argument(s) string project = ""; string resource = ""; // Make the request Policy response = await snapshotsClient.GetIamPolicyAsync(project, resource); // End snippet }
/// <summary>Snippet for TestIamPermissionsAsync</summary> public async Task TestIamPermissionsAsync() { // Snippet: TestIamPermissionsAsync(string, string, TestPermissionsRequest, CallSettings) // Additional: TestIamPermissionsAsync(string, string, TestPermissionsRequest, CancellationToken) // Create client SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync(); // Initialize request argument(s) string project = ""; string resource = ""; TestPermissionsRequest testPermissionsRequestResource = new TestPermissionsRequest(); // Make the request TestPermissionsResponse response = await snapshotsClient.TestIamPermissionsAsync(project, resource, testPermissionsRequestResource); // End snippet }
/// <summary>Snippet for SetLabelsAsync</summary> public async Task SetLabelsAsync() { // Snippet: SetLabelsAsync(string, string, GlobalSetLabelsRequest, CallSettings) // Additional: SetLabelsAsync(string, string, GlobalSetLabelsRequest, CancellationToken) // Create client SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync(); // Initialize request argument(s) string project = ""; string resource = ""; GlobalSetLabelsRequest globalSetLabelsRequestResource = new GlobalSetLabelsRequest(); // Make the request Operation response = await snapshotsClient.SetLabelsAsync(project, resource, globalSetLabelsRequestResource); // End snippet }
/// <summary>Snippet for GetAsync</summary> public async Task GetRequestObjectAsync() { // Snippet: GetAsync(GetSnapshotRequest, CallSettings) // Additional: GetAsync(GetSnapshotRequest, CancellationToken) // Create client SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync(); // Initialize request argument(s) GetSnapshotRequest request = new GetSnapshotRequest { Project = "", Snapshot = "", }; // Make the request Snapshot response = await snapshotsClient.GetAsync(request); // End snippet }
/// <summary>Snippet for TestIamPermissionsAsync</summary> public async Task TestIamPermissionsRequestObjectAsync() { // Snippet: TestIamPermissionsAsync(TestIamPermissionsSnapshotRequest, CallSettings) // Additional: TestIamPermissionsAsync(TestIamPermissionsSnapshotRequest, CancellationToken) // Create client SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync(); // Initialize request argument(s) TestIamPermissionsSnapshotRequest request = new TestIamPermissionsSnapshotRequest { Resource = "", Project = "", TestPermissionsRequestResource = new TestPermissionsRequest(), }; // Make the request TestPermissionsResponse response = await snapshotsClient.TestIamPermissionsAsync(request); // End snippet }
/// <summary>Snippet for SetIamPolicyAsync</summary> public async Task SetIamPolicyRequestObjectAsync() { // Snippet: SetIamPolicyAsync(SetIamPolicySnapshotRequest, CallSettings) // Additional: SetIamPolicyAsync(SetIamPolicySnapshotRequest, CancellationToken) // Create client SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync(); // Initialize request argument(s) SetIamPolicySnapshotRequest request = new SetIamPolicySnapshotRequest { Resource = "", Project = "", GlobalSetPolicyRequestResource = new GlobalSetPolicyRequest(), }; // Make the request Policy response = await snapshotsClient.SetIamPolicyAsync(request); // End snippet }
/// <summary>Snippet for GetIamPolicyAsync</summary> public async Task GetIamPolicyRequestObjectAsync() { // Snippet: GetIamPolicyAsync(GetIamPolicySnapshotRequest, CallSettings) // Additional: GetIamPolicyAsync(GetIamPolicySnapshotRequest, CancellationToken) // Create client SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync(); // Initialize request argument(s) GetIamPolicySnapshotRequest request = new GetIamPolicySnapshotRequest { Resource = "", Project = "", OptionsRequestedPolicyVersion = 0, }; // Make the request Policy response = await snapshotsClient.GetIamPolicyAsync(request); // End snippet }
/// <summary>Snippet for DeleteAsync</summary> public async Task DeleteRequestObjectAsync() { // Snippet: DeleteAsync(DeleteSnapshotRequest, CallSettings) // Additional: DeleteAsync(DeleteSnapshotRequest, CancellationToken) // Create client SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync(); // Initialize request argument(s) DeleteSnapshotRequest request = new DeleteSnapshotRequest { RequestId = "", Project = "", Snapshot = "", }; // Make the request Operation response = await snapshotsClient.DeleteAsync(request); // End snippet }
/// <summary>Snippet for ListAsync</summary> public async Task ListRequestObjectAsync() { // Snippet: ListAsync(ListSnapshotsRequest, CallSettings) // Additional: ListAsync(ListSnapshotsRequest, CancellationToken) // Create client SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync(); // Initialize request argument(s) ListSnapshotsRequest request = new ListSnapshotsRequest { PageToken = "", MaxResults = 0U, Filter = "", OrderBy = "", Project = "", ReturnPartialSuccess = false, }; // Make the request SnapshotList response = await snapshotsClient.ListAsync(request); // End snippet }
/// <summary>Snippet for DeleteAsync</summary> public async Task DeleteRequestObjectAsync() { // Snippet: DeleteAsync(DeleteSnapshotRequest, CallSettings) // Additional: DeleteAsync(DeleteSnapshotRequest, CancellationToken) // Create client SnapshotsClient snapshotsClient = await SnapshotsClient.CreateAsync(); // Initialize request argument(s) DeleteSnapshotRequest request = new DeleteSnapshotRequest { RequestId = "", Project = "", Snapshot = "", }; // Make the request lro::Operation <Operation, Operation> response = await snapshotsClient.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 snapshotsClient.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 }