Skip to content

samples(storage): add samples for bucket encryption encoforcement config#16045

Draft
bajajneha27 wants to merge 1 commit intogoogleapis:mainfrom
bajajneha27:bucket-encryption-sample
Draft

samples(storage): add samples for bucket encryption encoforcement config#16045
bajajneha27 wants to merge 1 commit intogoogleapis:mainfrom
bajajneha27:bucket-encryption-sample

Conversation

@bajajneha27
Copy link
Contributor

No description provided.

@product-auto-label product-auto-label bot added api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples. labels Mar 16, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces new C++ samples for the Google Cloud Storage client library, specifically focusing on managing bucket encryption enforcement configurations. These examples provide practical demonstrations of how to programmatically interact with and control the encryption policies for storage buckets, covering operations like retrieving current settings, applying new enforcement rules, and clearing existing configurations.

Highlights

  • New C++ Sample Added: A new C++ example file, storage_bucket_encryption_enforcement_samples.cc, has been added to demonstrate how to manage bucket encryption enforcement configurations.
  • Encryption Enforcement Operations: The new sample includes functions to retrieve, set, and remove Google-managed, customer-managed, and customer-supplied encryption key enforcement policies for Google Cloud Storage buckets.
  • Build System Integration: The new sample has been integrated into both the CMake and Bazel build systems, ensuring it is discoverable and buildable within the storage_examples project.
Changelog
  • google/cloud/storage/examples/CMakeLists.txt
    • Added storage_bucket_encryption_enforcement_samples.cc to the list of example sources.
  • google/cloud/storage/examples/storage_bucket_encryption_enforcement_samples.cc
    • Added a new C++ file containing samples for getting, setting, and removing bucket encryption enforcement configurations.
  • google/cloud/storage/examples/storage_examples.bzl
    • Added storage_bucket_encryption_enforcement_samples.cc to the storage_examples list.
Activity
  • No human activity (comments, reviews, etc.) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

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

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 adds new samples for managing bucket encryption enforcement configurations. The changes are well-structured and the new sample code correctly demonstrates the usage of the API. All original comments have been retained as they align with general C++ best practices and the Google C++ Style Guide, and none of the provided rules contradict them.

Comment on lines +122 to +123
std::cout << "\nCreating bucket to run the example (" << bucket_name << ")"
<< std::endl;

Choose a reason for hiding this comment

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

medium

Per the Google C++ Style Guide, you should use \n instead of std::endl. std::endl also flushes the stream, which is often unnecessary and can impact performance.

  std::cout << "\nCreating bucket to run the example (" << bucket_name << ")\n";
References
  1. The repository style guide defers to the Google C++ Style Guide, which states to use \n instead of std::endl to avoid performance issues with flushing the stream. (link)

Comment on lines +133 to +134
std::cout << "\nRunning the SetBucketEncryptionEnforcementConfig() example"
<< std::endl;

Choose a reason for hiding this comment

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

medium

Per the Google C++ Style Guide, you should use \n instead of std::endl. std::endl also flushes the stream, which is often unnecessary and can impact performance.

  std::cout << "\nRunning the SetBucketEncryptionEnforcementConfig() example\n";
References
  1. The repository style guide defers to the Google C++ Style Guide, which states to use \n instead of std::endl to avoid performance issues with flushing the stream. (link)

Comment on lines +137 to +138
std::cout << "\nRunning the GetBucketEncryptionEnforcementConfig() example [1]"
<< std::endl;

Choose a reason for hiding this comment

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

medium

Per the Google C++ Style Guide, you should use \n instead of std::endl. std::endl also flushes the stream, which is often unnecessary and can impact performance.

  std::cout << "\nRunning the GetBucketEncryptionEnforcementConfig() example [1]\n";
References
  1. The repository style guide defers to the Google C++ Style Guide, which states to use \n instead of std::endl to avoid performance issues with flushing the stream. (link)

Comment on lines +141 to +142
std::cout << "\nRunning the RemoveAllEncryptionEnforcementConfig() example"
<< std::endl;

Choose a reason for hiding this comment

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

medium

Per the Google C++ Style Guide, you should use \n instead of std::endl. std::endl also flushes the stream, which is often unnecessary and can impact performance.

  std::cout << "\nRunning the RemoveAllEncryptionEnforcementConfig() example\n";
References
  1. The repository style guide defers to the Google C++ Style Guide, which states to use \n instead of std::endl to avoid performance issues with flushing the stream. (link)

Comment on lines +145 to +146
std::cout << "\nRunning the GetBucketEncryptionEnforcementConfig() example [2]"
<< std::endl;

Choose a reason for hiding this comment

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

medium

Per the Google C++ Style Guide, you should use \n instead of std::endl. std::endl also flushes the stream, which is often unnecessary and can impact performance.

  std::cout << "\nRunning the GetBucketEncryptionEnforcementConfig() example [2]\n";
References
  1. The repository style guide defers to the Google C++ Style Guide, which states to use \n instead of std::endl to avoid performance issues with flushing the stream. (link)

@codecov
Copy link

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 98.71795% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.66%. Comparing base (48196b1) to head (12e20f5).

Files with missing lines Patch % Lines
...s/storage_bucket_encryption_enforcement_samples.cc 98.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16045      +/-   ##
==========================================
- Coverage   92.66%   92.66%   -0.01%     
==========================================
  Files        2341     2342       +1     
  Lines      215695   215773      +78     
==========================================
+ Hits       199876   199940      +64     
- Misses      15819    15833      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant