Skip to content

Commit

Permalink
fix!: Pagination feature is introduced for method ListKeyHandles in…
Browse files Browse the repository at this point in the history
… service `Autokey`

feat: Adding a state field for AutokeyConfig

docs: Field service_resolvers in message .google.cloud.kms.v1.EkmConnection is Explicitly is marked as to have field behavior of Optional

docs: A comment for field `destroy_scheduled_duration` in message `.google.cloud.kms.v1.CryptoKey` is updated for the default duration
PiperOrigin-RevId: 676068244

Source-Link: googleapis/googleapis@42492c9

Source-Link: googleapis/googleapis-gen@4743218
Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuQ2xvdWQuS21zLlYxLy5Pd2xCb3QueWFtbCIsImgiOiI0NzQzMjE4MGJkZmJhODc5ZmM3ZjgyYzRjNDUxMTgxNzAyZjI1MDA5In0=
  • Loading branch information
gcf-owl-bot[bot] authored and amanda-tarafa committed Sep 19, 2024
1 parent d6641c2 commit d036220
Show file tree
Hide file tree
Showing 16 changed files with 922 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
namespace GoogleCSharpSnippets
{
// [START cloudkms_v1_generated_Autokey_ListKeyHandles_async_flattened]
using Google.Api.Gax;
using Google.Cloud.Kms.V1;
using System;
using System.Linq;
using System.Threading.Tasks;

public sealed partial class GeneratedAutokeyClientSnippets
Expand All @@ -37,7 +40,39 @@ public async Task ListKeyHandlesAsync()
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
// Make the request
ListKeyHandlesResponse response = await autokeyClient.ListKeyHandlesAsync(parent);
PagedAsyncEnumerable<ListKeyHandlesResponse, KeyHandle> response = autokeyClient.ListKeyHandlesAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((KeyHandle 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((ListKeyHandlesResponse page) =>
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (KeyHandle 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<KeyHandle> 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 (KeyHandle 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 cloudkms_v1_generated_Autokey_ListKeyHandles_async_flattened]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
namespace GoogleCSharpSnippets
{
// [START cloudkms_v1_generated_Autokey_ListKeyHandles_async]
using Google.Api.Gax;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Kms.V1;
using System;
using System.Linq;
using System.Threading.Tasks;

public sealed partial class GeneratedAutokeyClientSnippets
Expand All @@ -42,7 +45,39 @@ public async Task ListKeyHandlesRequestObjectAsync()
Filter = "",
};
// Make the request
ListKeyHandlesResponse response = await autokeyClient.ListKeyHandlesAsync(request);
PagedAsyncEnumerable<ListKeyHandlesResponse, KeyHandle> response = autokeyClient.ListKeyHandlesAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((KeyHandle 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((ListKeyHandlesResponse page) =>
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (KeyHandle 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<KeyHandle> 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 (KeyHandle 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 cloudkms_v1_generated_Autokey_ListKeyHandles_async]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
namespace GoogleCSharpSnippets
{
// [START cloudkms_v1_generated_Autokey_ListKeyHandles_sync]
using Google.Api.Gax;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Kms.V1;
using System;

public sealed partial class GeneratedAutokeyClientSnippets
{
Expand All @@ -41,7 +43,39 @@ public void ListKeyHandlesRequestObject()
Filter = "",
};
// Make the request
ListKeyHandlesResponse response = autokeyClient.ListKeyHandles(request);
PagedEnumerable<ListKeyHandlesResponse, KeyHandle> response = autokeyClient.ListKeyHandles(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (KeyHandle 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 (ListKeyHandlesResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (KeyHandle 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<KeyHandle> 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 (KeyHandle 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 cloudkms_v1_generated_Autokey_ListKeyHandles_sync]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
namespace GoogleCSharpSnippets
{
// [START cloudkms_v1_generated_Autokey_ListKeyHandles_async_flattened_resourceNames]
using Google.Api.Gax;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Kms.V1;
using System;
using System.Linq;
using System.Threading.Tasks;

public sealed partial class GeneratedAutokeyClientSnippets
Expand All @@ -38,7 +41,39 @@ public async Task ListKeyHandlesResourceNamesAsync()
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
// Make the request
ListKeyHandlesResponse response = await autokeyClient.ListKeyHandlesAsync(parent);
PagedAsyncEnumerable<ListKeyHandlesResponse, KeyHandle> response = autokeyClient.ListKeyHandlesAsync(parent);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((KeyHandle 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((ListKeyHandlesResponse page) =>
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (KeyHandle 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<KeyHandle> 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 (KeyHandle 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 cloudkms_v1_generated_Autokey_ListKeyHandles_async_flattened_resourceNames]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
namespace GoogleCSharpSnippets
{
// [START cloudkms_v1_generated_Autokey_ListKeyHandles_sync_flattened_resourceNames]
using Google.Api.Gax;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Kms.V1;
using System;

public sealed partial class GeneratedAutokeyClientSnippets
{
Expand All @@ -37,7 +39,39 @@ public void ListKeyHandlesResourceNames()
// Initialize request argument(s)
LocationName parent = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]");
// Make the request
ListKeyHandlesResponse response = autokeyClient.ListKeyHandles(parent);
PagedEnumerable<ListKeyHandlesResponse, KeyHandle> response = autokeyClient.ListKeyHandles(parent);

// Iterate over all response items, lazily performing RPCs as required
foreach (KeyHandle 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 (ListKeyHandlesResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (KeyHandle 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<KeyHandle> 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 (KeyHandle 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 cloudkms_v1_generated_Autokey_ListKeyHandles_sync_flattened_resourceNames]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
namespace GoogleCSharpSnippets
{
// [START cloudkms_v1_generated_Autokey_ListKeyHandles_sync_flattened]
using Google.Api.Gax;
using Google.Cloud.Kms.V1;
using System;

public sealed partial class GeneratedAutokeyClientSnippets
{
Expand All @@ -36,7 +38,39 @@ public void ListKeyHandles()
// Initialize request argument(s)
string parent = "projects/[PROJECT]/locations/[LOCATION]";
// Make the request
ListKeyHandlesResponse response = autokeyClient.ListKeyHandles(parent);
PagedEnumerable<ListKeyHandlesResponse, KeyHandle> response = autokeyClient.ListKeyHandles(parent);

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

0 comments on commit d036220

Please sign in to comment.