1 /* 2 * Copyright 2022 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.cloud.webrisk.v1; 18 19 import com.google.api.gax.core.BackgroundResource; 20 import com.google.api.gax.rpc.UnaryCallable; 21 import com.google.cloud.webrisk.v1.stub.WebRiskServiceStub; 22 import com.google.cloud.webrisk.v1.stub.WebRiskServiceStubSettings; 23 import com.google.protobuf.ByteString; 24 import com.google.webrisk.v1.ComputeThreatListDiffRequest; 25 import com.google.webrisk.v1.ComputeThreatListDiffResponse; 26 import com.google.webrisk.v1.CreateSubmissionRequest; 27 import com.google.webrisk.v1.ProjectName; 28 import com.google.webrisk.v1.SearchHashesRequest; 29 import com.google.webrisk.v1.SearchHashesResponse; 30 import com.google.webrisk.v1.SearchUrisRequest; 31 import com.google.webrisk.v1.SearchUrisResponse; 32 import com.google.webrisk.v1.Submission; 33 import com.google.webrisk.v1.ThreatType; 34 import java.io.IOException; 35 import java.util.List; 36 import java.util.concurrent.TimeUnit; 37 import javax.annotation.Generated; 38 39 // AUTO-GENERATED DOCUMENTATION AND CLASS. 40 /** 41 * Service Description: Web Risk API defines an interface to detect malicious URLs on your website 42 * and in client applications. 43 * 44 * <p>This class provides the ability to make remote calls to the backing service through method 45 * calls that map to API methods. Sample code to get started: 46 * 47 * <pre>{@code 48 * // This snippet has been automatically generated and should be regarded as a code template only. 49 * // It will require modifications to work: 50 * // - It may require correct/in-range values for request initialization. 51 * // - It may require specifying regional endpoints when creating the service client as shown in 52 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 53 * try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) { 54 * ThreatType threatType = ThreatType.forNumber(0); 55 * ByteString versionToken = ByteString.EMPTY; 56 * ComputeThreatListDiffRequest.Constraints constraints = 57 * ComputeThreatListDiffRequest.Constraints.newBuilder().build(); 58 * ComputeThreatListDiffResponse response = 59 * webRiskServiceClient.computeThreatListDiff(threatType, versionToken, constraints); 60 * } 61 * }</pre> 62 * 63 * <p>Note: close() needs to be called on the WebRiskServiceClient object to clean up resources such 64 * as threads. In the example above, try-with-resources is used, which automatically calls close(). 65 * 66 * <p>The surface of this class includes several types of Java methods for each of the API's 67 * methods: 68 * 69 * <ol> 70 * <li>A "flattened" method. With this type of method, the fields of the request type have been 71 * converted into function parameters. It may be the case that not all fields are available as 72 * parameters, and not every API method will have a flattened method entry point. 73 * <li>A "request object" method. This type of method only takes one parameter, a request object, 74 * which must be constructed before the call. Not every API method will have a request object 75 * method. 76 * <li>A "callable" method. This type of method takes no parameters and returns an immutable API 77 * callable object, which can be used to initiate calls to the service. 78 * </ol> 79 * 80 * <p>See the individual methods for example code. 81 * 82 * <p>Many parameters require resource names to be formatted in a particular way. To assist with 83 * these names, this class includes a format method for each type of name, and additionally a parse 84 * method to extract the individual identifiers contained within names that are returned. 85 * 86 * <p>This class can be customized by passing in a custom instance of WebRiskServiceSettings to 87 * create(). For example: 88 * 89 * <p>To customize credentials: 90 * 91 * <pre>{@code 92 * // This snippet has been automatically generated and should be regarded as a code template only. 93 * // It will require modifications to work: 94 * // - It may require correct/in-range values for request initialization. 95 * // - It may require specifying regional endpoints when creating the service client as shown in 96 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 97 * WebRiskServiceSettings webRiskServiceSettings = 98 * WebRiskServiceSettings.newBuilder() 99 * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) 100 * .build(); 101 * WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create(webRiskServiceSettings); 102 * }</pre> 103 * 104 * <p>To customize the endpoint: 105 * 106 * <pre>{@code 107 * // This snippet has been automatically generated and should be regarded as a code template only. 108 * // It will require modifications to work: 109 * // - It may require correct/in-range values for request initialization. 110 * // - It may require specifying regional endpoints when creating the service client as shown in 111 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 112 * WebRiskServiceSettings webRiskServiceSettings = 113 * WebRiskServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); 114 * WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create(webRiskServiceSettings); 115 * }</pre> 116 * 117 * <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over 118 * the wire: 119 * 120 * <pre>{@code 121 * // This snippet has been automatically generated and should be regarded as a code template only. 122 * // It will require modifications to work: 123 * // - It may require correct/in-range values for request initialization. 124 * // - It may require specifying regional endpoints when creating the service client as shown in 125 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 126 * WebRiskServiceSettings webRiskServiceSettings = 127 * WebRiskServiceSettings.newHttpJsonBuilder().build(); 128 * WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create(webRiskServiceSettings); 129 * }</pre> 130 * 131 * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. 132 */ 133 @Generated("by gapic-generator-java") 134 public class WebRiskServiceClient implements BackgroundResource { 135 private final WebRiskServiceSettings settings; 136 private final WebRiskServiceStub stub; 137 138 /** Constructs an instance of WebRiskServiceClient with default settings. */ create()139 public static final WebRiskServiceClient create() throws IOException { 140 return create(WebRiskServiceSettings.newBuilder().build()); 141 } 142 143 /** 144 * Constructs an instance of WebRiskServiceClient, using the given settings. The channels are 145 * created based on the settings passed in, or defaults for any settings that are not set. 146 */ create(WebRiskServiceSettings settings)147 public static final WebRiskServiceClient create(WebRiskServiceSettings settings) 148 throws IOException { 149 return new WebRiskServiceClient(settings); 150 } 151 152 /** 153 * Constructs an instance of WebRiskServiceClient, using the given stub for making calls. This is 154 * for advanced usage - prefer using create(WebRiskServiceSettings). 155 */ create(WebRiskServiceStub stub)156 public static final WebRiskServiceClient create(WebRiskServiceStub stub) { 157 return new WebRiskServiceClient(stub); 158 } 159 160 /** 161 * Constructs an instance of WebRiskServiceClient, using the given settings. This is protected so 162 * that it is easy to make a subclass, but otherwise, the static factory methods should be 163 * preferred. 164 */ WebRiskServiceClient(WebRiskServiceSettings settings)165 protected WebRiskServiceClient(WebRiskServiceSettings settings) throws IOException { 166 this.settings = settings; 167 this.stub = ((WebRiskServiceStubSettings) settings.getStubSettings()).createStub(); 168 } 169 WebRiskServiceClient(WebRiskServiceStub stub)170 protected WebRiskServiceClient(WebRiskServiceStub stub) { 171 this.settings = null; 172 this.stub = stub; 173 } 174 getSettings()175 public final WebRiskServiceSettings getSettings() { 176 return settings; 177 } 178 getStub()179 public WebRiskServiceStub getStub() { 180 return stub; 181 } 182 183 // AUTO-GENERATED DOCUMENTATION AND METHOD. 184 /** 185 * Gets the most recent threat list diffs. These diffs should be applied to a local database of 186 * hashes to keep it up-to-date. If the local database is empty or excessively out-of-date, a 187 * complete snapshot of the database will be returned. This Method only updates a single 188 * ThreatList at a time. To update multiple ThreatList databases, this method needs to be called 189 * once for each list. 190 * 191 * <p>Sample code: 192 * 193 * <pre>{@code 194 * // This snippet has been automatically generated and should be regarded as a code template only. 195 * // It will require modifications to work: 196 * // - It may require correct/in-range values for request initialization. 197 * // - It may require specifying regional endpoints when creating the service client as shown in 198 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 199 * try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) { 200 * ThreatType threatType = ThreatType.forNumber(0); 201 * ByteString versionToken = ByteString.EMPTY; 202 * ComputeThreatListDiffRequest.Constraints constraints = 203 * ComputeThreatListDiffRequest.Constraints.newBuilder().build(); 204 * ComputeThreatListDiffResponse response = 205 * webRiskServiceClient.computeThreatListDiff(threatType, versionToken, constraints); 206 * } 207 * }</pre> 208 * 209 * @param threatType Required. The threat list to update. Only a single ThreatType should be 210 * specified per request. If you want to handle multiple ThreatTypes, you must make one 211 * request per ThreatType. 212 * @param versionToken The current version token of the client for the requested list (the client 213 * version that was received from the last successful diff). If the client does not have a 214 * version token (this is the first time calling ComputeThreatListDiff), this may be left 215 * empty and a full database snapshot will be returned. 216 * @param constraints Required. The constraints associated with this request. 217 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 218 */ computeThreatListDiff( ThreatType threatType, ByteString versionToken, ComputeThreatListDiffRequest.Constraints constraints)219 public final ComputeThreatListDiffResponse computeThreatListDiff( 220 ThreatType threatType, 221 ByteString versionToken, 222 ComputeThreatListDiffRequest.Constraints constraints) { 223 ComputeThreatListDiffRequest request = 224 ComputeThreatListDiffRequest.newBuilder() 225 .setThreatType(threatType) 226 .setVersionToken(versionToken) 227 .setConstraints(constraints) 228 .build(); 229 return computeThreatListDiff(request); 230 } 231 232 // AUTO-GENERATED DOCUMENTATION AND METHOD. 233 /** 234 * Gets the most recent threat list diffs. These diffs should be applied to a local database of 235 * hashes to keep it up-to-date. If the local database is empty or excessively out-of-date, a 236 * complete snapshot of the database will be returned. This Method only updates a single 237 * ThreatList at a time. To update multiple ThreatList databases, this method needs to be called 238 * once for each list. 239 * 240 * <p>Sample code: 241 * 242 * <pre>{@code 243 * // This snippet has been automatically generated and should be regarded as a code template only. 244 * // It will require modifications to work: 245 * // - It may require correct/in-range values for request initialization. 246 * // - It may require specifying regional endpoints when creating the service client as shown in 247 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 248 * try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) { 249 * ComputeThreatListDiffRequest request = 250 * ComputeThreatListDiffRequest.newBuilder() 251 * .setThreatType(ThreatType.forNumber(0)) 252 * .setVersionToken(ByteString.EMPTY) 253 * .setConstraints(ComputeThreatListDiffRequest.Constraints.newBuilder().build()) 254 * .build(); 255 * ComputeThreatListDiffResponse response = webRiskServiceClient.computeThreatListDiff(request); 256 * } 257 * }</pre> 258 * 259 * @param request The request object containing all of the parameters for the API call. 260 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 261 */ computeThreatListDiff( ComputeThreatListDiffRequest request)262 public final ComputeThreatListDiffResponse computeThreatListDiff( 263 ComputeThreatListDiffRequest request) { 264 return computeThreatListDiffCallable().call(request); 265 } 266 267 // AUTO-GENERATED DOCUMENTATION AND METHOD. 268 /** 269 * Gets the most recent threat list diffs. These diffs should be applied to a local database of 270 * hashes to keep it up-to-date. If the local database is empty or excessively out-of-date, a 271 * complete snapshot of the database will be returned. This Method only updates a single 272 * ThreatList at a time. To update multiple ThreatList databases, this method needs to be called 273 * once for each list. 274 * 275 * <p>Sample code: 276 * 277 * <pre>{@code 278 * // This snippet has been automatically generated and should be regarded as a code template only. 279 * // It will require modifications to work: 280 * // - It may require correct/in-range values for request initialization. 281 * // - It may require specifying regional endpoints when creating the service client as shown in 282 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 283 * try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) { 284 * ComputeThreatListDiffRequest request = 285 * ComputeThreatListDiffRequest.newBuilder() 286 * .setThreatType(ThreatType.forNumber(0)) 287 * .setVersionToken(ByteString.EMPTY) 288 * .setConstraints(ComputeThreatListDiffRequest.Constraints.newBuilder().build()) 289 * .build(); 290 * ApiFuture<ComputeThreatListDiffResponse> future = 291 * webRiskServiceClient.computeThreatListDiffCallable().futureCall(request); 292 * // Do something. 293 * ComputeThreatListDiffResponse response = future.get(); 294 * } 295 * }</pre> 296 */ 297 public final UnaryCallable<ComputeThreatListDiffRequest, ComputeThreatListDiffResponse> computeThreatListDiffCallable()298 computeThreatListDiffCallable() { 299 return stub.computeThreatListDiffCallable(); 300 } 301 302 // AUTO-GENERATED DOCUMENTATION AND METHOD. 303 /** 304 * This method is used to check whether a URI is on a given threatList. Multiple threatLists may 305 * be searched in a single query. The response will list all requested threatLists the URI was 306 * found to match. If the URI is not found on any of the requested ThreatList an empty response 307 * will be returned. 308 * 309 * <p>Sample code: 310 * 311 * <pre>{@code 312 * // This snippet has been automatically generated and should be regarded as a code template only. 313 * // It will require modifications to work: 314 * // - It may require correct/in-range values for request initialization. 315 * // - It may require specifying regional endpoints when creating the service client as shown in 316 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 317 * try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) { 318 * String uri = "uri116076"; 319 * List<ThreatType> threatTypes = new ArrayList<>(); 320 * SearchUrisResponse response = webRiskServiceClient.searchUris(uri, threatTypes); 321 * } 322 * }</pre> 323 * 324 * @param uri Required. The URI to be checked for matches. 325 * @param threatTypes Required. The ThreatLists to search in. Multiple ThreatLists may be 326 * specified. 327 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 328 */ searchUris(String uri, List<ThreatType> threatTypes)329 public final SearchUrisResponse searchUris(String uri, List<ThreatType> threatTypes) { 330 SearchUrisRequest request = 331 SearchUrisRequest.newBuilder().setUri(uri).addAllThreatTypes(threatTypes).build(); 332 return searchUris(request); 333 } 334 335 // AUTO-GENERATED DOCUMENTATION AND METHOD. 336 /** 337 * This method is used to check whether a URI is on a given threatList. Multiple threatLists may 338 * be searched in a single query. The response will list all requested threatLists the URI was 339 * found to match. If the URI is not found on any of the requested ThreatList an empty response 340 * will be returned. 341 * 342 * <p>Sample code: 343 * 344 * <pre>{@code 345 * // This snippet has been automatically generated and should be regarded as a code template only. 346 * // It will require modifications to work: 347 * // - It may require correct/in-range values for request initialization. 348 * // - It may require specifying regional endpoints when creating the service client as shown in 349 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 350 * try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) { 351 * SearchUrisRequest request = 352 * SearchUrisRequest.newBuilder() 353 * .setUri("uri116076") 354 * .addAllThreatTypes(new ArrayList<ThreatType>()) 355 * .build(); 356 * SearchUrisResponse response = webRiskServiceClient.searchUris(request); 357 * } 358 * }</pre> 359 * 360 * @param request The request object containing all of the parameters for the API call. 361 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 362 */ searchUris(SearchUrisRequest request)363 public final SearchUrisResponse searchUris(SearchUrisRequest request) { 364 return searchUrisCallable().call(request); 365 } 366 367 // AUTO-GENERATED DOCUMENTATION AND METHOD. 368 /** 369 * This method is used to check whether a URI is on a given threatList. Multiple threatLists may 370 * be searched in a single query. The response will list all requested threatLists the URI was 371 * found to match. If the URI is not found on any of the requested ThreatList an empty response 372 * will be returned. 373 * 374 * <p>Sample code: 375 * 376 * <pre>{@code 377 * // This snippet has been automatically generated and should be regarded as a code template only. 378 * // It will require modifications to work: 379 * // - It may require correct/in-range values for request initialization. 380 * // - It may require specifying regional endpoints when creating the service client as shown in 381 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 382 * try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) { 383 * SearchUrisRequest request = 384 * SearchUrisRequest.newBuilder() 385 * .setUri("uri116076") 386 * .addAllThreatTypes(new ArrayList<ThreatType>()) 387 * .build(); 388 * ApiFuture<SearchUrisResponse> future = 389 * webRiskServiceClient.searchUrisCallable().futureCall(request); 390 * // Do something. 391 * SearchUrisResponse response = future.get(); 392 * } 393 * }</pre> 394 */ searchUrisCallable()395 public final UnaryCallable<SearchUrisRequest, SearchUrisResponse> searchUrisCallable() { 396 return stub.searchUrisCallable(); 397 } 398 399 // AUTO-GENERATED DOCUMENTATION AND METHOD. 400 /** 401 * Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is 402 * looked up in a threatList and there is a match. The client side threatList only holds partial 403 * hashes so the client must query this method to determine if there is a full hash match of a 404 * threat. 405 * 406 * <p>Sample code: 407 * 408 * <pre>{@code 409 * // This snippet has been automatically generated and should be regarded as a code template only. 410 * // It will require modifications to work: 411 * // - It may require correct/in-range values for request initialization. 412 * // - It may require specifying regional endpoints when creating the service client as shown in 413 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 414 * try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) { 415 * ByteString hashPrefix = ByteString.EMPTY; 416 * List<ThreatType> threatTypes = new ArrayList<>(); 417 * SearchHashesResponse response = webRiskServiceClient.searchHashes(hashPrefix, threatTypes); 418 * } 419 * }</pre> 420 * 421 * @param hashPrefix A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 422 * hash. For JSON requests, this field is base64-encoded. Note that if this parameter is 423 * provided by a URI, it must be encoded using the web safe base64 variant (RFC 4648). 424 * @param threatTypes Required. The ThreatLists to search in. Multiple ThreatLists may be 425 * specified. 426 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 427 */ searchHashes( ByteString hashPrefix, List<ThreatType> threatTypes)428 public final SearchHashesResponse searchHashes( 429 ByteString hashPrefix, List<ThreatType> threatTypes) { 430 SearchHashesRequest request = 431 SearchHashesRequest.newBuilder() 432 .setHashPrefix(hashPrefix) 433 .addAllThreatTypes(threatTypes) 434 .build(); 435 return searchHashes(request); 436 } 437 438 // AUTO-GENERATED DOCUMENTATION AND METHOD. 439 /** 440 * Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is 441 * looked up in a threatList and there is a match. The client side threatList only holds partial 442 * hashes so the client must query this method to determine if there is a full hash match of a 443 * threat. 444 * 445 * <p>Sample code: 446 * 447 * <pre>{@code 448 * // This snippet has been automatically generated and should be regarded as a code template only. 449 * // It will require modifications to work: 450 * // - It may require correct/in-range values for request initialization. 451 * // - It may require specifying regional endpoints when creating the service client as shown in 452 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 453 * try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) { 454 * SearchHashesRequest request = 455 * SearchHashesRequest.newBuilder() 456 * .setHashPrefix(ByteString.EMPTY) 457 * .addAllThreatTypes(new ArrayList<ThreatType>()) 458 * .build(); 459 * SearchHashesResponse response = webRiskServiceClient.searchHashes(request); 460 * } 461 * }</pre> 462 * 463 * @param request The request object containing all of the parameters for the API call. 464 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 465 */ searchHashes(SearchHashesRequest request)466 public final SearchHashesResponse searchHashes(SearchHashesRequest request) { 467 return searchHashesCallable().call(request); 468 } 469 470 // AUTO-GENERATED DOCUMENTATION AND METHOD. 471 /** 472 * Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is 473 * looked up in a threatList and there is a match. The client side threatList only holds partial 474 * hashes so the client must query this method to determine if there is a full hash match of a 475 * threat. 476 * 477 * <p>Sample code: 478 * 479 * <pre>{@code 480 * // This snippet has been automatically generated and should be regarded as a code template only. 481 * // It will require modifications to work: 482 * // - It may require correct/in-range values for request initialization. 483 * // - It may require specifying regional endpoints when creating the service client as shown in 484 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 485 * try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) { 486 * SearchHashesRequest request = 487 * SearchHashesRequest.newBuilder() 488 * .setHashPrefix(ByteString.EMPTY) 489 * .addAllThreatTypes(new ArrayList<ThreatType>()) 490 * .build(); 491 * ApiFuture<SearchHashesResponse> future = 492 * webRiskServiceClient.searchHashesCallable().futureCall(request); 493 * // Do something. 494 * SearchHashesResponse response = future.get(); 495 * } 496 * }</pre> 497 */ searchHashesCallable()498 public final UnaryCallable<SearchHashesRequest, SearchHashesResponse> searchHashesCallable() { 499 return stub.searchHashesCallable(); 500 } 501 502 // AUTO-GENERATED DOCUMENTATION AND METHOD. 503 /** 504 * Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the 505 * result verifies the existence of malicious phishing content, the site will be added to the 506 * [Google's Social Engineering lists](https://support.google.com/webmasters/answer/6350487/) in 507 * order to protect users that could get exposed to this threat in the future. Only allowlisted 508 * projects can use this method during Early Access. Please reach out to Sales or your customer 509 * engineer to obtain access. 510 * 511 * <p>Sample code: 512 * 513 * <pre>{@code 514 * // This snippet has been automatically generated and should be regarded as a code template only. 515 * // It will require modifications to work: 516 * // - It may require correct/in-range values for request initialization. 517 * // - It may require specifying regional endpoints when creating the service client as shown in 518 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 519 * try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) { 520 * ProjectName parent = ProjectName.of("[PROJECT]"); 521 * Submission submission = Submission.newBuilder().build(); 522 * Submission response = webRiskServiceClient.createSubmission(parent, submission); 523 * } 524 * }</pre> 525 * 526 * @param parent Required. The name of the project that is making the submission. This string is 527 * in the format "projects/{project_number}". 528 * @param submission Required. The submission that contains the content of the phishing report. 529 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 530 */ createSubmission(ProjectName parent, Submission submission)531 public final Submission createSubmission(ProjectName parent, Submission submission) { 532 CreateSubmissionRequest request = 533 CreateSubmissionRequest.newBuilder() 534 .setParent(parent == null ? null : parent.toString()) 535 .setSubmission(submission) 536 .build(); 537 return createSubmission(request); 538 } 539 540 // AUTO-GENERATED DOCUMENTATION AND METHOD. 541 /** 542 * Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the 543 * result verifies the existence of malicious phishing content, the site will be added to the 544 * [Google's Social Engineering lists](https://support.google.com/webmasters/answer/6350487/) in 545 * order to protect users that could get exposed to this threat in the future. Only allowlisted 546 * projects can use this method during Early Access. Please reach out to Sales or your customer 547 * engineer to obtain access. 548 * 549 * <p>Sample code: 550 * 551 * <pre>{@code 552 * // This snippet has been automatically generated and should be regarded as a code template only. 553 * // It will require modifications to work: 554 * // - It may require correct/in-range values for request initialization. 555 * // - It may require specifying regional endpoints when creating the service client as shown in 556 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 557 * try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) { 558 * String parent = ProjectName.of("[PROJECT]").toString(); 559 * Submission submission = Submission.newBuilder().build(); 560 * Submission response = webRiskServiceClient.createSubmission(parent, submission); 561 * } 562 * }</pre> 563 * 564 * @param parent Required. The name of the project that is making the submission. This string is 565 * in the format "projects/{project_number}". 566 * @param submission Required. The submission that contains the content of the phishing report. 567 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 568 */ createSubmission(String parent, Submission submission)569 public final Submission createSubmission(String parent, Submission submission) { 570 CreateSubmissionRequest request = 571 CreateSubmissionRequest.newBuilder().setParent(parent).setSubmission(submission).build(); 572 return createSubmission(request); 573 } 574 575 // AUTO-GENERATED DOCUMENTATION AND METHOD. 576 /** 577 * Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the 578 * result verifies the existence of malicious phishing content, the site will be added to the 579 * [Google's Social Engineering lists](https://support.google.com/webmasters/answer/6350487/) in 580 * order to protect users that could get exposed to this threat in the future. Only allowlisted 581 * projects can use this method during Early Access. Please reach out to Sales or your customer 582 * engineer to obtain access. 583 * 584 * <p>Sample code: 585 * 586 * <pre>{@code 587 * // This snippet has been automatically generated and should be regarded as a code template only. 588 * // It will require modifications to work: 589 * // - It may require correct/in-range values for request initialization. 590 * // - It may require specifying regional endpoints when creating the service client as shown in 591 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 592 * try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) { 593 * CreateSubmissionRequest request = 594 * CreateSubmissionRequest.newBuilder() 595 * .setParent(ProjectName.of("[PROJECT]").toString()) 596 * .setSubmission(Submission.newBuilder().build()) 597 * .build(); 598 * Submission response = webRiskServiceClient.createSubmission(request); 599 * } 600 * }</pre> 601 * 602 * @param request The request object containing all of the parameters for the API call. 603 * @throws com.google.api.gax.rpc.ApiException if the remote call fails 604 */ createSubmission(CreateSubmissionRequest request)605 public final Submission createSubmission(CreateSubmissionRequest request) { 606 return createSubmissionCallable().call(request); 607 } 608 609 // AUTO-GENERATED DOCUMENTATION AND METHOD. 610 /** 611 * Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the 612 * result verifies the existence of malicious phishing content, the site will be added to the 613 * [Google's Social Engineering lists](https://support.google.com/webmasters/answer/6350487/) in 614 * order to protect users that could get exposed to this threat in the future. Only allowlisted 615 * projects can use this method during Early Access. Please reach out to Sales or your customer 616 * engineer to obtain access. 617 * 618 * <p>Sample code: 619 * 620 * <pre>{@code 621 * // This snippet has been automatically generated and should be regarded as a code template only. 622 * // It will require modifications to work: 623 * // - It may require correct/in-range values for request initialization. 624 * // - It may require specifying regional endpoints when creating the service client as shown in 625 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 626 * try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) { 627 * CreateSubmissionRequest request = 628 * CreateSubmissionRequest.newBuilder() 629 * .setParent(ProjectName.of("[PROJECT]").toString()) 630 * .setSubmission(Submission.newBuilder().build()) 631 * .build(); 632 * ApiFuture<Submission> future = 633 * webRiskServiceClient.createSubmissionCallable().futureCall(request); 634 * // Do something. 635 * Submission response = future.get(); 636 * } 637 * }</pre> 638 */ createSubmissionCallable()639 public final UnaryCallable<CreateSubmissionRequest, Submission> createSubmissionCallable() { 640 return stub.createSubmissionCallable(); 641 } 642 643 @Override close()644 public final void close() { 645 stub.close(); 646 } 647 648 @Override shutdown()649 public void shutdown() { 650 stub.shutdown(); 651 } 652 653 @Override isShutdown()654 public boolean isShutdown() { 655 return stub.isShutdown(); 656 } 657 658 @Override isTerminated()659 public boolean isTerminated() { 660 return stub.isTerminated(); 661 } 662 663 @Override shutdownNow()664 public void shutdownNow() { 665 stub.shutdownNow(); 666 } 667 668 @Override awaitTermination(long duration, TimeUnit unit)669 public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { 670 return stub.awaitTermination(duration, unit); 671 } 672 } 673