Skip to content
New issue

Have 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: Adding API v2 Source samples #9299

Merged
merged 5 commits into from May 23, 2024

Conversation

rafaelMurata
Copy link
Contributor

@rafaelMurata rafaelMurata commented Apr 25, 2024

Description

b/337023783

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

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

Copy link

snippet-bot bot commented Apr 25, 2024

Here is the summary of changes.

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

@product-auto-label product-auto-label bot added samples Issues that are directly related to samples. api: securitycenter Issues related to the Security Command Center API. labels Apr 25, 2024
@Sita04 Sita04 assigned Sita04 and unassigned kweinmeister Apr 25, 2024
@Sita04 Sita04 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 26, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 26, 2024
Copy link
Contributor

@Sita04 Sita04 left a comment

Choose a reason for hiding this comment

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

Thanks for the snippets. PTAL at the comments and the failing tests.

try (SecurityCenterClient client = SecurityCenterClient.create()) {

// Start setting up a request to get a source.
SourceName sourceName = SourceName.ofOrganizationSourceName(organizationId, sourceId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't the v2 API require a location to be passed as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I create a source, this is the response:
Created source : name: "organizations/xx/sources/xx"

To use V2, this syntax must be used:
"organizations/[organization_id]/source/[source_id]"

but I tried other approaches like
"organizations/%s/locations/%s/sources/%s"
"organizations/%s/sources/%s/locations/%s"
SourceName sourceName = SourceName.ofOrganizationSourceName(organizationId, sourceId);
Parent String = String.format("%s/locals/%s", sourceName.toString(), "global");

all resulting in an INVALID_ARGUMENT.
Kindly show me the best approach.

}

@BeforeClass
public static void setUp() throws IOException, InterruptedException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Create a corresponding method with AfterClass annotation cleaning up the resources created in setUp()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

@rafaelMurata I'm unable to see the changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for V2 I can't clear the SOURCE and FINDING.

}

@BeforeClass
public static void setUp() throws IOException, InterruptedException {
Copy link
Contributor

Choose a reason for hiding this comment

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

@rafaelMurata I'm unable to see the changes.

@Sita04
Copy link
Contributor

Sita04 commented May 6, 2024

@rafaelMurata Kindly add the AfterClass method to clean up the resources created during setup

@rafaelMurata
Copy link
Contributor Author

@rafaelMurata Kindly add the AfterClass method to clean up the resources created during setup

done.

@Sita04 Sita04 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 9, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 9, 2024
@rafaelMurata
Copy link
Contributor Author

@Sita04
Please run kokoro again. Thanks.

@Sita04 Sita04 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 13, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 13, 2024
@rafaelMurata
Copy link
Contributor Author

@Sita04
Please run kokoro again. Thanks.

@Sita04 Sita04 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 23, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 23, 2024
@Sita04 Sita04 merged commit 2b43cb4 into GoogleCloudPlatform:main May 23, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: securitycenter Issues related to the Security Command Center API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants