File tree 4 files changed +16
-17
lines changed
4 files changed +16
-17
lines changed Original file line number Diff line number Diff line change 25
25
public class SearchUriExample {
26
26
27
27
public static void searchUriExample () throws IOException {
28
- //The URL to be searched
28
+ // The URL to be searched
29
29
String uri = "http://testsafebrowsing.appspot.com/s/malware.html" ;
30
30
SearchUrisResponse response = searchUriExample (uri );
31
31
}
32
-
32
+
33
33
// [START webrisk_search_uri]
34
34
public static SearchUrisResponse searchUriExample (String uri ) throws IOException {
35
- //create-webrisk-client
35
+ // create-webrisk-client
36
36
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 ();
41
40
SearchUrisResponse searchUrisResponse = webRiskServiceClient .searchUris (searchUrisRequest );
42
41
webRiskServiceClient .shutdownNow ();
43
42
if (!searchUrisResponse .getThreat ().getThreatTypesList ().isEmpty ()) {
Original file line number Diff line number Diff line change 24
24
public class SubmitUriExample {
25
25
26
26
public static void submitUriExample () throws IOException {
27
- //The URL to be submitted
27
+ // The URL to be submitted
28
28
String uri = "http://testsafebrowsing.appspot.com/s/malware.html" ;
29
29
Submission response = submitUriExample (uri );
30
30
}
31
31
32
32
// [START webrisk_submit_uri]
33
33
public static Submission submitUriExample (String uri ) throws IOException {
34
- //create-webrisk-client
34
+ // create-webrisk-client
35
35
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 ();
40
42
Submission submissionResponse = webRiskServiceClient .createSubmission (submissionRequest );
41
43
webRiskServiceClient .shutdownNow ();
42
44
System .out .println ("The submitted " + submissionResponse );
43
45
return submissionResponse ;
44
46
}
45
-
46
47
}
47
48
// [END webrisk_submit_uri]
48
49
}
Original file line number Diff line number Diff line change 29
29
public class SearchUriExampleTest {
30
30
@ Test
31
31
public void testSearchWithThreat () throws IOException {
32
- //The URL to be searched
32
+ // The URL to be searched
33
33
String uri = "http://testsafebrowsing.appspot.com/s/malware.html" ;
34
34
SearchUrisResponse actualResponse = SearchUriExample .searchUriExample (uri );
35
35
List <ThreatType > type = actualResponse .getThreat ().getThreatTypesList ();
@@ -38,7 +38,7 @@ public void testSearchWithThreat() throws IOException {
38
38
39
39
@ Test
40
40
public void testSearchWithoutThreat () throws IOException {
41
- //The URL to be searched
41
+ // The URL to be searched
42
42
String uri = "http://testsafebrowsing.appspot.com/malware.html" ;
43
43
SearchUrisResponse actualResponse = SearchUriExample .searchUriExample (uri );
44
44
List <ThreatType > type = actualResponse .getThreat ().getThreatTypesList ();
Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
*/
16
16
17
-
18
17
package webrisk ;
19
18
20
19
import com .google .common .truth .Truth ;
You can’t perform that action at this time.
0 commit comments