File tree Expand file tree Collapse file tree 4 files changed +16
-17
lines changed Expand file tree Collapse file tree 4 files changed +16
-17
lines changed Original file line number Diff line number Diff line change 2525public class SearchUriExample {
2626
2727 public static void searchUriExample () throws IOException {
28- //The URL to be searched
28+ // The URL to be searched
2929 String uri = "http://testsafebrowsing.appspot.com/s/malware.html" ;
3030 SearchUrisResponse response = searchUriExample (uri );
3131 }
32-
32+
3333 // [START webrisk_search_uri]
3434 public static SearchUrisResponse searchUriExample (String uri ) throws IOException {
35- //create-webrisk-client
35+ // create-webrisk-client
3636 try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient .create ()) {
37- //Query the url for a specific threat type
38- SearchUrisRequest searchUrisRequest = SearchUrisRequest .newBuilder ()
39- .addThreatTypes (ThreatType .MALWARE )
40- .setUri (uri ).build ();
37+ // Query the url for a specific threat type
38+ SearchUrisRequest searchUrisRequest =
39+ SearchUrisRequest .newBuilder ().addThreatTypes (ThreatType .MALWARE ).setUri (uri ).build ();
4140 SearchUrisResponse searchUrisResponse = webRiskServiceClient .searchUris (searchUrisRequest );
4241 webRiskServiceClient .shutdownNow ();
4342 if (!searchUrisResponse .getThreat ().getThreatTypesList ().isEmpty ()) {
Original file line number Diff line number Diff line change 2424public class SubmitUriExample {
2525
2626 public static void submitUriExample () throws IOException {
27- //The URL to be submitted
27+ // The URL to be submitted
2828 String uri = "http://testsafebrowsing.appspot.com/s/malware.html" ;
2929 Submission response = submitUriExample (uri );
3030 }
3131
3232 // [START webrisk_submit_uri]
3333 public static Submission submitUriExample (String uri ) throws IOException {
34- //create-webrisk-client
34+ // create-webrisk-client
3535 try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient .create ()) {
36- Submission submission = Submission .newBuilder ()
37- .setUri (uri ).build ();
38- CreateSubmissionRequest submissionRequest = CreateSubmissionRequest .newBuilder ()
39- .setParent ("projects/your-project-id" ).setSubmission (submission ).build ();
36+ Submission submission = Submission .newBuilder ().setUri (uri ).build ();
37+ CreateSubmissionRequest submissionRequest =
38+ CreateSubmissionRequest .newBuilder ()
39+ .setParent ("projects/your-project-id" )
40+ .setSubmission (submission )
41+ .build ();
4042 Submission submissionResponse = webRiskServiceClient .createSubmission (submissionRequest );
4143 webRiskServiceClient .shutdownNow ();
4244 System .out .println ("The submitted " + submissionResponse );
4345 return submissionResponse ;
4446 }
45-
4647 }
4748 // [END webrisk_submit_uri]
4849}
Original file line number Diff line number Diff line change 2929public class SearchUriExampleTest {
3030 @ Test
3131 public void testSearchWithThreat () throws IOException {
32- //The URL to be searched
32+ // The URL to be searched
3333 String uri = "http://testsafebrowsing.appspot.com/s/malware.html" ;
3434 SearchUrisResponse actualResponse = SearchUriExample .searchUriExample (uri );
3535 List <ThreatType > type = actualResponse .getThreat ().getThreatTypesList ();
@@ -38,7 +38,7 @@ public void testSearchWithThreat() throws IOException {
3838
3939 @ Test
4040 public void testSearchWithoutThreat () throws IOException {
41- //The URL to be searched
41+ // The URL to be searched
4242 String uri = "http://testsafebrowsing.appspot.com/malware.html" ;
4343 SearchUrisResponse actualResponse = SearchUriExample .searchUriExample (uri );
4444 List <ThreatType > type = actualResponse .getThreat ().getThreatTypesList ();
Original file line number Diff line number Diff line change 1414 * limitations under the License.
1515 */
1616
17-
1817package webrisk ;
1918
2019import com .google .common .truth .Truth ;
You can’t perform that action at this time.
0 commit comments