diff --git a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClient.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClient.java
index fdce037a1a31..9f79e5aa3b55 100644
--- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClient.java
+++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClient.java
@@ -18,7 +18,9 @@
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
+import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.httpjson.longrunning.OperationsClient;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
@@ -30,7 +32,6 @@
import com.google.cloud.networkmanagement.v1.stub.ReachabilityServiceStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.longrunning.Operation;
-import com.google.longrunning.OperationsClient;
import com.google.protobuf.Empty;
import com.google.protobuf.FieldMask;
import java.io.IOException;
@@ -112,13 +113,29 @@
* ReachabilityServiceClient.create(reachabilityServiceSettings);
* }
*
+ * 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.
+ * ReachabilityServiceSettings reachabilityServiceSettings =
+ * ReachabilityServiceSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * ReachabilityServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * ReachabilityServiceClient reachabilityServiceClient =
+ * ReachabilityServiceClient.create(reachabilityServiceSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class ReachabilityServiceClient implements BackgroundResource {
private final ReachabilityServiceSettings settings;
private final ReachabilityServiceStub stub;
- private final OperationsClient operationsClient;
+ private final OperationsClient httpJsonOperationsClient;
+ private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of ReachabilityServiceClient with default settings. */
public static final ReachabilityServiceClient create() throws IOException {
@@ -150,13 +167,17 @@ public static final ReachabilityServiceClient create(ReachabilityServiceStub stu
protected ReachabilityServiceClient(ReachabilityServiceSettings settings) throws IOException {
this.settings = settings;
this.stub = ((ReachabilityServiceStubSettings) settings.getStubSettings()).createStub();
- this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ this.operationsClient =
+ com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
+ this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
protected ReachabilityServiceClient(ReachabilityServiceStub stub) {
this.settings = null;
this.stub = stub;
- this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ this.operationsClient =
+ com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
+ this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
public final ReachabilityServiceSettings getSettings() {
@@ -171,10 +192,19 @@ public ReachabilityServiceStub getStub() {
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
- public final OperationsClient getOperationsClient() {
+ public final com.google.longrunning.OperationsClient getOperationsClient() {
return operationsClient;
}
+ /**
+ * Returns the OperationsClient that can be used to query the status of a long-running operation
+ * returned by another API method call.
+ */
+ @BetaApi
+ public final OperationsClient getHttpJsonOperationsClient() {
+ return httpJsonOperationsClient;
+ }
+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists all Connectivity Tests owned by a project.
diff --git a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceSettings.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceSettings.java
index 63618a249fa2..2690e58aac9c 100644
--- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceSettings.java
+++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceSettings.java
@@ -23,6 +23,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;
@@ -168,11 +169,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return ReachabilityServiceStubSettings.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 ReachabilityServiceStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return ReachabilityServiceStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return ReachabilityServiceStubSettings.defaultTransportChannelProvider();
}
@@ -182,11 +190,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return ReachabilityServiceStubSettings.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);
@@ -224,6 +238,11 @@ private static Builder createDefault() {
return new Builder(ReachabilityServiceStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(ReachabilityServiceStubSettings.newHttpJsonBuilder());
+ }
+
public ReachabilityServiceStubSettings.Builder getStubSettingsBuilder() {
return ((ReachabilityServiceStubSettings.Builder) getStubSettings());
}
diff --git a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/HttpJsonReachabilityServiceCallableFactory.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/HttpJsonReachabilityServiceCallableFactory.java
new file mode 100644
index 000000000000..b14cf9ab20bb
--- /dev/null
+++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/HttpJsonReachabilityServiceCallableFactory.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.networkmanagement.v1.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 ReachabilityService service API.
+ *
+ *
This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonReachabilityServiceCallableFactory
+ 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/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/HttpJsonReachabilityServiceStub.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/HttpJsonReachabilityServiceStub.java
new file mode 100644
index 000000000000..5fc103ece90b
--- /dev/null
+++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/HttpJsonReachabilityServiceStub.java
@@ -0,0 +1,592 @@
+/*
+ * 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.networkmanagement.v1.stub;
+
+import static com.google.cloud.networkmanagement.v1.ReachabilityServiceClient.ListConnectivityTestsPagedResponse;
+
+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.HttpJsonOperationSnapshot;
+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.httpjson.longrunning.stub.HttpJsonOperationsStub;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.networkmanagement.v1.ConnectivityTest;
+import com.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest;
+import com.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest;
+import com.google.cloud.networkmanagement.v1.GetConnectivityTestRequest;
+import com.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest;
+import com.google.cloud.networkmanagement.v1.ListConnectivityTestsResponse;
+import com.google.cloud.networkmanagement.v1.OperationMetadata;
+import com.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest;
+import com.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest;
+import com.google.longrunning.Operation;
+import com.google.protobuf.Empty;
+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 ReachabilityService service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonReachabilityServiceStub extends ReachabilityServiceStub {
+ private static final TypeRegistry typeRegistry =
+ TypeRegistry.newBuilder()
+ .add(Empty.getDescriptor())
+ .add(OperationMetadata.getDescriptor())
+ .add(ConnectivityTest.getDescriptor())
+ .build();
+
+ private static final ApiMethodDescriptor<
+ ListConnectivityTestsRequest, ListConnectivityTestsResponse>
+ listConnectivityTestsMethodDescriptor =
+ ApiMethodDescriptor
+ .newBuilder()
+ .setFullMethodName(
+ "google.cloud.networkmanagement.v1.ReachabilityService/ListConnectivityTests")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{parent=projects/*/locations/global}/connectivityTests",
+ 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();
+ serializer.putQueryParam(fields, "filter", request.getFilter());
+ serializer.putQueryParam(fields, "orderBy", request.getOrderBy());
+ serializer.putQueryParam(fields, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListConnectivityTestsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ getConnectivityTestMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.networkmanagement.v1.ReachabilityService/GetConnectivityTest")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/global/connectivityTests/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ConnectivityTest.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ createConnectivityTestMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.networkmanagement.v1.ReachabilityService/CreateConnectivityTest")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{parent=projects/*/locations/global}/connectivityTests",
+ 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();
+ serializer.putQueryParam(fields, "testId", request.getTestId());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("resource", request.getResource()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (CreateConnectivityTestRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ updateConnectivityTestMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.networkmanagement.v1.ReachabilityService/UpdateConnectivityTest")
+ .setHttpMethod("PATCH")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{resource.name=projects/*/locations/global/connectivityTests/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(
+ fields, "resource.name", request.getResource().getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "updateMask", request.getUpdateMask());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("resource", request.getResource()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (UpdateConnectivityTestRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ rerunConnectivityTestMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.networkmanagement.v1.ReachabilityService/RerunConnectivityTest")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/global/connectivityTests/*}:rerun",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearName().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (RerunConnectivityTestRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ deleteConnectivityTestMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.networkmanagement.v1.ReachabilityService/DeleteConnectivityTest")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=projects/*/locations/global/connectivityTests/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (DeleteConnectivityTestRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private final UnaryCallable
+ listConnectivityTestsCallable;
+ private final UnaryCallable
+ listConnectivityTestsPagedCallable;
+ private final UnaryCallable
+ getConnectivityTestCallable;
+ private final UnaryCallable
+ createConnectivityTestCallable;
+ private final OperationCallable<
+ CreateConnectivityTestRequest, ConnectivityTest, OperationMetadata>
+ createConnectivityTestOperationCallable;
+ private final UnaryCallable
+ updateConnectivityTestCallable;
+ private final OperationCallable<
+ UpdateConnectivityTestRequest, ConnectivityTest, OperationMetadata>
+ updateConnectivityTestOperationCallable;
+ private final UnaryCallable
+ rerunConnectivityTestCallable;
+ private final OperationCallable
+ rerunConnectivityTestOperationCallable;
+ private final UnaryCallable
+ deleteConnectivityTestCallable;
+ private final OperationCallable
+ deleteConnectivityTestOperationCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonOperationsStub httpJsonOperationsStub;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonReachabilityServiceStub create(
+ ReachabilityServiceStubSettings settings) throws IOException {
+ return new HttpJsonReachabilityServiceStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonReachabilityServiceStub create(ClientContext clientContext)
+ throws IOException {
+ return new HttpJsonReachabilityServiceStub(
+ ReachabilityServiceStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonReachabilityServiceStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonReachabilityServiceStub(
+ ReachabilityServiceStubSettings.newHttpJsonBuilder().build(),
+ clientContext,
+ callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonReachabilityServiceStub, 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 HttpJsonReachabilityServiceStub(
+ ReachabilityServiceStubSettings settings, ClientContext clientContext) throws IOException {
+ this(settings, clientContext, new HttpJsonReachabilityServiceCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonReachabilityServiceStub, 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 HttpJsonReachabilityServiceStub(
+ ReachabilityServiceStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.httpJsonOperationsStub =
+ HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
+
+ HttpJsonCallSettings
+ listConnectivityTestsTransportSettings =
+ HttpJsonCallSettings
+ .newBuilder()
+ .setMethodDescriptor(listConnectivityTestsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ getConnectivityTestTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getConnectivityTestMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ createConnectivityTestTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(createConnectivityTestMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ updateConnectivityTestTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(updateConnectivityTestMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ rerunConnectivityTestTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(rerunConnectivityTestMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ deleteConnectivityTestTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deleteConnectivityTestMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+
+ this.listConnectivityTestsCallable =
+ callableFactory.createUnaryCallable(
+ listConnectivityTestsTransportSettings,
+ settings.listConnectivityTestsSettings(),
+ clientContext);
+ this.listConnectivityTestsPagedCallable =
+ callableFactory.createPagedCallable(
+ listConnectivityTestsTransportSettings,
+ settings.listConnectivityTestsSettings(),
+ clientContext);
+ this.getConnectivityTestCallable =
+ callableFactory.createUnaryCallable(
+ getConnectivityTestTransportSettings,
+ settings.getConnectivityTestSettings(),
+ clientContext);
+ this.createConnectivityTestCallable =
+ callableFactory.createUnaryCallable(
+ createConnectivityTestTransportSettings,
+ settings.createConnectivityTestSettings(),
+ clientContext);
+ this.createConnectivityTestOperationCallable =
+ callableFactory.createOperationCallable(
+ createConnectivityTestTransportSettings,
+ settings.createConnectivityTestOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.updateConnectivityTestCallable =
+ callableFactory.createUnaryCallable(
+ updateConnectivityTestTransportSettings,
+ settings.updateConnectivityTestSettings(),
+ clientContext);
+ this.updateConnectivityTestOperationCallable =
+ callableFactory.createOperationCallable(
+ updateConnectivityTestTransportSettings,
+ settings.updateConnectivityTestOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.rerunConnectivityTestCallable =
+ callableFactory.createUnaryCallable(
+ rerunConnectivityTestTransportSettings,
+ settings.rerunConnectivityTestSettings(),
+ clientContext);
+ this.rerunConnectivityTestOperationCallable =
+ callableFactory.createOperationCallable(
+ rerunConnectivityTestTransportSettings,
+ settings.rerunConnectivityTestOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.deleteConnectivityTestCallable =
+ callableFactory.createUnaryCallable(
+ deleteConnectivityTestTransportSettings,
+ settings.deleteConnectivityTestSettings(),
+ clientContext);
+ this.deleteConnectivityTestOperationCallable =
+ callableFactory.createOperationCallable(
+ deleteConnectivityTestTransportSettings,
+ settings.deleteConnectivityTestOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(listConnectivityTestsMethodDescriptor);
+ methodDescriptors.add(getConnectivityTestMethodDescriptor);
+ methodDescriptors.add(createConnectivityTestMethodDescriptor);
+ methodDescriptors.add(updateConnectivityTestMethodDescriptor);
+ methodDescriptors.add(rerunConnectivityTestMethodDescriptor);
+ methodDescriptors.add(deleteConnectivityTestMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ public HttpJsonOperationsStub getHttpJsonOperationsStub() {
+ return httpJsonOperationsStub;
+ }
+
+ @Override
+ public UnaryCallable
+ listConnectivityTestsCallable() {
+ return listConnectivityTestsCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listConnectivityTestsPagedCallable() {
+ return listConnectivityTestsPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable getConnectivityTestCallable() {
+ return getConnectivityTestCallable;
+ }
+
+ @Override
+ public UnaryCallable createConnectivityTestCallable() {
+ return createConnectivityTestCallable;
+ }
+
+ @Override
+ public OperationCallable
+ createConnectivityTestOperationCallable() {
+ return createConnectivityTestOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable updateConnectivityTestCallable() {
+ return updateConnectivityTestCallable;
+ }
+
+ @Override
+ public OperationCallable
+ updateConnectivityTestOperationCallable() {
+ return updateConnectivityTestOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable rerunConnectivityTestCallable() {
+ return rerunConnectivityTestCallable;
+ }
+
+ @Override
+ public OperationCallable
+ rerunConnectivityTestOperationCallable() {
+ return rerunConnectivityTestOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteConnectivityTestCallable() {
+ return deleteConnectivityTestCallable;
+ }
+
+ @Override
+ public OperationCallable
+ deleteConnectivityTestOperationCallable() {
+ return deleteConnectivityTestOperationCallable;
+ }
+
+ @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/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStub.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStub.java
index 6ec5898ca64a..dd8f1ed70836 100644
--- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStub.java
+++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStub.java
@@ -45,7 +45,11 @@
public abstract class ReachabilityServiceStub implements BackgroundResource {
public OperationsStub getOperationsStub() {
- throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
+ return null;
+ }
+
+ public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() {
+ return null;
}
public UnaryCallable
diff --git a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStubSettings.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStubSettings.java
index 63f83c503e86..1e29ac7d7d31 100644
--- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStubSettings.java
+++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStubSettings.java
@@ -28,6 +28,9 @@
import com.google.api.gax.grpc.GrpcTransportChannel;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.api.gax.grpc.ProtoOperationTransformers;
+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.longrunning.OperationSnapshot;
import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
import com.google.api.gax.retrying.RetrySettings;
@@ -267,6 +270,11 @@ public ReachabilityServiceStub createStub() throws IOException {
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcReachabilityServiceStub.create(this);
}
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonReachabilityServiceStub.create(this);
+ }
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -299,18 +307,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", GaxProperties.getLibraryVersion(ReachabilityServiceStubSettings.class))
@@ -318,11 +333,30 @@ 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(ReachabilityServiceStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return ReachabilityServiceStubSettings.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);
@@ -481,6 +515,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
.listConnectivityTestsSettings()
diff --git a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceClient.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceClient.java
index 7015618994e4..c0ba33f9c830 100644
--- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceClient.java
+++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceClient.java
@@ -20,6 +20,7 @@
import com.google.api.core.ApiFutures;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.httpjson.longrunning.OperationsClient;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
@@ -31,7 +32,6 @@
import com.google.cloud.networkmanagement.v1beta1.stub.ReachabilityServiceStubSettings;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.longrunning.Operation;
-import com.google.longrunning.OperationsClient;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.List;
@@ -113,6 +113,21 @@
* ReachabilityServiceClient.create(reachabilityServiceSettings);
* }
*
+ * 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.
+ * ReachabilityServiceSettings reachabilityServiceSettings =
+ * ReachabilityServiceSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * ReachabilityServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * ReachabilityServiceClient reachabilityServiceClient =
+ * ReachabilityServiceClient.create(reachabilityServiceSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@BetaApi
@@ -120,7 +135,8 @@
public class ReachabilityServiceClient implements BackgroundResource {
private final ReachabilityServiceSettings settings;
private final ReachabilityServiceStub stub;
- private final OperationsClient operationsClient;
+ private final OperationsClient httpJsonOperationsClient;
+ private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of ReachabilityServiceClient with default settings. */
public static final ReachabilityServiceClient create() throws IOException {
@@ -152,13 +168,17 @@ public static final ReachabilityServiceClient create(ReachabilityServiceStub stu
protected ReachabilityServiceClient(ReachabilityServiceSettings settings) throws IOException {
this.settings = settings;
this.stub = ((ReachabilityServiceStubSettings) settings.getStubSettings()).createStub();
- this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ this.operationsClient =
+ com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
+ this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
protected ReachabilityServiceClient(ReachabilityServiceStub stub) {
this.settings = null;
this.stub = stub;
- this.operationsClient = OperationsClient.create(this.stub.getOperationsStub());
+ this.operationsClient =
+ com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub());
+ this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub());
}
public final ReachabilityServiceSettings getSettings() {
@@ -173,10 +193,19 @@ public ReachabilityServiceStub getStub() {
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
- public final OperationsClient getOperationsClient() {
+ public final com.google.longrunning.OperationsClient getOperationsClient() {
return operationsClient;
}
+ /**
+ * Returns the OperationsClient that can be used to query the status of a long-running operation
+ * returned by another API method call.
+ */
+ @BetaApi
+ public final OperationsClient getHttpJsonOperationsClient() {
+ return httpJsonOperationsClient;
+ }
+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Lists all Connectivity Tests owned by a project.
diff --git a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceSettings.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceSettings.java
index e5a47e81a1b0..38bf707ebd28 100644
--- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceSettings.java
+++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceSettings.java
@@ -23,6 +23,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;
@@ -169,11 +170,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return ReachabilityServiceStubSettings.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 ReachabilityServiceStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return ReachabilityServiceStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return ReachabilityServiceStubSettings.defaultTransportChannelProvider();
}
@@ -183,11 +191,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return ReachabilityServiceStubSettings.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);
@@ -225,6 +239,11 @@ private static Builder createDefault() {
return new Builder(ReachabilityServiceStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(ReachabilityServiceStubSettings.newHttpJsonBuilder());
+ }
+
public ReachabilityServiceStubSettings.Builder getStubSettingsBuilder() {
return ((ReachabilityServiceStubSettings.Builder) getStubSettings());
}
diff --git a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/HttpJsonReachabilityServiceCallableFactory.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/HttpJsonReachabilityServiceCallableFactory.java
new file mode 100644
index 000000000000..1b33639031a3
--- /dev/null
+++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/HttpJsonReachabilityServiceCallableFactory.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.networkmanagement.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 ReachabilityService service API.
+ *
+ *
This class is for advanced usage.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class HttpJsonReachabilityServiceCallableFactory
+ 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/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/HttpJsonReachabilityServiceStub.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/HttpJsonReachabilityServiceStub.java
new file mode 100644
index 000000000000..b38d42a06f06
--- /dev/null
+++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/HttpJsonReachabilityServiceStub.java
@@ -0,0 +1,592 @@
+/*
+ * 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.networkmanagement.v1beta1.stub;
+
+import static com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient.ListConnectivityTestsPagedResponse;
+
+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.HttpJsonOperationSnapshot;
+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.httpjson.longrunning.stub.HttpJsonOperationsStub;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.OperationCallable;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.networkmanagement.v1beta1.ConnectivityTest;
+import com.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest;
+import com.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest;
+import com.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest;
+import com.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest;
+import com.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsResponse;
+import com.google.cloud.networkmanagement.v1beta1.OperationMetadata;
+import com.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest;
+import com.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest;
+import com.google.longrunning.Operation;
+import com.google.protobuf.Empty;
+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 ReachabilityService service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class HttpJsonReachabilityServiceStub extends ReachabilityServiceStub {
+ private static final TypeRegistry typeRegistry =
+ TypeRegistry.newBuilder()
+ .add(Empty.getDescriptor())
+ .add(ConnectivityTest.getDescriptor())
+ .add(OperationMetadata.getDescriptor())
+ .build();
+
+ private static final ApiMethodDescriptor<
+ ListConnectivityTestsRequest, ListConnectivityTestsResponse>
+ listConnectivityTestsMethodDescriptor =
+ ApiMethodDescriptor
+ .newBuilder()
+ .setFullMethodName(
+ "google.cloud.networkmanagement.v1beta1.ReachabilityService/ListConnectivityTests")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{parent=projects/*/locations/global}/connectivityTests",
+ 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();
+ serializer.putQueryParam(fields, "filter", request.getFilter());
+ serializer.putQueryParam(fields, "orderBy", request.getOrderBy());
+ serializer.putQueryParam(fields, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListConnectivityTestsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ getConnectivityTestMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.networkmanagement.v1beta1.ReachabilityService/GetConnectivityTest")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{name=projects/*/locations/global/connectivityTests/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ConnectivityTest.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ createConnectivityTestMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.networkmanagement.v1beta1.ReachabilityService/CreateConnectivityTest")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{parent=projects/*/locations/global}/connectivityTests",
+ 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();
+ serializer.putQueryParam(fields, "testId", request.getTestId());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("resource", request.getResource()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (CreateConnectivityTestRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ updateConnectivityTestMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.networkmanagement.v1beta1.ReachabilityService/UpdateConnectivityTest")
+ .setHttpMethod("PATCH")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{resource.name=projects/*/locations/global/connectivityTests/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(
+ fields, "resource.name", request.getResource().getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "updateMask", request.getUpdateMask());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("resource", request.getResource()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (UpdateConnectivityTestRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ rerunConnectivityTestMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.networkmanagement.v1beta1.ReachabilityService/RerunConnectivityTest")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{name=projects/*/locations/global/connectivityTests/*}:rerun",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearName().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (RerunConnectivityTestRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ deleteConnectivityTestMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.networkmanagement.v1beta1.ReachabilityService/DeleteConnectivityTest")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{name=projects/*/locations/global/connectivityTests/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (DeleteConnectivityTestRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private final UnaryCallable
+ listConnectivityTestsCallable;
+ private final UnaryCallable
+ listConnectivityTestsPagedCallable;
+ private final UnaryCallable
+ getConnectivityTestCallable;
+ private final UnaryCallable
+ createConnectivityTestCallable;
+ private final OperationCallable<
+ CreateConnectivityTestRequest, ConnectivityTest, OperationMetadata>
+ createConnectivityTestOperationCallable;
+ private final UnaryCallable
+ updateConnectivityTestCallable;
+ private final OperationCallable<
+ UpdateConnectivityTestRequest, ConnectivityTest, OperationMetadata>
+ updateConnectivityTestOperationCallable;
+ private final UnaryCallable
+ rerunConnectivityTestCallable;
+ private final OperationCallable
+ rerunConnectivityTestOperationCallable;
+ private final UnaryCallable
+ deleteConnectivityTestCallable;
+ private final OperationCallable
+ deleteConnectivityTestOperationCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonOperationsStub httpJsonOperationsStub;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonReachabilityServiceStub create(
+ ReachabilityServiceStubSettings settings) throws IOException {
+ return new HttpJsonReachabilityServiceStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonReachabilityServiceStub create(ClientContext clientContext)
+ throws IOException {
+ return new HttpJsonReachabilityServiceStub(
+ ReachabilityServiceStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonReachabilityServiceStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonReachabilityServiceStub(
+ ReachabilityServiceStubSettings.newHttpJsonBuilder().build(),
+ clientContext,
+ callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonReachabilityServiceStub, 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 HttpJsonReachabilityServiceStub(
+ ReachabilityServiceStubSettings settings, ClientContext clientContext) throws IOException {
+ this(settings, clientContext, new HttpJsonReachabilityServiceCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonReachabilityServiceStub, 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 HttpJsonReachabilityServiceStub(
+ ReachabilityServiceStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.httpJsonOperationsStub =
+ HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
+
+ HttpJsonCallSettings
+ listConnectivityTestsTransportSettings =
+ HttpJsonCallSettings
+ .newBuilder()
+ .setMethodDescriptor(listConnectivityTestsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ getConnectivityTestTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getConnectivityTestMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ createConnectivityTestTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(createConnectivityTestMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ updateConnectivityTestTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(updateConnectivityTestMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ rerunConnectivityTestTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(rerunConnectivityTestMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ deleteConnectivityTestTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deleteConnectivityTestMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+
+ this.listConnectivityTestsCallable =
+ callableFactory.createUnaryCallable(
+ listConnectivityTestsTransportSettings,
+ settings.listConnectivityTestsSettings(),
+ clientContext);
+ this.listConnectivityTestsPagedCallable =
+ callableFactory.createPagedCallable(
+ listConnectivityTestsTransportSettings,
+ settings.listConnectivityTestsSettings(),
+ clientContext);
+ this.getConnectivityTestCallable =
+ callableFactory.createUnaryCallable(
+ getConnectivityTestTransportSettings,
+ settings.getConnectivityTestSettings(),
+ clientContext);
+ this.createConnectivityTestCallable =
+ callableFactory.createUnaryCallable(
+ createConnectivityTestTransportSettings,
+ settings.createConnectivityTestSettings(),
+ clientContext);
+ this.createConnectivityTestOperationCallable =
+ callableFactory.createOperationCallable(
+ createConnectivityTestTransportSettings,
+ settings.createConnectivityTestOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.updateConnectivityTestCallable =
+ callableFactory.createUnaryCallable(
+ updateConnectivityTestTransportSettings,
+ settings.updateConnectivityTestSettings(),
+ clientContext);
+ this.updateConnectivityTestOperationCallable =
+ callableFactory.createOperationCallable(
+ updateConnectivityTestTransportSettings,
+ settings.updateConnectivityTestOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.rerunConnectivityTestCallable =
+ callableFactory.createUnaryCallable(
+ rerunConnectivityTestTransportSettings,
+ settings.rerunConnectivityTestSettings(),
+ clientContext);
+ this.rerunConnectivityTestOperationCallable =
+ callableFactory.createOperationCallable(
+ rerunConnectivityTestTransportSettings,
+ settings.rerunConnectivityTestOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.deleteConnectivityTestCallable =
+ callableFactory.createUnaryCallable(
+ deleteConnectivityTestTransportSettings,
+ settings.deleteConnectivityTestSettings(),
+ clientContext);
+ this.deleteConnectivityTestOperationCallable =
+ callableFactory.createOperationCallable(
+ deleteConnectivityTestTransportSettings,
+ settings.deleteConnectivityTestOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(listConnectivityTestsMethodDescriptor);
+ methodDescriptors.add(getConnectivityTestMethodDescriptor);
+ methodDescriptors.add(createConnectivityTestMethodDescriptor);
+ methodDescriptors.add(updateConnectivityTestMethodDescriptor);
+ methodDescriptors.add(rerunConnectivityTestMethodDescriptor);
+ methodDescriptors.add(deleteConnectivityTestMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ public HttpJsonOperationsStub getHttpJsonOperationsStub() {
+ return httpJsonOperationsStub;
+ }
+
+ @Override
+ public UnaryCallable
+ listConnectivityTestsCallable() {
+ return listConnectivityTestsCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listConnectivityTestsPagedCallable() {
+ return listConnectivityTestsPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable getConnectivityTestCallable() {
+ return getConnectivityTestCallable;
+ }
+
+ @Override
+ public UnaryCallable createConnectivityTestCallable() {
+ return createConnectivityTestCallable;
+ }
+
+ @Override
+ public OperationCallable
+ createConnectivityTestOperationCallable() {
+ return createConnectivityTestOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable updateConnectivityTestCallable() {
+ return updateConnectivityTestCallable;
+ }
+
+ @Override
+ public OperationCallable
+ updateConnectivityTestOperationCallable() {
+ return updateConnectivityTestOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable rerunConnectivityTestCallable() {
+ return rerunConnectivityTestCallable;
+ }
+
+ @Override
+ public OperationCallable
+ rerunConnectivityTestOperationCallable() {
+ return rerunConnectivityTestOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteConnectivityTestCallable() {
+ return deleteConnectivityTestCallable;
+ }
+
+ @Override
+ public OperationCallable
+ deleteConnectivityTestOperationCallable() {
+ return deleteConnectivityTestOperationCallable;
+ }
+
+ @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/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStub.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStub.java
index 1ce8fdbc58bf..1757b51ced66 100644
--- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStub.java
+++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStub.java
@@ -47,7 +47,11 @@
public abstract class ReachabilityServiceStub implements BackgroundResource {
public OperationsStub getOperationsStub() {
- throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
+ return null;
+ }
+
+ public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() {
+ return null;
}
public UnaryCallable
diff --git a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStubSettings.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStubSettings.java
index da1769f9fd84..97a9c22e9028 100644
--- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStubSettings.java
+++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStubSettings.java
@@ -28,6 +28,9 @@
import com.google.api.gax.grpc.GrpcTransportChannel;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.api.gax.grpc.ProtoOperationTransformers;
+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.longrunning.OperationSnapshot;
import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
import com.google.api.gax.retrying.RetrySettings;
@@ -268,6 +271,11 @@ public ReachabilityServiceStub createStub() throws IOException {
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcReachabilityServiceStub.create(this);
}
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonReachabilityServiceStub.create(this);
+ }
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -300,18 +308,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", GaxProperties.getLibraryVersion(ReachabilityServiceStubSettings.class))
@@ -319,11 +334,30 @@ 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(ReachabilityServiceStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return ReachabilityServiceStubSettings.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);
@@ -482,6 +516,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
.listConnectivityTestsSettings()
diff --git a/java-network-management/google-cloud-network-management/src/test/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClientHttpJsonTest.java b/java-network-management/google-cloud-network-management/src/test/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClientHttpJsonTest.java
new file mode 100644
index 000000000000..0a8d6cf918bd
--- /dev/null
+++ b/java-network-management/google-cloud-network-management/src/test/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClientHttpJsonTest.java
@@ -0,0 +1,457 @@
+/*
+ * 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.networkmanagement.v1;
+
+import static com.google.cloud.networkmanagement.v1.ReachabilityServiceClient.ListConnectivityTestsPagedResponse;
+
+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.networkmanagement.v1.stub.HttpJsonReachabilityServiceStub;
+import com.google.common.collect.Lists;
+import com.google.longrunning.Operation;
+import com.google.protobuf.Any;
+import com.google.protobuf.Empty;
+import com.google.protobuf.FieldMask;
+import com.google.protobuf.Timestamp;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+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 ReachabilityServiceClientHttpJsonTest {
+ private static MockHttpService mockService;
+ private static ReachabilityServiceClient client;
+
+ @BeforeClass
+ public static void startStaticServer() throws IOException {
+ mockService =
+ new MockHttpService(
+ HttpJsonReachabilityServiceStub.getMethodDescriptors(),
+ ReachabilityServiceSettings.getDefaultEndpoint());
+ ReachabilityServiceSettings settings =
+ ReachabilityServiceSettings.newHttpJsonBuilder()
+ .setTransportChannelProvider(
+ ReachabilityServiceSettings.defaultHttpJsonTransportProviderBuilder()
+ .setHttpTransport(mockService)
+ .build())
+ .setCredentialsProvider(NoCredentialsProvider.create())
+ .build();
+ client = ReachabilityServiceClient.create(settings);
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ client.close();
+ }
+
+ @Before
+ public void setUp() {}
+
+ @After
+ public void tearDown() throws Exception {
+ mockService.reset();
+ }
+
+ @Test
+ public void listConnectivityTestsTest() throws Exception {
+ ConnectivityTest responsesElement = ConnectivityTest.newBuilder().build();
+ ListConnectivityTestsResponse expectedResponse =
+ ListConnectivityTestsResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllResources(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String parent = "projects/project-6156/locations/global";
+
+ ListConnectivityTestsPagedResponse pagedListResponse = client.listConnectivityTests(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getResourcesList().get(0), resources.get(0));
+
+ 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 listConnectivityTestsExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String parent = "projects/project-6156/locations/global";
+ client.listConnectivityTests(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getConnectivityTestTest() throws Exception {
+ ConnectivityTest expectedResponse =
+ ConnectivityTest.newBuilder()
+ .setName("name3373707")
+ .setDescription("description-1724546052")
+ .setSource(Endpoint.newBuilder().build())
+ .setDestination(Endpoint.newBuilder().build())
+ .setProtocol("protocol-989163880")
+ .addAllRelatedProjects(new ArrayList())
+ .setDisplayName("displayName1714148973")
+ .putAllLabels(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setReachabilityDetails(ReachabilityDetails.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String name = "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569";
+
+ ConnectivityTest actualResponse = client.getConnectivityTest(name);
+ 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 getConnectivityTestExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name =
+ "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569";
+ client.getConnectivityTest(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void createConnectivityTestTest() throws Exception {
+ ConnectivityTest expectedResponse =
+ ConnectivityTest.newBuilder()
+ .setName("name3373707")
+ .setDescription("description-1724546052")
+ .setSource(Endpoint.newBuilder().build())
+ .setDestination(Endpoint.newBuilder().build())
+ .setProtocol("protocol-989163880")
+ .addAllRelatedProjects(new ArrayList())
+ .setDisplayName("displayName1714148973")
+ .putAllLabels(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setReachabilityDetails(ReachabilityDetails.newBuilder().build())
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("createConnectivityTestTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ String parent = "projects/project-6156/locations/global";
+ String testId = "testId-877170355";
+ ConnectivityTest resource = ConnectivityTest.newBuilder().build();
+
+ ConnectivityTest actualResponse =
+ client.createConnectivityTestAsync(parent, testId, resource).get();
+ 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 createConnectivityTestExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String parent = "projects/project-6156/locations/global";
+ String testId = "testId-877170355";
+ ConnectivityTest resource = ConnectivityTest.newBuilder().build();
+ client.createConnectivityTestAsync(parent, testId, resource).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+
+ @Test
+ public void updateConnectivityTestTest() throws Exception {
+ ConnectivityTest expectedResponse =
+ ConnectivityTest.newBuilder()
+ .setName("name3373707")
+ .setDescription("description-1724546052")
+ .setSource(Endpoint.newBuilder().build())
+ .setDestination(Endpoint.newBuilder().build())
+ .setProtocol("protocol-989163880")
+ .addAllRelatedProjects(new ArrayList())
+ .setDisplayName("displayName1714148973")
+ .putAllLabels(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setReachabilityDetails(ReachabilityDetails.newBuilder().build())
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("updateConnectivityTestTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ FieldMask updateMask = FieldMask.newBuilder().build();
+ ConnectivityTest resource =
+ ConnectivityTest.newBuilder()
+ .setName(
+ "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569")
+ .setDescription("description-1724546052")
+ .setSource(Endpoint.newBuilder().build())
+ .setDestination(Endpoint.newBuilder().build())
+ .setProtocol("protocol-989163880")
+ .addAllRelatedProjects(new ArrayList())
+ .setDisplayName("displayName1714148973")
+ .putAllLabels(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setReachabilityDetails(ReachabilityDetails.newBuilder().build())
+ .build();
+
+ ConnectivityTest actualResponse =
+ client.updateConnectivityTestAsync(updateMask, resource).get();
+ 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 updateConnectivityTestExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ FieldMask updateMask = FieldMask.newBuilder().build();
+ ConnectivityTest resource =
+ ConnectivityTest.newBuilder()
+ .setName(
+ "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569")
+ .setDescription("description-1724546052")
+ .setSource(Endpoint.newBuilder().build())
+ .setDestination(Endpoint.newBuilder().build())
+ .setProtocol("protocol-989163880")
+ .addAllRelatedProjects(new ArrayList())
+ .setDisplayName("displayName1714148973")
+ .putAllLabels(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setReachabilityDetails(ReachabilityDetails.newBuilder().build())
+ .build();
+ client.updateConnectivityTestAsync(updateMask, resource).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+
+ @Test
+ public void rerunConnectivityTestTest() throws Exception {
+ ConnectivityTest expectedResponse =
+ ConnectivityTest.newBuilder()
+ .setName("name3373707")
+ .setDescription("description-1724546052")
+ .setSource(Endpoint.newBuilder().build())
+ .setDestination(Endpoint.newBuilder().build())
+ .setProtocol("protocol-989163880")
+ .addAllRelatedProjects(new ArrayList())
+ .setDisplayName("displayName1714148973")
+ .putAllLabels(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setReachabilityDetails(ReachabilityDetails.newBuilder().build())
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("rerunConnectivityTestTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ RerunConnectivityTestRequest request =
+ RerunConnectivityTestRequest.newBuilder()
+ .setName(
+ "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569")
+ .build();
+
+ ConnectivityTest actualResponse = client.rerunConnectivityTestAsync(request).get();
+ 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 rerunConnectivityTestExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ RerunConnectivityTestRequest request =
+ RerunConnectivityTestRequest.newBuilder()
+ .setName(
+ "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569")
+ .build();
+ client.rerunConnectivityTestAsync(request).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+
+ @Test
+ public void deleteConnectivityTestTest() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("deleteConnectivityTestTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ String name = "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569";
+
+ client.deleteConnectivityTestAsync(name).get();
+
+ 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 deleteConnectivityTestExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name =
+ "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569";
+ client.deleteConnectivityTestAsync(name).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+}
diff --git a/java-network-management/google-cloud-network-management/src/test/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceClientHttpJsonTest.java b/java-network-management/google-cloud-network-management/src/test/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceClientHttpJsonTest.java
new file mode 100644
index 000000000000..f3f62a3f8e34
--- /dev/null
+++ b/java-network-management/google-cloud-network-management/src/test/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceClientHttpJsonTest.java
@@ -0,0 +1,501 @@
+/*
+ * 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.networkmanagement.v1beta1;
+
+import static com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient.ListConnectivityTestsPagedResponse;
+
+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.networkmanagement.v1beta1.stub.HttpJsonReachabilityServiceStub;
+import com.google.common.collect.Lists;
+import com.google.longrunning.Operation;
+import com.google.protobuf.Any;
+import com.google.protobuf.Empty;
+import com.google.protobuf.FieldMask;
+import com.google.protobuf.Timestamp;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+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 ReachabilityServiceClientHttpJsonTest {
+ private static MockHttpService mockService;
+ private static ReachabilityServiceClient client;
+
+ @BeforeClass
+ public static void startStaticServer() throws IOException {
+ mockService =
+ new MockHttpService(
+ HttpJsonReachabilityServiceStub.getMethodDescriptors(),
+ ReachabilityServiceSettings.getDefaultEndpoint());
+ ReachabilityServiceSettings settings =
+ ReachabilityServiceSettings.newHttpJsonBuilder()
+ .setTransportChannelProvider(
+ ReachabilityServiceSettings.defaultHttpJsonTransportProviderBuilder()
+ .setHttpTransport(mockService)
+ .build())
+ .setCredentialsProvider(NoCredentialsProvider.create())
+ .build();
+ client = ReachabilityServiceClient.create(settings);
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ client.close();
+ }
+
+ @Before
+ public void setUp() {}
+
+ @After
+ public void tearDown() throws Exception {
+ mockService.reset();
+ }
+
+ @Test
+ public void listConnectivityTestsTest() throws Exception {
+ ConnectivityTest responsesElement = ConnectivityTest.newBuilder().build();
+ ListConnectivityTestsResponse expectedResponse =
+ ListConnectivityTestsResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllResources(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ ListConnectivityTestsRequest request =
+ ListConnectivityTestsRequest.newBuilder()
+ .setParent("projects/project-6156/locations/global")
+ .setPageSize(883849137)
+ .setPageToken("pageToken873572522")
+ .setFilter("filter-1274492040")
+ .setOrderBy("orderBy-1207110587")
+ .build();
+
+ ListConnectivityTestsPagedResponse pagedListResponse = client.listConnectivityTests(request);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getResourcesList().get(0), resources.get(0));
+
+ 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 listConnectivityTestsExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ ListConnectivityTestsRequest request =
+ ListConnectivityTestsRequest.newBuilder()
+ .setParent("projects/project-6156/locations/global")
+ .setPageSize(883849137)
+ .setPageToken("pageToken873572522")
+ .setFilter("filter-1274492040")
+ .setOrderBy("orderBy-1207110587")
+ .build();
+ client.listConnectivityTests(request);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getConnectivityTestTest() throws Exception {
+ ConnectivityTest expectedResponse =
+ ConnectivityTest.newBuilder()
+ .setName("name3373707")
+ .setDescription("description-1724546052")
+ .setSource(Endpoint.newBuilder().build())
+ .setDestination(Endpoint.newBuilder().build())
+ .setProtocol("protocol-989163880")
+ .addAllRelatedProjects(new ArrayList())
+ .setDisplayName("displayName1714148973")
+ .putAllLabels(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setReachabilityDetails(ReachabilityDetails.newBuilder().build())
+ .setProbingDetails(ProbingDetails.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ GetConnectivityTestRequest request =
+ GetConnectivityTestRequest.newBuilder()
+ .setName(
+ "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569")
+ .build();
+
+ ConnectivityTest actualResponse = client.getConnectivityTest(request);
+ 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 getConnectivityTestExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ GetConnectivityTestRequest request =
+ GetConnectivityTestRequest.newBuilder()
+ .setName(
+ "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569")
+ .build();
+ client.getConnectivityTest(request);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void createConnectivityTestTest() throws Exception {
+ ConnectivityTest expectedResponse =
+ ConnectivityTest.newBuilder()
+ .setName("name3373707")
+ .setDescription("description-1724546052")
+ .setSource(Endpoint.newBuilder().build())
+ .setDestination(Endpoint.newBuilder().build())
+ .setProtocol("protocol-989163880")
+ .addAllRelatedProjects(new ArrayList())
+ .setDisplayName("displayName1714148973")
+ .putAllLabels(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setReachabilityDetails(ReachabilityDetails.newBuilder().build())
+ .setProbingDetails(ProbingDetails.newBuilder().build())
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("createConnectivityTestTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ CreateConnectivityTestRequest request =
+ CreateConnectivityTestRequest.newBuilder()
+ .setParent("projects/project-6156/locations/global")
+ .setTestId("testId-877170355")
+ .setResource(ConnectivityTest.newBuilder().build())
+ .build();
+
+ ConnectivityTest actualResponse = client.createConnectivityTestAsync(request).get();
+ 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 createConnectivityTestExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ CreateConnectivityTestRequest request =
+ CreateConnectivityTestRequest.newBuilder()
+ .setParent("projects/project-6156/locations/global")
+ .setTestId("testId-877170355")
+ .setResource(ConnectivityTest.newBuilder().build())
+ .build();
+ client.createConnectivityTestAsync(request).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+
+ @Test
+ public void updateConnectivityTestTest() throws Exception {
+ ConnectivityTest expectedResponse =
+ ConnectivityTest.newBuilder()
+ .setName("name3373707")
+ .setDescription("description-1724546052")
+ .setSource(Endpoint.newBuilder().build())
+ .setDestination(Endpoint.newBuilder().build())
+ .setProtocol("protocol-989163880")
+ .addAllRelatedProjects(new ArrayList())
+ .setDisplayName("displayName1714148973")
+ .putAllLabels(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setReachabilityDetails(ReachabilityDetails.newBuilder().build())
+ .setProbingDetails(ProbingDetails.newBuilder().build())
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("updateConnectivityTestTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ UpdateConnectivityTestRequest request =
+ UpdateConnectivityTestRequest.newBuilder()
+ .setUpdateMask(FieldMask.newBuilder().build())
+ .setResource(
+ ConnectivityTest.newBuilder()
+ .setName(
+ "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569")
+ .setDescription("description-1724546052")
+ .setSource(Endpoint.newBuilder().build())
+ .setDestination(Endpoint.newBuilder().build())
+ .setProtocol("protocol-989163880")
+ .addAllRelatedProjects(new ArrayList())
+ .setDisplayName("displayName1714148973")
+ .putAllLabels(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setReachabilityDetails(ReachabilityDetails.newBuilder().build())
+ .setProbingDetails(ProbingDetails.newBuilder().build())
+ .build())
+ .build();
+
+ ConnectivityTest actualResponse = client.updateConnectivityTestAsync(request).get();
+ 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 updateConnectivityTestExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ UpdateConnectivityTestRequest request =
+ UpdateConnectivityTestRequest.newBuilder()
+ .setUpdateMask(FieldMask.newBuilder().build())
+ .setResource(
+ ConnectivityTest.newBuilder()
+ .setName(
+ "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569")
+ .setDescription("description-1724546052")
+ .setSource(Endpoint.newBuilder().build())
+ .setDestination(Endpoint.newBuilder().build())
+ .setProtocol("protocol-989163880")
+ .addAllRelatedProjects(new ArrayList())
+ .setDisplayName("displayName1714148973")
+ .putAllLabels(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setReachabilityDetails(ReachabilityDetails.newBuilder().build())
+ .setProbingDetails(ProbingDetails.newBuilder().build())
+ .build())
+ .build();
+ client.updateConnectivityTestAsync(request).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+
+ @Test
+ public void rerunConnectivityTestTest() throws Exception {
+ ConnectivityTest expectedResponse =
+ ConnectivityTest.newBuilder()
+ .setName("name3373707")
+ .setDescription("description-1724546052")
+ .setSource(Endpoint.newBuilder().build())
+ .setDestination(Endpoint.newBuilder().build())
+ .setProtocol("protocol-989163880")
+ .addAllRelatedProjects(new ArrayList())
+ .setDisplayName("displayName1714148973")
+ .putAllLabels(new HashMap())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setUpdateTime(Timestamp.newBuilder().build())
+ .setReachabilityDetails(ReachabilityDetails.newBuilder().build())
+ .setProbingDetails(ProbingDetails.newBuilder().build())
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("rerunConnectivityTestTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ RerunConnectivityTestRequest request =
+ RerunConnectivityTestRequest.newBuilder()
+ .setName(
+ "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569")
+ .build();
+
+ ConnectivityTest actualResponse = client.rerunConnectivityTestAsync(request).get();
+ 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 rerunConnectivityTestExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ RerunConnectivityTestRequest request =
+ RerunConnectivityTestRequest.newBuilder()
+ .setName(
+ "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569")
+ .build();
+ client.rerunConnectivityTestAsync(request).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+
+ @Test
+ public void deleteConnectivityTestTest() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("deleteConnectivityTestTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ DeleteConnectivityTestRequest request =
+ DeleteConnectivityTestRequest.newBuilder()
+ .setName(
+ "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569")
+ .build();
+
+ client.deleteConnectivityTestAsync(request).get();
+
+ List