Skip to content

samples: add samples for bucket encryption enforcement config#1772

Open
nidhiii-27 wants to merge 5 commits intomainfrom
add-bucket-encryption-enforcement-samples-3410657303470871774
Open

samples: add samples for bucket encryption enforcement config#1772
nidhiii-27 wants to merge 5 commits intomainfrom
add-bucket-encryption-enforcement-samples-3410657303470871774

Conversation

@nidhiii-27
Copy link
Contributor

Add Python samples demonstrating how to set, get, update, and remove bucket encryption enforcement configuration. Includes an integration test.


PR created automatically by Jules for task 3410657303470871774 started by @nidhiii-27

Co-authored-by: nidhiii-27 <224584462+nidhiii-27@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@nidhiii-27 nidhiii-27 requested review from a team as code owners March 17, 2026 11:33
@nidhiii-27 nidhiii-27 requested a review from gericdong March 17, 2026 11:33
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: storage Issues related to the googleapis/python-storage API. labels Mar 17, 2026
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Mar 17, 2026
@snippet-bot
Copy link

snippet-bot bot commented Mar 17, 2026

Here is the summary of changes.

You are about to add 3 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

@gemini-code-assist
Copy link
Contributor

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 a suite of Python samples designed to provide practical guidance on managing bucket encryption enforcement configurations within Google Cloud Storage. These samples cover the full lifecycle of encryption policy management, from initial setup to retrieval, modification, and removal, ensuring developers have clear examples for implementing robust data security measures.

Highlights

  • New Python Samples: Added Python samples demonstrating how to set, get, update, and remove bucket encryption enforcement configurations for Google Cloud Storage.
  • Integration Test: Included a comprehensive integration test (test_bucket_encryption_enforcement_config) to validate the functionality of the new encryption enforcement samples.
Changelog
  • samples/snippets/encryption_test.py
    • Imported new encryption enforcement sample functions.
    • Added test_bucket_encryption_enforcement_config to test the new encryption enforcement samples.
  • samples/snippets/storage_get_bucket_encryption_enforcement_config.py
    • Added a new file containing a function to retrieve the encryption enforcement configuration of a GCS bucket.
  • samples/snippets/storage_remove_all_bucket_encryption_enforcement_config.py
    • Added a new file containing a function to remove all encryption enforcement configurations from a GCS bucket.
  • samples/snippets/storage_set_bucket_encryption_enforcement_config.py
    • Added a new file containing a function to create a GCS bucket with initial encryption enforcement configurations.
  • samples/snippets/storage_update_encryption_enforcement_config.py
    • Added a new file containing a function to update the encryption enforcement configuration of a GCS bucket.
Activity
  • PR created automatically by Jules for task 3410657303470871774, initiated by @nidhiii-27.
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
Contributor

@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 Python samples and an integration test for managing bucket encryption enforcement configurations. The code is well-structured and the test coverage is good. I've identified a few areas for improvement regarding Python best practices and error handling to enhance code quality and robustness.

Co-authored-by: nidhiii-27 <224584462+nidhiii-27@users.noreply.github.com>
@nidhiii-27 nidhiii-27 requested review from a team as code owners March 17, 2026 12:22
Co-authored-by: nidhiii-27 <224584462+nidhiii-27@users.noreply.github.com>
@nidhiii-27 nidhiii-27 changed the title feat: add samples for bucket encryption enforcement config samples: add samples for bucket encryption enforcement config Mar 17, 2026
Co-authored-by: nidhiii-27 <224584462+nidhiii-27@users.noreply.github.com>
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)

# Restriction mode can be "FullyRestricted" or "NotRestricted"
Copy link

@iennae iennae Mar 17, 2026

Choose a reason for hiding this comment

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

This section seems a little confusing to me. you've got 3 options, and very similar named and the difference is in managed versus supplied. if you set the restriction mode that feels like the customer is customizing it. but then you also have google_managed_encryption_enforcement_config versus customer .. and maybe this is 3 different enforcements of Fully Restricted, Not Restricted, and no enforcement?

I might suggest doing something like the following where only one line is fully visible or adding more space between with comments and then slicing the specific example with a region tag. It's not standalone but then you can have it be copy-paste runnable while also being able to highlight the difference in documentation.

  # Setting restriction_mode to "FullyRestricted" means objects cannot 
        # be created using GMEK.
        bucket.google_managed_encryption_enforcement_config = EncryptionEnforcementConfig(
            restriction_mode="FullyRestricted"
        )
# Setting restriction_mode to "NotRestricted" ensures CMEK is permitted.
        # bucket.customer_managed_encryption_enforcement_config = EncryptionEnforcementConfig(
            restriction_mode="NotRestricted"
        )

Co-authored-by: nidhiii-27 <224584462+nidhiii-27@users.noreply.github.com>
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 googleapis/python-storage API. samples Issues that are directly related to samples. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants