diff --git a/README.md b/README.md index f54893af..41976d31 100644 --- a/README.md +++ b/README.md @@ -59,13 +59,13 @@ implementation 'com.google.cloud:google-cloud-phishingprotection' If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-phishingprotection:0.33.0' +implementation 'com.google.cloud:google-cloud-phishingprotection:0.33.1' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-phishingprotection" % "0.33.0" +libraryDependencies += "com.google.cloud" % "google-cloud-phishingprotection" % "0.33.1" ``` ## Authentication diff --git a/google-cloud-phishingprotection/pom.xml b/google-cloud-phishingprotection/pom.xml index 3432fe8a..104b8350 100644 --- a/google-cloud-phishingprotection/pom.xml +++ b/google-cloud-phishingprotection/pom.xml @@ -58,6 +58,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -76,12 +80,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/PhishingProtectionServiceV1Beta1Client.java b/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/PhishingProtectionServiceV1Beta1Client.java index 2d8adf35..e8559f92 100644 --- a/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/PhishingProtectionServiceV1Beta1Client.java +++ b/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/PhishingProtectionServiceV1Beta1Client.java @@ -98,6 +98,22 @@ * PhishingProtectionServiceV1Beta1Client.create(phishingProtectionServiceV1Beta1Settings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * PhishingProtectionServiceV1Beta1Settings phishingProtectionServiceV1Beta1Settings =
+ *     PhishingProtectionServiceV1Beta1Settings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             PhishingProtectionServiceV1Beta1Settings.defaultHttpJsonTransportProviderBuilder()
+ *                 .build())
+ *         .build();
+ * PhishingProtectionServiceV1Beta1Client phishingProtectionServiceV1Beta1Client =
+ *     PhishingProtectionServiceV1Beta1Client.create(phishingProtectionServiceV1Beta1Settings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/PhishingProtectionServiceV1Beta1Settings.java b/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/PhishingProtectionServiceV1Beta1Settings.java index 0a93585a..e505fe3b 100644 --- a/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/PhishingProtectionServiceV1Beta1Settings.java +++ b/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/PhishingProtectionServiceV1Beta1Settings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -106,11 +107,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return PhishingProtectionServiceV1Beta1StubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return PhishingProtectionServiceV1Beta1StubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return PhishingProtectionServiceV1Beta1StubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return PhishingProtectionServiceV1Beta1StubSettings.defaultTransportChannelProvider(); } @@ -120,11 +128,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return PhishingProtectionServiceV1Beta1StubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -163,6 +177,11 @@ private static Builder createDefault() { return new Builder(PhishingProtectionServiceV1Beta1StubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(PhishingProtectionServiceV1Beta1StubSettings.newHttpJsonBuilder()); + } + public PhishingProtectionServiceV1Beta1StubSettings.Builder getStubSettingsBuilder() { return ((PhishingProtectionServiceV1Beta1StubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/stub/HttpJsonPhishingProtectionServiceV1Beta1CallableFactory.java b/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/stub/HttpJsonPhishingProtectionServiceV1Beta1CallableFactory.java new file mode 100644 index 00000000..3a1546df --- /dev/null +++ b/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/stub/HttpJsonPhishingProtectionServiceV1Beta1CallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.phishingprotection.v1beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the PhishingProtectionServiceV1Beta1 service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonPhishingProtectionServiceV1Beta1CallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/stub/HttpJsonPhishingProtectionServiceV1Beta1Stub.java b/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/stub/HttpJsonPhishingProtectionServiceV1Beta1Stub.java new file mode 100644 index 00000000..1bf0c783 --- /dev/null +++ b/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/stub/HttpJsonPhishingProtectionServiceV1Beta1Stub.java @@ -0,0 +1,201 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.phishingprotection.v1beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.phishingprotection.v1beta1.ReportPhishingRequest; +import com.google.phishingprotection.v1beta1.ReportPhishingResponse; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the PhishingProtectionServiceV1Beta1 service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonPhishingProtectionServiceV1Beta1Stub + extends PhishingProtectionServiceV1Beta1Stub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + reportPhishingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1/ReportPhishing") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*}/phishing:report", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ReportPhishingResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable reportPhishingCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonPhishingProtectionServiceV1Beta1Stub create( + PhishingProtectionServiceV1Beta1StubSettings settings) throws IOException { + return new HttpJsonPhishingProtectionServiceV1Beta1Stub( + settings, ClientContext.create(settings)); + } + + public static final HttpJsonPhishingProtectionServiceV1Beta1Stub create( + ClientContext clientContext) throws IOException { + return new HttpJsonPhishingProtectionServiceV1Beta1Stub( + PhishingProtectionServiceV1Beta1StubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonPhishingProtectionServiceV1Beta1Stub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonPhishingProtectionServiceV1Beta1Stub( + PhishingProtectionServiceV1Beta1StubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonPhishingProtectionServiceV1Beta1Stub, using the given + * settings. This is protected so that it is easy to make a subclass, but otherwise, the static + * factory methods should be preferred. + */ + protected HttpJsonPhishingProtectionServiceV1Beta1Stub( + PhishingProtectionServiceV1Beta1StubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonPhishingProtectionServiceV1Beta1CallableFactory()); + } + + /** + * Constructs an instance of HttpJsonPhishingProtectionServiceV1Beta1Stub, using the given + * settings. This is protected so that it is easy to make a subclass, but otherwise, the static + * factory methods should be preferred. + */ + protected HttpJsonPhishingProtectionServiceV1Beta1Stub( + PhishingProtectionServiceV1Beta1StubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + reportPhishingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(reportPhishingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.reportPhishingCallable = + callableFactory.createUnaryCallable( + reportPhishingTransportSettings, settings.reportPhishingSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(reportPhishingMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable reportPhishingCallable() { + return reportPhishingCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/stub/PhishingProtectionServiceV1Beta1StubSettings.java b/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/stub/PhishingProtectionServiceV1Beta1StubSettings.java index f17767c5..36dcdece 100644 --- a/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/stub/PhishingProtectionServiceV1Beta1StubSettings.java +++ b/google-cloud-phishingprotection/src/main/java/com/google/cloud/phishingprotection/v1beta1/stub/PhishingProtectionServiceV1Beta1StubSettings.java @@ -24,6 +24,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -101,6 +104,11 @@ public PhishingProtectionServiceV1Beta1Stub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcPhishingProtectionServiceV1Beta1Stub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonPhishingProtectionServiceV1Beta1Stub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -133,18 +141,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", @@ -153,11 +168,31 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", + GaxProperties.getLibraryVersion(PhishingProtectionServiceV1Beta1StubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return PhishingProtectionServiceV1Beta1StubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -244,6 +279,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .reportPhishingSettings() diff --git a/google-cloud-phishingprotection/src/test/java/com/google/cloud/phishingprotection/v1beta1/PhishingProtectionServiceV1Beta1ClientHttpJsonTest.java b/google-cloud-phishingprotection/src/test/java/com/google/cloud/phishingprotection/v1beta1/PhishingProtectionServiceV1Beta1ClientHttpJsonTest.java new file mode 100644 index 00000000..1452ba49 --- /dev/null +++ b/google-cloud-phishingprotection/src/test/java/com/google/cloud/phishingprotection/v1beta1/PhishingProtectionServiceV1Beta1ClientHttpJsonTest.java @@ -0,0 +1,161 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.phishingprotection.v1beta1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.phishingprotection.v1beta1.stub.HttpJsonPhishingProtectionServiceV1Beta1Stub; +import com.google.phishingprotection.v1beta1.ProjectName; +import com.google.phishingprotection.v1beta1.ReportPhishingResponse; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class PhishingProtectionServiceV1Beta1ClientHttpJsonTest { + private static MockHttpService mockService; + private static PhishingProtectionServiceV1Beta1Client client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonPhishingProtectionServiceV1Beta1Stub.getMethodDescriptors(), + PhishingProtectionServiceV1Beta1Settings.getDefaultEndpoint()); + PhishingProtectionServiceV1Beta1Settings settings = + PhishingProtectionServiceV1Beta1Settings.newHttpJsonBuilder() + .setTransportChannelProvider( + PhishingProtectionServiceV1Beta1Settings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = PhishingProtectionServiceV1Beta1Client.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void reportPhishingTest() throws Exception { + ReportPhishingResponse expectedResponse = ReportPhishingResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + String uri = "uri116076"; + + ReportPhishingResponse actualResponse = client.reportPhishing(parent, uri); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void reportPhishingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + String uri = "uri116076"; + client.reportPhishing(parent, uri); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void reportPhishingTest2() throws Exception { + ReportPhishingResponse expectedResponse = ReportPhishingResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + String uri = "uri116076"; + + ReportPhishingResponse actualResponse = client.reportPhishing(parent, uri); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void reportPhishingExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + String uri = "uri116076"; + client.reportPhishing(parent, uri); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..fbc05917 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.phishingprotection.v1beta1.samples; + +// [START +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1client_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1Client; +import com.google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1Settings; +import com.google.cloud.phishingprotection.v1beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PhishingProtectionServiceV1Beta1Settings phishingProtectionServiceV1Beta1Settings = + PhishingProtectionServiceV1Beta1Settings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + PhishingProtectionServiceV1Beta1Client phishingProtectionServiceV1Beta1Client = + PhishingProtectionServiceV1Beta1Client.create(phishingProtectionServiceV1Beta1Settings); + } +} +// [END +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1client_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..ef9b86c5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.phishingprotection.v1beta1.samples; + +// [START +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1client_create_setcredentialsprovider1_sync] +import com.google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1Client; +import com.google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1Settings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PhishingProtectionServiceV1Beta1Settings phishingProtectionServiceV1Beta1Settings = + PhishingProtectionServiceV1Beta1Settings.newBuilder() + .setTransportChannelProvider( + PhishingProtectionServiceV1Beta1Settings.defaultHttpJsonTransportProviderBuilder() + .build()) + .build(); + PhishingProtectionServiceV1Beta1Client phishingProtectionServiceV1Beta1Client = + PhishingProtectionServiceV1Beta1Client.create(phishingProtectionServiceV1Beta1Settings); + } +} +// [END +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1client_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..3c8fd580 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/create/SyncCreateSetEndpoint.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.phishingprotection.v1beta1.samples; + +// [START +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1client_create_setendpoint_sync] +import com.google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1Client; +import com.google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1Settings; +import com.google.cloud.phishingprotection.v1beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PhishingProtectionServiceV1Beta1Settings phishingProtectionServiceV1Beta1Settings = + PhishingProtectionServiceV1Beta1Settings.newBuilder().setEndpoint(myEndpoint).build(); + PhishingProtectionServiceV1Beta1Client phishingProtectionServiceV1Beta1Client = + PhishingProtectionServiceV1Beta1Client.create(phishingProtectionServiceV1Beta1Settings); + } +} +// [END +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1client_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/reportphishing/AsyncReportPhishing.java b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/reportphishing/AsyncReportPhishing.java new file mode 100644 index 00000000..9fe76545 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/reportphishing/AsyncReportPhishing.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.phishingprotection.v1beta1.samples; + +// [START +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1client_reportphishing_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1Client; +import com.google.phishingprotection.v1beta1.ProjectName; +import com.google.phishingprotection.v1beta1.ReportPhishingRequest; +import com.google.phishingprotection.v1beta1.ReportPhishingResponse; + +public class AsyncReportPhishing { + + public static void main(String[] args) throws Exception { + asyncReportPhishing(); + } + + public static void asyncReportPhishing() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PhishingProtectionServiceV1Beta1Client phishingProtectionServiceV1Beta1Client = + PhishingProtectionServiceV1Beta1Client.create()) { + ReportPhishingRequest request = + ReportPhishingRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setUri("uri116076") + .build(); + ApiFuture future = + phishingProtectionServiceV1Beta1Client.reportPhishingCallable().futureCall(request); + // Do something. + ReportPhishingResponse response = future.get(); + } + } +} +// [END +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1client_reportphishing_async] diff --git a/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/reportphishing/SyncReportPhishing.java b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/reportphishing/SyncReportPhishing.java new file mode 100644 index 00000000..70d70369 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/reportphishing/SyncReportPhishing.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.phishingprotection.v1beta1.samples; + +// [START +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1client_reportphishing_sync] +import com.google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1Client; +import com.google.phishingprotection.v1beta1.ProjectName; +import com.google.phishingprotection.v1beta1.ReportPhishingRequest; +import com.google.phishingprotection.v1beta1.ReportPhishingResponse; + +public class SyncReportPhishing { + + public static void main(String[] args) throws Exception { + syncReportPhishing(); + } + + public static void syncReportPhishing() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PhishingProtectionServiceV1Beta1Client phishingProtectionServiceV1Beta1Client = + PhishingProtectionServiceV1Beta1Client.create()) { + ReportPhishingRequest request = + ReportPhishingRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setUri("uri116076") + .build(); + ReportPhishingResponse response = + phishingProtectionServiceV1Beta1Client.reportPhishing(request); + } + } +} +// [END +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1client_reportphishing_sync] diff --git a/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/reportphishing/SyncReportPhishingProjectnameString.java b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/reportphishing/SyncReportPhishingProjectnameString.java new file mode 100644 index 00000000..ef363ca1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/reportphishing/SyncReportPhishingProjectnameString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.phishingprotection.v1beta1.samples; + +// [START +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1client_reportphishing_projectnamestring_sync] +import com.google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1Client; +import com.google.phishingprotection.v1beta1.ProjectName; +import com.google.phishingprotection.v1beta1.ReportPhishingResponse; + +public class SyncReportPhishingProjectnameString { + + public static void main(String[] args) throws Exception { + syncReportPhishingProjectnameString(); + } + + public static void syncReportPhishingProjectnameString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PhishingProtectionServiceV1Beta1Client phishingProtectionServiceV1Beta1Client = + PhishingProtectionServiceV1Beta1Client.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + String uri = "uri116076"; + ReportPhishingResponse response = + phishingProtectionServiceV1Beta1Client.reportPhishing(parent, uri); + } + } +} +// [END +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1client_reportphishing_projectnamestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/reportphishing/SyncReportPhishingStringString.java b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/reportphishing/SyncReportPhishingStringString.java new file mode 100644 index 00000000..f958ce81 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1client/reportphishing/SyncReportPhishingStringString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.phishingprotection.v1beta1.samples; + +// [START +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1client_reportphishing_stringstring_sync] +import com.google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1Client; +import com.google.phishingprotection.v1beta1.ProjectName; +import com.google.phishingprotection.v1beta1.ReportPhishingResponse; + +public class SyncReportPhishingStringString { + + public static void main(String[] args) throws Exception { + syncReportPhishingStringString(); + } + + public static void syncReportPhishingStringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (PhishingProtectionServiceV1Beta1Client phishingProtectionServiceV1Beta1Client = + PhishingProtectionServiceV1Beta1Client.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + String uri = "uri116076"; + ReportPhishingResponse response = + phishingProtectionServiceV1Beta1Client.reportPhishing(parent, uri); + } + } +} +// [END +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1client_reportphishing_stringstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1settings/reportphishing/SyncReportPhishing.java b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1settings/reportphishing/SyncReportPhishing.java new file mode 100644 index 00000000..eedd3f96 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/phishingprotectionservicev1beta1settings/reportphishing/SyncReportPhishing.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.phishingprotection.v1beta1.samples; + +// [START +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1settings_reportphishing_sync] +import com.google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1Settings; +import java.time.Duration; + +public class SyncReportPhishing { + + public static void main(String[] args) throws Exception { + syncReportPhishing(); + } + + public static void syncReportPhishing() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PhishingProtectionServiceV1Beta1Settings.Builder + phishingProtectionServiceV1Beta1SettingsBuilder = + PhishingProtectionServiceV1Beta1Settings.newBuilder(); + phishingProtectionServiceV1Beta1SettingsBuilder + .reportPhishingSettings() + .setRetrySettings( + phishingProtectionServiceV1Beta1SettingsBuilder + .reportPhishingSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + PhishingProtectionServiceV1Beta1Settings phishingProtectionServiceV1Beta1Settings = + phishingProtectionServiceV1Beta1SettingsBuilder.build(); + } +} +// [END +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1settings_reportphishing_sync] diff --git a/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/stub/phishingprotectionservicev1beta1stubsettings/reportphishing/SyncReportPhishing.java b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/stub/phishingprotectionservicev1beta1stubsettings/reportphishing/SyncReportPhishing.java new file mode 100644 index 00000000..b27d291c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/phishingprotection/v1beta1/stub/phishingprotectionservicev1beta1stubsettings/reportphishing/SyncReportPhishing.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.phishingprotection.v1beta1.stub.samples; + +// [START +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1stubsettings_reportphishing_sync] +import com.google.cloud.phishingprotection.v1beta1.stub.PhishingProtectionServiceV1Beta1StubSettings; +import java.time.Duration; + +public class SyncReportPhishing { + + public static void main(String[] args) throws Exception { + syncReportPhishing(); + } + + public static void syncReportPhishing() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + PhishingProtectionServiceV1Beta1StubSettings.Builder + phishingProtectionServiceV1Beta1SettingsBuilder = + PhishingProtectionServiceV1Beta1StubSettings.newBuilder(); + phishingProtectionServiceV1Beta1SettingsBuilder + .reportPhishingSettings() + .setRetrySettings( + phishingProtectionServiceV1Beta1SettingsBuilder + .reportPhishingSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + PhishingProtectionServiceV1Beta1StubSettings phishingProtectionServiceV1Beta1Settings = + phishingProtectionServiceV1Beta1SettingsBuilder.build(); + } +} +// [END +// phishingprotection_v1beta1_generated_phishingprotectionservicev1beta1stubsettings_reportphishing_sync]