Skip to content

samples(Storage): add Storage Control Rapid Cache samples - #3353

Merged
sahusneha2004 merged 5 commits into
mainfrom
storage-control-rapid-cache-samples-dotnet
Nov 16, 2026
Merged

sahusneha2004 merged 5 commits into
mainfrom
storage-control-rapid-cache-samples-dotnet

Conversation

@sahusneha2004

@sahusneha2004 sahusneha2004 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds Storage Control Rapid Cache samples for .NET (storage/api/Storage.Samples):

Region tag File
storage_control_create_rapid_cache StorageControlCreateRapidCache.cs
storage_control_get_rapid_cache StorageControlGetRapidCache.cs
storage_control_list_rapid_caches StorageControlListRapidCaches.cs
storage_control_update_rapid_cache StorageControlUpdateRapidCache.cs
storage_control_disable_rapid_cache StorageControlDisableRapidCache.cs

Also bumps Google.Cloud.Storage.Control.V2 from 1.8.0 to 1.11.0, the first release that includes the Rapid Cache APIs.

Behavior notes

  • Create sets only parent, zone and cache_type = "rapid-cache-ultra". It does not set a name: the server derives it from the bucket and zone (projects/_/buckets/{bucket}/rapidCaches/{zone}), as in the Anywhere Cache create sample. It waits for the operation and prints the returned name and state.
  • Get / Update / Disable take rapidCacheId, which is the cache's zone; the default is "us-central1-a".
  • List takes pageSize (default 10), shows item-by-item and page-by-page iteration, and returns the PagedEnumerable directly.
  • Update sets ttl to 172800s with update mask ["ttl"].
  • Disable starts the long-running operation, prints the operation name and returns the Operation. It does not wait: the cache moves to disabled within seconds, but the operation only completes once the cache is fully removed, which can take more than an hour. Callers can use StorageControlGetRapidCache to check for the disabled state.

Tests

Storage.Samples.Tests/StorageControlRapidCacheTest.cs runs the full lifecycle: create, get, list, update, then disable and poll Get (up to 12 × 10s) until the state is disabled. It uses a regional HNS + UBLA bucket in the zone's region, with the standard fixture sleep after bucket creation. The zone defaults to us-central1-a and can be overridden with the RAPID_CACHE_ZONE env var.

  • The test is [Fact(Skip = ...)] by default. Rapid Cache needs an allowlisted project, and Anywhere Cache, the closest precedent, has no CI tests in this repo either.
  • Bucket cleanup is left to the fixture (TempBucketNames). Deleting the bucket returns 409 until the disabled cache is fully removed, so the bucket may need to be deleted manually later.
  • Live run against an allowlisted project with the skip removed: passed (29s).

Internal bug: b/482946642

Adds create, get, list, update and disable Rapid Cache samples for Storage Control, with a (skipped by default) integration test. Bumps Google.Cloud.Storage.Control.V2 to 1.11.0. b/482946642

[Generated-by: AI]
@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Nov 2, 2026
@sahusneha2004 sahusneha2004 added ai-generated Generated by AI storage-sample-architect Generated by storage-sample-architect skill labels Nov 2, 2026
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Nov 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request upgrades the Google.Cloud.Storage.Control.V2 package to version 1.11.0 and introduces code samples and integration tests for managing the Rapid Cache lifecycle, including creation, retrieval, listing, updating, and disabling. The review feedback highlights two important improvements in the test suite: adding a safety guard when parsing the region from the zone string to prevent an ArgumentOutOfRangeException, and registering the newly created bucket in the test fixture's temporary bucket collection immediately after creation to avoid resource leaks if the test is aborted.

Set the explicit cache name (ID = zone), cache_type rapid-cache-ultra and ttl 24h on create; wait for the disable LRO; tests assert running state, cache type, list membership and the updated ttl, and bound the disable wait. Aligns with googleapis/google-cloud-java#14529. b/482946642

[Generated-by: AI]
Guard zone-to-region parsing when the zone has no hyphen, and register the test bucket in the fixture right after creation so it is cleaned up even if the test aborts.

[Generated-by: AI]
…rdown

- Create sample sets only name, zone and cache type (rapid-cache-ultra);
  TTL is left to the update sample, matching AnywhereCacheCreate.
- Use a rapidCacheId variable in the create sample, consistent with
  Get/Update/Disable.
- Test: linear lifecycle flow with IDisposable teardown that disables
  the cache if still active (positive _cacheActive flag) and deletes the
  bucket best-effort; no nested try/catch/finally. Disable wait stays
  bounded via LRO PollSettings.

[Generated-by: AI]
@sahusneha2004
sahusneha2004 marked this pull request as ready for review November 6, 2026 11:39
@sahusneha2004
sahusneha2004 requested review from a team as code owners November 6, 2026 11:39
@snippet-bot

snippet-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 5 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

- Disable starts the operation, prints its name and returns it instead of
  waiting; the test polls Get until the state is "disabled".
- Create no longer sets the cache name; the server derives it from the
  bucket and zone.
- List returns the PagedEnumerable directly and accepts a page size.
- Get/Update/Disable default the cache ID to the zone "us-central1-a".
- Test uses the fixture sleep after bucket creation and relies on the
  fixture for bucket cleanup.

[Generated-by: AI]
@sahusneha2004
sahusneha2004 merged commit d89706a into main Nov 16, 2026
16 checks passed
@sahusneha2004
sahusneha2004 deleted the storage-control-rapid-cache-samples-dotnet branch November 16, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Generated by AI api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. storage-sample-architect Generated by storage-sample-architect skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants