Skip to content

Commit

Permalink
chore: migrate to owlbot (#525)
Browse files Browse the repository at this point in the history
  • Loading branch information
Neenu1995 authored Sep 5, 2021
1 parent ea81f59 commit 46904b9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
13 changes: 6 additions & 7 deletions webrisk/src/main/java/webrisk/SearchUriExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,18 @@
public class SearchUriExample {

public static void searchUriExample() throws IOException {
//The URL to be searched
// The URL to be searched
String uri = "http://testsafebrowsing.appspot.com/s/malware.html";
SearchUrisResponse response = searchUriExample(uri);
}

// [START webrisk_search_uri]
public static SearchUrisResponse searchUriExample(String uri) throws IOException {
//create-webrisk-client
// create-webrisk-client
try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
//Query the url for a specific threat type
SearchUrisRequest searchUrisRequest = SearchUrisRequest.newBuilder()
.addThreatTypes(ThreatType.MALWARE)
.setUri(uri).build();
// Query the url for a specific threat type
SearchUrisRequest searchUrisRequest =
SearchUrisRequest.newBuilder().addThreatTypes(ThreatType.MALWARE).setUri(uri).build();
SearchUrisResponse searchUrisResponse = webRiskServiceClient.searchUris(searchUrisRequest);
webRiskServiceClient.shutdownNow();
if (!searchUrisResponse.getThreat().getThreatTypesList().isEmpty()) {
Expand Down
15 changes: 8 additions & 7 deletions webrisk/src/main/java/webrisk/SubmitUriExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,26 @@
public class SubmitUriExample {

public static void submitUriExample() throws IOException {
//The URL to be submitted
// The URL to be submitted
String uri = "http://testsafebrowsing.appspot.com/s/malware.html";
Submission response = submitUriExample(uri);
}

// [START webrisk_submit_uri]
public static Submission submitUriExample(String uri) throws IOException {
//create-webrisk-client
// create-webrisk-client
try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
Submission submission = Submission.newBuilder()
.setUri(uri).build();
CreateSubmissionRequest submissionRequest = CreateSubmissionRequest.newBuilder()
.setParent("projects/your-project-id").setSubmission(submission).build();
Submission submission = Submission.newBuilder().setUri(uri).build();
CreateSubmissionRequest submissionRequest =
CreateSubmissionRequest.newBuilder()
.setParent("projects/your-project-id")
.setSubmission(submission)
.build();
Submission submissionResponse = webRiskServiceClient.createSubmission(submissionRequest);
webRiskServiceClient.shutdownNow();
System.out.println("The submitted " + submissionResponse);
return submissionResponse;
}

}
// [END webrisk_submit_uri]
}
4 changes: 2 additions & 2 deletions webrisk/src/test/java/webrisk/SearchUriExampleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class SearchUriExampleTest {
@Test
public void testSearchWithThreat() throws IOException {
//The URL to be searched
// The URL to be searched
String uri = "http://testsafebrowsing.appspot.com/s/malware.html";
SearchUrisResponse actualResponse = SearchUriExample.searchUriExample(uri);
List<ThreatType> type = actualResponse.getThreat().getThreatTypesList();
Expand All @@ -38,7 +38,7 @@ public void testSearchWithThreat() throws IOException {

@Test
public void testSearchWithoutThreat() throws IOException {
//The URL to be searched
// The URL to be searched
String uri = "http://testsafebrowsing.appspot.com/malware.html";
SearchUrisResponse actualResponse = SearchUriExample.searchUriExample(uri);
List<ThreatType> type = actualResponse.getThreat().getThreatTypesList();
Expand Down
1 change: 0 additions & 1 deletion webrisk/src/test/java/webrisk/SubmitUriExampleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/


package webrisk;

import com.google.common.truth.Truth;
Expand Down

0 comments on commit 46904b9

Please sign in to comment.