8000 feat(modelarmor): Added code samples for delete, get and list model armor templates by rudrakhsha-crest · Pull Request #10070 · GoogleCloudPlatform/java-docs-samples · GitHub
[go: up one dir, main page]

Skip to content

feat(modelarmor): Added code samples for delete, get and list model armor templates #10070

New issue

Have 10000 a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

rudrakhsha-crest
Copy link
Contributor
@rudrakhsha-crest rudrakhsha-crest commented Apr 11, 2025

Description

Added code samples for delete, get and list Model Armor templates.

Checklist

  • I have followed Sample Format Guide
  • pom.xml parent set to latest shared-configuration
  • Appropriate changes to README are included in PR
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • Tests pass: mvn clean verify required
  • Lint passes: mvn -P lint checkstyle:check required
  • Static Analysis: mvn -P lint clean compile pmd:cpd-check spotbugs:check advisory only
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

@rudrakhsha-crest rudrakhsha-crest requested review from yoshi-approver and a team as code owners April 11, 2025 12:40
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Apr 11, 2025
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.

Hello @rudrakhsha-crest, 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!

Summary of Changes

This pull request adds code samples for deleting, getting, and listing Model Armor templates. It includes four new Java files: DeleteTemplate.java, GetTemplate.java, ListTemplates.java, and ListTemplatesWithFilter.java. Additionally, it introduces a test file SnippetsIT.java to verify the functionality of these new code samples. The samples demonstrate how to interact with the Model Armor API to manage templates.

Highlights

  • New Code Samples: The pull request introduces new code samples for common Model Armor template operations: delete, get, and list.
  • Integration Tests: An integration test suite (SnippetsIT.java) is added to ensure the new code samples function as expected.
  • ModelArmor API interaction: The code samples demonstrate how to use the ModelArmorClient to interact with the Model Armor API.

Changelog

Click here to see the changelog
  • modelarmor/main/java/modelarmor/DeleteTemplate.java
    • Added a new class DeleteTemplate to demonstrate how to delete a Model Armor template.
    • Includes a deleteTemplate method that takes projectId, locationId, and templateId as parameters.
    • Uses the ModelArmorClient to delete the specified template.
  • modelarmor/main/java/modelarmor/GetTemplate.java
    • Added a new class GetTemplate to demonstrate how to retrieve a Model Armor template.
    • Includes a getTemplate method that takes projectId, locationId, and templateId as parameters.
    • Uses the ModelArmorClient to get the specified template and prints it to the console.
  • modelarmor/main/java/modelarmor/ListTemplates.java
    • Added a new class ListTemplates to demonstrate how to list all Model Armor templates.
    • Includes a listTemplates method that takes projectId and locationId as parameters.
    • Uses the ModelArmorClient to list all templates in the specified location and prints them to the console.
  • modelarmor/main/java/modelarmor/ListTemplatesWithFilter.java
    • Added a new class ListTemplatesWithFilter to demonstrate how to list Model Armor templates with a filter.
    • Includes a listTemplatesWithFilter method that takes projectId, locationId, and templateId as parameters.
    • Uses the ModelArmorClient to list templates matching the specified filter and prints them to the console.
  • modelarmor/test/java/modelarmor/SnippetsIT.java
    • Added a new integration test suite SnippetsIT to test the new code samples.
    • Includes tests for deleting, getting, and listing Model Armor templates.
    • Uses JUnit to define and run the integration tests.
    • The tests create a template, perform an action on it, and then delete the template.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.


A template's tale,
Get, list, delete, no fail,
ModelArmor's might.

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

The pull request introduces code samples for deleting, getting, and listing model armor templates. The code appears to be well-structured and follows a consistent pattern. However, there are a few areas that could be improved to enhance readability and maintainability.

Summary of Findings

  • Missing Create Template Sample: There is no code sample for creating a template, which is essential for testing the other functionalities. Without a create sample, the integration tests rely on an external mechanism to create the template, which is not ideal.
  • Inconsistent Naming: The naming of the test methods in SnippetsIT.java is inconsistent. Some methods use ModelArmorTemplate while others use ModelArmorTemplates. Standardizing the naming convention would improve readability.
  • Duplicated Endpoint Definition: The apiEndpoint is defined in each method. It should be defined as a constant or a method to avoid duplication.

Merge Readiness

The pull request is not quite ready for merging. The absence of a create template sample and the inconsistencies in naming and endpoint definitions should be addressed before merging. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging.

Copy link
snippet-bot bot commented Apr 11, 2025

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

Copy link
Contributor
@telpirion telpirion left a comment

Choose a reason for hiding this comment

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

This PR has the same global issues as #10068 . Please re-open once you have addressed global issues.

@telpirion telpirion marked this pull request as draft April 11, 2025 19:40
@rudrakhsha-crest rudrakhsha-crest marked this pull request as ready for review April 15, 2025 13:46
@harshnasitcrest
Copy link
Contributor

This PR has the same global issues as #10068 . Please re-open once you have addressed global issues.

@telpirion Thanks for the review! All global issues have been addressed in this PR. Note that create templates and delete template snippet have been added just to pass tests. Please ignore its review. They're present in #10068

@gptSanyam gptSanyam added kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Apr 17, 2025
@kokoro-team kokoro-team removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Apr 17, 2025
@gptSanyam gptSanyam added kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Apr 18, 2025
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 18, 2025
@kokoro-team kokoro-team removed kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Apr 18, 2025
@product-auto-label product-auto-label bot added the api: modelarmor Issues related to the Model Armor API. label May 1, 2025
.build();

// List all templates.
ListTemplatesPagedResponse pagedResponse = client.listTemplates(request);
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: showing how to page responses from a list operation is a nice-to-have here. Thanks!

@telpirion telpirion added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 6, 2025
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 6, 2025
@telpirion
Copy link
Contributor

Please resolve merge conflicts and then I will merge. Thanks!

@harshnasitcrest harshnasitcrest requested review from a team as code owners May 7, 2025 17:33
@harshnasitcrest
Copy link
Contributor

Please resolve merge conflicts and then I will merge. Thanks!

@telpirion Merge conflicts are resolved. Could you merge this PR?

@telpirion telpirion merged commit 414e26b into GoogleCloudPlatform:main May 8, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: modelarmor Issues related to the Model Armor API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0