Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

docs: generate sample code in the Java microgenerator #344

Merged
merged 1 commit into from Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -45,6 +45,17 @@
* <p>This class provides the ability to make remote calls to the backing service through method
* calls that map to API methods. Sample code to get started:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* ThreatType threatType = ThreatType.forNumber(0);
* ByteString versionToken = ByteString.EMPTY;
* ComputeThreatListDiffRequest.Constraints constraints =
* ComputeThreatListDiffRequest.Constraints.newBuilder().build();
* ComputeThreatListDiffResponse response =
* webRiskServiceClient.computeThreatListDiff(threatType, versionToken, constraints);
* }
* }</pre>
*
* <p>Note: close() needs to be called on the WebRiskServiceClient object to clean up resources such
* as threads. In the example above, try-with-resources is used, which automatically calls close().
*
Expand Down Expand Up @@ -152,6 +163,19 @@ public WebRiskServiceStub getStub() {
* ThreatList at a time. To update multiple ThreatList databases, this method needs to be called
* once for each list.
*
* <p>Sample code:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* ThreatType threatType = ThreatType.forNumber(0);
* ByteString versionToken = ByteString.EMPTY;
* ComputeThreatListDiffRequest.Constraints constraints =
* ComputeThreatListDiffRequest.Constraints.newBuilder().build();
* ComputeThreatListDiffResponse response =
* webRiskServiceClient.computeThreatListDiff(threatType, versionToken, constraints);
* }
* }</pre>
*
* @param threatType Required. The threat list to update. Only a single ThreatType should be
* specified.
* @param versionToken The current version token of the client for the requested list (the client
Expand Down Expand Up @@ -182,6 +206,19 @@ public final ComputeThreatListDiffResponse computeThreatListDiff(
* ThreatList at a time. To update multiple ThreatList databases, this method needs to be called
* once for each list.
*
* <p>Sample code:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* ComputeThreatListDiffRequest request =
* ComputeThreatListDiffRequest.newBuilder()
* .setVersionToken(ByteString.EMPTY)
* .setConstraints(ComputeThreatListDiffRequest.Constraints.newBuilder().build())
* .build();
* ComputeThreatListDiffResponse response = webRiskServiceClient.computeThreatListDiff(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand All @@ -199,6 +236,20 @@ public final ComputeThreatListDiffResponse computeThreatListDiff(
* once for each list.
*
* <p>Sample code:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* ComputeThreatListDiffRequest request =
* ComputeThreatListDiffRequest.newBuilder()
* .setVersionToken(ByteString.EMPTY)
* .setConstraints(ComputeThreatListDiffRequest.Constraints.newBuilder().build())
* .build();
* ApiFuture<ComputeThreatListDiffResponse> future =
* webRiskServiceClient.computeThreatListDiffCallable().futureCall(request);
* // Do something.
* ComputeThreatListDiffResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<ComputeThreatListDiffRequest, ComputeThreatListDiffResponse>
computeThreatListDiffCallable() {
Expand All @@ -212,6 +263,16 @@ public final ComputeThreatListDiffResponse computeThreatListDiff(
* found to match. If the URI is not found on any of the requested ThreatList an empty response
* will be returned.
*
* <p>Sample code:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* String uri = "uri116076";
* List<ThreatType> threatTypes = new ArrayList<>();
* SearchUrisResponse response = webRiskServiceClient.searchUris(uri, threatTypes);
* }
* }</pre>
*
* @param uri Required. The URI to be checked for matches.
* @param threatTypes Required. The ThreatLists to search in. Multiple ThreatLists may be
* specified.
Expand All @@ -230,6 +291,19 @@ public final SearchUrisResponse searchUris(String uri, List<ThreatType> threatTy
* found to match. If the URI is not found on any of the requested ThreatList an empty response
* will be returned.
*
* <p>Sample code:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* SearchUrisRequest request =
* SearchUrisRequest.newBuilder()
* .setUri("uri116076")
* .addAllThreatTypes(new ArrayList<ThreatType>())
* .build();
* SearchUrisResponse response = webRiskServiceClient.searchUris(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand All @@ -245,6 +319,20 @@ public final SearchUrisResponse searchUris(SearchUrisRequest request) {
* will be returned.
*
* <p>Sample code:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* SearchUrisRequest request =
* SearchUrisRequest.newBuilder()
* .setUri("uri116076")
* .addAllThreatTypes(new ArrayList<ThreatType>())
* .build();
* ApiFuture<SearchUrisResponse> future =
* webRiskServiceClient.searchUrisCallable().futureCall(request);
* // Do something.
* SearchUrisResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<SearchUrisRequest, SearchUrisResponse> searchUrisCallable() {
return stub.searchUrisCallable();
Expand All @@ -257,6 +345,16 @@ public final UnaryCallable<SearchUrisRequest, SearchUrisResponse> searchUrisCall
* hashes so the client must query this method to determine if there is a full hash match of a
* threat.
*
* <p>Sample code:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* ByteString hashPrefix = ByteString.EMPTY;
* List<ThreatType> threatTypes = new ArrayList<>();
* SearchHashesResponse response = webRiskServiceClient.searchHashes(hashPrefix, threatTypes);
* }
* }</pre>
*
* @param hashPrefix A hash prefix, consisting of the most significant 4-32 bytes of a SHA256
* hash. For JSON requests, this field is base64-encoded.
* @param threatTypes Required. The ThreatLists to search in. Multiple ThreatLists may be
Expand All @@ -280,6 +378,19 @@ public final SearchHashesResponse searchHashes(
* hashes so the client must query this method to determine if there is a full hash match of a
* threat.
*
* <p>Sample code:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* SearchHashesRequest request =
* SearchHashesRequest.newBuilder()
* .setHashPrefix(ByteString.EMPTY)
* .addAllThreatTypes(new ArrayList<ThreatType>())
* .build();
* SearchHashesResponse response = webRiskServiceClient.searchHashes(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand All @@ -295,6 +406,20 @@ public final SearchHashesResponse searchHashes(SearchHashesRequest request) {
* threat.
*
* <p>Sample code:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* SearchHashesRequest request =
* SearchHashesRequest.newBuilder()
* .setHashPrefix(ByteString.EMPTY)
* .addAllThreatTypes(new ArrayList<ThreatType>())
* .build();
* ApiFuture<SearchHashesResponse> future =
* webRiskServiceClient.searchHashesCallable().futureCall(request);
* // Do something.
* SearchHashesResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<SearchHashesRequest, SearchHashesResponse> searchHashesCallable() {
return stub.searchHashesCallable();
Expand All @@ -308,6 +433,16 @@ public final UnaryCallable<SearchHashesRequest, SearchHashesResponse> searchHash
* order to protect users that could get exposed to this threat in the future. Only projects with
* CREATE_SUBMISSION_USERS visibility can use this method.
*
* <p>Sample code:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* ProjectName parent = ProjectName.of("[PROJECT]");
* Submission submission = Submission.newBuilder().build();
* Submission response = webRiskServiceClient.createSubmission(parent, submission);
* }
* }</pre>
*
* @param parent Required. The name of the project that is making the submission. This string is
* in the format "projects/{project_number}".
* @param submission Required. The submission that contains the content of the phishing report.
Expand All @@ -330,6 +465,16 @@ public final Submission createSubmission(ProjectName parent, Submission submissi
* order to protect users that could get exposed to this threat in the future. Only projects with
* CREATE_SUBMISSION_USERS visibility can use this method.
*
* <p>Sample code:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* String parent = ProjectName.of("[PROJECT]").toString();
* Submission submission = Submission.newBuilder().build();
* Submission response = webRiskServiceClient.createSubmission(parent, submission);
* }
* }</pre>
*
* @param parent Required. The name of the project that is making the submission. This string is
* in the format "projects/{project_number}".
* @param submission Required. The submission that contains the content of the phishing report.
Expand All @@ -349,6 +494,19 @@ public final Submission createSubmission(String parent, Submission submission) {
* order to protect users that could get exposed to this threat in the future. Only projects with
* CREATE_SUBMISSION_USERS visibility can use this method.
*
* <p>Sample code:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* CreateSubmissionRequest request =
* CreateSubmissionRequest.newBuilder()
* .setParent(ProjectName.of("[PROJECT]").toString())
* .setSubmission(Submission.newBuilder().build())
* .build();
* Submission response = webRiskServiceClient.createSubmission(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
Expand All @@ -365,6 +523,20 @@ public final Submission createSubmission(CreateSubmissionRequest request) {
* CREATE_SUBMISSION_USERS visibility can use this method.
*
* <p>Sample code:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* CreateSubmissionRequest request =
* CreateSubmissionRequest.newBuilder()
* .setParent(ProjectName.of("[PROJECT]").toString())
* .setSubmission(Submission.newBuilder().build())
* .build();
* ApiFuture<Submission> future =
* webRiskServiceClient.createSubmissionCallable().futureCall(request);
* // Do something.
* Submission response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<CreateSubmissionRequest, Submission> createSubmissionCallable() {
return stub.createSubmissionCallable();
Expand Down
Expand Up @@ -23,6 +23,17 @@
* website and in client applications.
*
* <p>Sample for WebRiskServiceClient:
*
* <pre>{@code
* try (WebRiskServiceClient webRiskServiceClient = WebRiskServiceClient.create()) {
* ThreatType threatType = ThreatType.forNumber(0);
* ByteString versionToken = ByteString.EMPTY;
* ComputeThreatListDiffRequest.Constraints constraints =
* ComputeThreatListDiffRequest.Constraints.newBuilder().build();
* ComputeThreatListDiffResponse response =
* webRiskServiceClient.computeThreatListDiff(threatType, versionToken, constraints);
* }
* }</pre>
*/
@Generated("by gapic-generator-java")
package com.google.cloud.webrisk.v1;
Expand Down