-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
feat(modelarmor): Added code samples for delete, get and list model armor templates #10070
Conversation
There was a problem hiding this 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.
- Added a new class
- 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.
- Added a new class
- 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.
- Added a new class
- 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.
- Added a new class
- 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.
- Added a new integration test suite
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
-
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. ↩
There was a problem hiding this 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 useModelArmorTemplate
while others useModelArmorTemplates
. 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.
Here is the summary of changes. You are about to add 3 region tags.
This comment is generated by snippet-bot.
|
There was a problem hiding this 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 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 |
.build(); | ||
|
||
// List all templates. | ||
ListTemplatesPagedResponse pagedResponse = client.listTemplates(request); |
There was a problem hiding this comment.
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!
Please resolve merge conflicts and then I will merge. Thanks! |
@telpirion Merge conflicts are resolved. Could you merge this PR? |
Description
Added code samples for delete, get and list Model Armor templates.
Checklist
pom.xml
parent set to latestshared-configuration
mvn clean verify
requiredmvn -P lint checkstyle:check
requiredmvn -P lint clean compile pmd:cpd-check spotbugs:check
advisory only