diff --git a/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/AnalyticsHubServiceClient.java b/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/AnalyticsHubServiceClient.java
index 736f643d5204..1a33a7a4f79c 100644
--- a/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/AnalyticsHubServiceClient.java
+++ b/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/AnalyticsHubServiceClient.java
@@ -110,6 +110,21 @@
* AnalyticsHubServiceClient.create(analyticsHubServiceSettings);
* }
*
+ * 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.
+ * AnalyticsHubServiceSettings analyticsHubServiceSettings =
+ * AnalyticsHubServiceSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * AnalyticsHubServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * AnalyticsHubServiceClient analyticsHubServiceClient =
+ * AnalyticsHubServiceClient.create(analyticsHubServiceSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@BetaApi
diff --git a/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/AnalyticsHubServiceSettings.java b/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/AnalyticsHubServiceSettings.java
index 5dbc6ea27111..083506b076ef 100644
--- a/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/AnalyticsHubServiceSettings.java
+++ b/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/AnalyticsHubServiceSettings.java
@@ -25,6 +25,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;
@@ -190,11 +191,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return AnalyticsHubServiceStubSettings.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 AnalyticsHubServiceStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return AnalyticsHubServiceStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return AnalyticsHubServiceStubSettings.defaultTransportChannelProvider();
}
@@ -204,11 +212,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return AnalyticsHubServiceStubSettings.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);
@@ -246,6 +260,11 @@ private static Builder createDefault() {
return new Builder(AnalyticsHubServiceStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(AnalyticsHubServiceStubSettings.newHttpJsonBuilder());
+ }
+
public AnalyticsHubServiceStubSettings.Builder getStubSettingsBuilder() {
return ((AnalyticsHubServiceStubSettings.Builder) getStubSettings());
}
diff --git a/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/stub/AnalyticsHubServiceStubSettings.java b/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/stub/AnalyticsHubServiceStubSettings.java
index 98354b9a1a05..866c6cc737f7 100644
--- a/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/stub/AnalyticsHubServiceStubSettings.java
+++ b/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/stub/AnalyticsHubServiceStubSettings.java
@@ -29,6 +29,9 @@
import com.google.api.gax.grpc.GaxGrpcProperties;
import com.google.api.gax.grpc.GrpcTransportChannel;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
+import com.google.api.gax.httpjson.GaxHttpJsonProperties;
+import com.google.api.gax.httpjson.HttpJsonTransportChannel;
+import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.rpc.ApiCallContext;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
@@ -415,6 +418,11 @@ public AnalyticsHubServiceStub createStub() throws IOException {
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcAnalyticsHubServiceStub.create(this);
}
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonAnalyticsHubServiceStub.create(this);
+ }
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -447,18 +455,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(AnalyticsHubServiceStubSettings.class))
@@ -466,11 +481,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(AnalyticsHubServiceStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return AnalyticsHubServiceStubSettings.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);
@@ -662,6 +696,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
.listDataExchangesSettings()
diff --git a/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/stub/HttpJsonAnalyticsHubServiceCallableFactory.java b/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/stub/HttpJsonAnalyticsHubServiceCallableFactory.java
new file mode 100644
index 000000000000..93293c25b8c7
--- /dev/null
+++ b/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/stub/HttpJsonAnalyticsHubServiceCallableFactory.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.bigquery.dataexchange.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 AnalyticsHubService service API.
+ *
+ *
This class is for advanced usage.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class HttpJsonAnalyticsHubServiceCallableFactory
+ 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-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/stub/HttpJsonAnalyticsHubServiceStub.java b/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/stub/HttpJsonAnalyticsHubServiceStub.java
new file mode 100644
index 000000000000..b11de5eb97cf
--- /dev/null
+++ b/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/main/java/com/google/cloud/bigquery/dataexchange/v1beta1/stub/HttpJsonAnalyticsHubServiceStub.java
@@ -0,0 +1,1012 @@
+/*
+ * 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.bigquery.dataexchange.v1beta1.stub;
+
+import static com.google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubServiceClient.ListDataExchangesPagedResponse;
+import static com.google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubServiceClient.ListListingsPagedResponse;
+import static com.google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubServiceClient.ListOrgDataExchangesPagedResponse;
+
+import com.google.api.core.BetaApi;
+import com.google.api.core.InternalApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.core.BackgroundResourceAggregation;
+import com.google.api.gax.httpjson.ApiMethodDescriptor;
+import com.google.api.gax.httpjson.HttpJsonCallSettings;
+import com.google.api.gax.httpjson.HttpJsonStubCallableFactory;
+import com.google.api.gax.httpjson.ProtoMessageRequestFormatter;
+import com.google.api.gax.httpjson.ProtoMessageResponseParser;
+import com.google.api.gax.httpjson.ProtoRestSerializer;
+import com.google.api.gax.rpc.ClientContext;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.bigquery.dataexchange.v1beta1.CreateDataExchangeRequest;
+import com.google.cloud.bigquery.dataexchange.v1beta1.CreateListingRequest;
+import com.google.cloud.bigquery.dataexchange.v1beta1.DataExchange;
+import com.google.cloud.bigquery.dataexchange.v1beta1.DeleteDataExchangeRequest;
+import com.google.cloud.bigquery.dataexchange.v1beta1.DeleteListingRequest;
+import com.google.cloud.bigquery.dataexchange.v1beta1.GetDataExchangeRequest;
+import com.google.cloud.bigquery.dataexchange.v1beta1.GetListingRequest;
+import com.google.cloud.bigquery.dataexchange.v1beta1.ListDataExchangesRequest;
+import com.google.cloud.bigquery.dataexchange.v1beta1.ListDataExchangesResponse;
+import com.google.cloud.bigquery.dataexchange.v1beta1.ListListingsRequest;
+import com.google.cloud.bigquery.dataexchange.v1beta1.ListListingsResponse;
+import com.google.cloud.bigquery.dataexchange.v1beta1.ListOrgDataExchangesRequest;
+import com.google.cloud.bigquery.dataexchange.v1beta1.ListOrgDataExchangesResponse;
+import com.google.cloud.bigquery.dataexchange.v1beta1.Listing;
+import com.google.cloud.bigquery.dataexchange.v1beta1.SubscribeListingRequest;
+import com.google.cloud.bigquery.dataexchange.v1beta1.SubscribeListingResponse;
+import com.google.cloud.bigquery.dataexchange.v1beta1.UpdateDataExchangeRequest;
+import com.google.cloud.bigquery.dataexchange.v1beta1.UpdateListingRequest;
+import com.google.iam.v1.GetIamPolicyRequest;
+import com.google.iam.v1.Policy;
+import com.google.iam.v1.SetIamPolicyRequest;
+import com.google.iam.v1.TestIamPermissionsRequest;
+import com.google.iam.v1.TestIamPermissionsResponse;
+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 AnalyticsHubService service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class HttpJsonAnalyticsHubServiceStub extends AnalyticsHubServiceStub {
+ private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build();
+
+ private static final ApiMethodDescriptor
+ listDataExchangesMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/ListDataExchanges")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{parent=projects/*/locations/*}/dataExchanges",
+ 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, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListDataExchangesResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor<
+ ListOrgDataExchangesRequest, ListOrgDataExchangesResponse>
+ listOrgDataExchangesMethodDescriptor =
+ ApiMethodDescriptor
+ .newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/ListOrgDataExchanges")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{organization=organizations/*/locations/*}/dataExchanges",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(
+ fields, "organization", request.getOrganization());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListOrgDataExchangesResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ getDataExchangeMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/GetDataExchange")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{name=projects/*/locations/*/dataExchanges/*}",
+ 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(DataExchange.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ createDataExchangeMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/CreateDataExchange")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{parent=projects/*/locations/*}/dataExchanges",
+ 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, "dataExchangeId", request.getDataExchangeId());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("dataExchange", request.getDataExchange()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(DataExchange.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ updateDataExchangeMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/UpdateDataExchange")
+ .setHttpMethod("PATCH")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{dataExchange.name=projects/*/locations/*/dataExchanges/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(
+ fields, "dataExchange.name", request.getDataExchange().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("dataExchange", request.getDataExchange()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(DataExchange.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ deleteDataExchangeMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/DeleteDataExchange")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{name=projects/*/locations/*/dataExchanges/*}",
+ 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(Empty.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ listListingsMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/ListListings")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{parent=projects/*/locations/*/dataExchanges/*}/listings",
+ 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, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListListingsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor getListingMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/GetListing")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{name=projects/*/locations/*/dataExchanges/*/listings/*}",
+ 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(Listing.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ createListingMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/CreateListing")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{parent=projects/*/locations/*/dataExchanges/*}/listings",
+ 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, "listingId", request.getListingId());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create().toBody("listing", request.getListing()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Listing.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ updateListingMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/UpdateListing")
+ .setHttpMethod("PATCH")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{listing.name=projects/*/locations/*/dataExchanges/*/listings/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(
+ fields, "listing.name", request.getListing().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("listing", request.getListing()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Listing.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ deleteListingMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/DeleteListing")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{name=projects/*/locations/*/dataExchanges/*/listings/*}",
+ 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(Empty.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ subscribeListingMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/SubscribeListing")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{name=projects/*/locations/*/dataExchanges/*/listings/*}:subscribe",
+ 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(SubscribeListingResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ getIamPolicyMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/GetIamPolicy")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{resource=projects/*/locations/*/dataExchanges/*}:getIamPolicy",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "resource", request.getResource());
+ return fields;
+ })
+ .setAdditionalPaths(
+ "/v1beta1/{resource=projects/*/locations/*/dataExchanges/*/listings/*}:getIamPolicy")
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearResource().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Policy.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ setIamPolicyMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/SetIamPolicy")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{resource=projects/*/locations/*/dataExchanges/*}:setIamPolicy",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "resource", request.getResource());
+ return fields;
+ })
+ .setAdditionalPaths(
+ "/v1beta1/{resource=projects/*/locations/*/dataExchanges/*/listings/*}:setIamPolicy")
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearResource().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Policy.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ testIamPermissionsMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/TestIamPermissions")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{resource=projects/*/locations/*/dataExchanges/*}:testIamPermissions",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "resource", request.getResource());
+ return fields;
+ })
+ .setAdditionalPaths(
+ "/v1beta1/{resource=projects/*/locations/*/dataExchanges/*/listings/*}:testIamPermissions")
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("*", request.toBuilder().clearResource().build()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(TestIamPermissionsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private final UnaryCallable
+ listDataExchangesCallable;
+ private final UnaryCallable
+ listDataExchangesPagedCallable;
+ private final UnaryCallable
+ listOrgDataExchangesCallable;
+ private final UnaryCallable
+ listOrgDataExchangesPagedCallable;
+ private final UnaryCallable getDataExchangeCallable;
+ private final UnaryCallable createDataExchangeCallable;
+ private final UnaryCallable updateDataExchangeCallable;
+ private final UnaryCallable deleteDataExchangeCallable;
+ private final UnaryCallable listListingsCallable;
+ private final UnaryCallable
+ listListingsPagedCallable;
+ private final UnaryCallable getListingCallable;
+ private final UnaryCallable createListingCallable;
+ private final UnaryCallable updateListingCallable;
+ private final UnaryCallable deleteListingCallable;
+ private final UnaryCallable
+ subscribeListingCallable;
+ private final UnaryCallable getIamPolicyCallable;
+ private final UnaryCallable setIamPolicyCallable;
+ private final UnaryCallable
+ testIamPermissionsCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonAnalyticsHubServiceStub create(
+ AnalyticsHubServiceStubSettings settings) throws IOException {
+ return new HttpJsonAnalyticsHubServiceStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonAnalyticsHubServiceStub create(ClientContext clientContext)
+ throws IOException {
+ return new HttpJsonAnalyticsHubServiceStub(
+ AnalyticsHubServiceStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonAnalyticsHubServiceStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonAnalyticsHubServiceStub(
+ AnalyticsHubServiceStubSettings.newHttpJsonBuilder().build(),
+ clientContext,
+ callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonAnalyticsHubServiceStub, 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 HttpJsonAnalyticsHubServiceStub(
+ AnalyticsHubServiceStubSettings settings, ClientContext clientContext) throws IOException {
+ this(settings, clientContext, new HttpJsonAnalyticsHubServiceCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonAnalyticsHubServiceStub, 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 HttpJsonAnalyticsHubServiceStub(
+ AnalyticsHubServiceStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+
+ HttpJsonCallSettings
+ listDataExchangesTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(listDataExchangesMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ listOrgDataExchangesTransportSettings =
+ HttpJsonCallSettings
+ .newBuilder()
+ .setMethodDescriptor(listOrgDataExchangesMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings getDataExchangeTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getDataExchangeMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ createDataExchangeTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(createDataExchangeMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ updateDataExchangeTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(updateDataExchangeMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings deleteDataExchangeTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deleteDataExchangeMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings listListingsTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(listListingsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings getListingTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getListingMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings createListingTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(createListingMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings updateListingTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(updateListingMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings deleteListingTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deleteListingMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ subscribeListingTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(subscribeListingMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings getIamPolicyTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getIamPolicyMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings setIamPolicyTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(setIamPolicyMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ testIamPermissionsTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(testIamPermissionsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+
+ this.listDataExchangesCallable =
+ callableFactory.createUnaryCallable(
+ listDataExchangesTransportSettings,
+ settings.listDataExchangesSettings(),
+ clientContext);
+ this.listDataExchangesPagedCallable =
+ callableFactory.createPagedCallable(
+ listDataExchangesTransportSettings,
+ settings.listDataExchangesSettings(),
+ clientContext);
+ this.listOrgDataExchangesCallable =
+ callableFactory.createUnaryCallable(
+ listOrgDataExchangesTransportSettings,
+ settings.listOrgDataExchangesSettings(),
+ clientContext);
+ this.listOrgDataExchangesPagedCallable =
+ callableFactory.createPagedCallable(
+ listOrgDataExchangesTransportSettings,
+ settings.listOrgDataExchangesSettings(),
+ clientContext);
+ this.getDataExchangeCallable =
+ callableFactory.createUnaryCallable(
+ getDataExchangeTransportSettings, settings.getDataExchangeSettings(), clientContext);
+ this.createDataExchangeCallable =
+ callableFactory.createUnaryCallable(
+ createDataExchangeTransportSettings,
+ settings.createDataExchangeSettings(),
+ clientContext);
+ this.updateDataExchangeCallable =
+ callableFactory.createUnaryCallable(
+ updateDataExchangeTransportSettings,
+ settings.updateDataExchangeSettings(),
+ clientContext);
+ this.deleteDataExchangeCallable =
+ callableFactory.createUnaryCallable(
+ deleteDataExchangeTransportSettings,
+ settings.deleteDataExchangeSettings(),
+ clientContext);
+ this.listListingsCallable =
+ callableFactory.createUnaryCallable(
+ listListingsTransportSettings, settings.listListingsSettings(), clientContext);
+ this.listListingsPagedCallable =
+ callableFactory.createPagedCallable(
+ listListingsTransportSettings, settings.listListingsSettings(), clientContext);
+ this.getListingCallable =
+ callableFactory.createUnaryCallable(
+ getListingTransportSettings, settings.getListingSettings(), clientContext);
+ this.createListingCallable =
+ callableFactory.createUnaryCallable(
+ createListingTransportSettings, settings.createListingSettings(), clientContext);
+ this.updateListingCallable =
+ callableFactory.createUnaryCallable(
+ updateListingTransportSettings, settings.updateListingSettings(), clientContext);
+ this.deleteListingCallable =
+ callableFactory.createUnaryCallable(
+ deleteListingTransportSettings, settings.deleteListingSettings(), clientContext);
+ this.subscribeListingCallable =
+ callableFactory.createUnaryCallable(
+ subscribeListingTransportSettings, settings.subscribeListingSettings(), clientContext);
+ this.getIamPolicyCallable =
+ callableFactory.createUnaryCallable(
+ getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext);
+ this.setIamPolicyCallable =
+ callableFactory.createUnaryCallable(
+ setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext);
+ this.testIamPermissionsCallable =
+ callableFactory.createUnaryCallable(
+ testIamPermissionsTransportSettings,
+ settings.testIamPermissionsSettings(),
+ clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(listDataExchangesMethodDescriptor);
+ methodDescriptors.add(listOrgDataExchangesMethodDescriptor);
+ methodDescriptors.add(getDataExchangeMethodDescriptor);
+ methodDescriptors.add(createDataExchangeMethodDescriptor);
+ methodDescriptors.add(updateDataExchangeMethodDescriptor);
+ methodDescriptors.add(deleteDataExchangeMethodDescriptor);
+ methodDescriptors.add(listListingsMethodDescriptor);
+ methodDescriptors.add(getListingMethodDescriptor);
+ methodDescriptors.add(createListingMethodDescriptor);
+ methodDescriptors.add(updateListingMethodDescriptor);
+ methodDescriptors.add(deleteListingMethodDescriptor);
+ methodDescriptors.add(subscribeListingMethodDescriptor);
+ methodDescriptors.add(getIamPolicyMethodDescriptor);
+ methodDescriptors.add(setIamPolicyMethodDescriptor);
+ methodDescriptors.add(testIamPermissionsMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ @Override
+ public UnaryCallable
+ listDataExchangesCallable() {
+ return listDataExchangesCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listDataExchangesPagedCallable() {
+ return listDataExchangesPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listOrgDataExchangesCallable() {
+ return listOrgDataExchangesCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listOrgDataExchangesPagedCallable() {
+ return listOrgDataExchangesPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable getDataExchangeCallable() {
+ return getDataExchangeCallable;
+ }
+
+ @Override
+ public UnaryCallable createDataExchangeCallable() {
+ return createDataExchangeCallable;
+ }
+
+ @Override
+ public UnaryCallable updateDataExchangeCallable() {
+ return updateDataExchangeCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteDataExchangeCallable() {
+ return deleteDataExchangeCallable;
+ }
+
+ @Override
+ public UnaryCallable listListingsCallable() {
+ return listListingsCallable;
+ }
+
+ @Override
+ public UnaryCallable listListingsPagedCallable() {
+ return listListingsPagedCallable;
+ }
+
+ @Override
+ public UnaryCallable getListingCallable() {
+ return getListingCallable;
+ }
+
+ @Override
+ public UnaryCallable createListingCallable() {
+ return createListingCallable;
+ }
+
+ @Override
+ public UnaryCallable updateListingCallable() {
+ return updateListingCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteListingCallable() {
+ return deleteListingCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ subscribeListingCallable() {
+ return subscribeListingCallable;
+ }
+
+ @Override
+ public UnaryCallable getIamPolicyCallable() {
+ return getIamPolicyCallable;
+ }
+
+ @Override
+ public UnaryCallable setIamPolicyCallable() {
+ return setIamPolicyCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ testIamPermissionsCallable() {
+ return testIamPermissionsCallable;
+ }
+
+ @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-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/test/java/com/google/cloud/bigquery/dataexchange/v1beta1/AnalyticsHubServiceClientHttpJsonTest.java b/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/test/java/com/google/cloud/bigquery/dataexchange/v1beta1/AnalyticsHubServiceClientHttpJsonTest.java
new file mode 100644
index 000000000000..bf1c735e5b7b
--- /dev/null
+++ b/java-bigquery-data-exchange/google-cloud-bigquery-data-exchange/src/test/java/com/google/cloud/bigquery/dataexchange/v1beta1/AnalyticsHubServiceClientHttpJsonTest.java
@@ -0,0 +1,1343 @@
+/*
+ * 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.bigquery.dataexchange.v1beta1;
+
+import static com.google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubServiceClient.ListDataExchangesPagedResponse;
+import static com.google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubServiceClient.ListListingsPagedResponse;
+import static com.google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubServiceClient.ListOrgDataExchangesPagedResponse;
+
+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.bigquery.dataexchange.common.Category;
+import com.google.cloud.bigquery.dataexchange.v1beta1.stub.HttpJsonAnalyticsHubServiceStub;
+import com.google.common.collect.Lists;
+import com.google.iam.v1.AuditConfig;
+import com.google.iam.v1.Binding;
+import com.google.iam.v1.GetIamPolicyRequest;
+import com.google.iam.v1.GetPolicyOptions;
+import com.google.iam.v1.Policy;
+import com.google.iam.v1.SetIamPolicyRequest;
+import com.google.iam.v1.TestIamPermissionsRequest;
+import com.google.iam.v1.TestIamPermissionsResponse;
+import com.google.protobuf.ByteString;
+import com.google.protobuf.Empty;
+import com.google.protobuf.FieldMask;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.annotation.Generated;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@Generated("by gapic-generator-java")
+public class AnalyticsHubServiceClientHttpJsonTest {
+ private static MockHttpService mockService;
+ private static AnalyticsHubServiceClient client;
+
+ @BeforeClass
+ public static void startStaticServer() throws IOException {
+ mockService =
+ new MockHttpService(
+ HttpJsonAnalyticsHubServiceStub.getMethodDescriptors(),
+ AnalyticsHubServiceSettings.getDefaultEndpoint());
+ AnalyticsHubServiceSettings settings =
+ AnalyticsHubServiceSettings.newHttpJsonBuilder()
+ .setTransportChannelProvider(
+ AnalyticsHubServiceSettings.defaultHttpJsonTransportProviderBuilder()
+ .setHttpTransport(mockService)
+ .build())
+ .setCredentialsProvider(NoCredentialsProvider.create())
+ .build();
+ client = AnalyticsHubServiceClient.create(settings);
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ client.close();
+ }
+
+ @Before
+ public void setUp() {}
+
+ @After
+ public void tearDown() throws Exception {
+ mockService.reset();
+ }
+
+ @Test
+ public void listDataExchangesTest() throws Exception {
+ DataExchange responsesElement = DataExchange.newBuilder().build();
+ ListDataExchangesResponse expectedResponse =
+ ListDataExchangesResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllDataExchanges(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+
+ ListDataExchangesPagedResponse pagedListResponse = client.listDataExchanges(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getDataExchangesList().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 listDataExchangesExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ client.listDataExchanges(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listDataExchangesTest2() throws Exception {
+ DataExchange responsesElement = DataExchange.newBuilder().build();
+ ListDataExchangesResponse expectedResponse =
+ ListDataExchangesResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllDataExchanges(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String parent = "projects/project-5833/locations/location-5833";
+
+ ListDataExchangesPagedResponse pagedListResponse = client.listDataExchanges(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getDataExchangesList().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 listDataExchangesExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String parent = "projects/project-5833/locations/location-5833";
+ client.listDataExchanges(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listOrgDataExchangesTest() throws Exception {
+ DataExchange responsesElement = DataExchange.newBuilder().build();
+ ListOrgDataExchangesResponse expectedResponse =
+ ListOrgDataExchangesResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllDataExchanges(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String organization = "organizations/organization-686/locations/location-686";
+
+ ListOrgDataExchangesPagedResponse pagedListResponse = client.listOrgDataExchanges(organization);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getDataExchangesList().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 listOrgDataExchangesExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String organization = "organizations/organization-686/locations/location-686";
+ client.listOrgDataExchanges(organization);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getDataExchangeTest() throws Exception {
+ DataExchange expectedResponse =
+ DataExchange.newBuilder()
+ .setName(DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]").toString())
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setPrimaryContact("primaryContact-532068418")
+ .setDocumentation("documentation1587405498")
+ .setListingCount(-1101038700)
+ .setIcon(ByteString.EMPTY)
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ DataExchangeName name = DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]");
+
+ DataExchange actualResponse = client.getDataExchange(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 getDataExchangeExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ DataExchangeName name = DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]");
+ client.getDataExchange(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getDataExchangeTest2() throws Exception {
+ DataExchange expectedResponse =
+ DataExchange.newBuilder()
+ .setName(DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]").toString())
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setPrimaryContact("primaryContact-532068418")
+ .setDocumentation("documentation1587405498")
+ .setListingCount(-1101038700)
+ .setIcon(ByteString.EMPTY)
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String name = "projects/project-1196/locations/location-1196/dataExchanges/dataExchange-1196";
+
+ DataExchange actualResponse = client.getDataExchange(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 getDataExchangeExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name = "projects/project-1196/locations/location-1196/dataExchanges/dataExchange-1196";
+ client.getDataExchange(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void createDataExchangeTest() throws Exception {
+ DataExchange expectedResponse =
+ DataExchange.newBuilder()
+ .setName(DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]").toString())
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setPrimaryContact("primaryContact-532068418")
+ .setDocumentation("documentation1587405498")
+ .setListingCount(-1101038700)
+ .setIcon(ByteString.EMPTY)
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ DataExchange dataExchange = DataExchange.newBuilder().build();
+
+ DataExchange actualResponse = client.createDataExchange(parent, dataExchange);
+ 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 createDataExchangeExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ DataExchange dataExchange = DataExchange.newBuilder().build();
+ client.createDataExchange(parent, dataExchange);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void createDataExchangeTest2() throws Exception {
+ DataExchange expectedResponse =
+ DataExchange.newBuilder()
+ .setName(DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]").toString())
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setPrimaryContact("primaryContact-532068418")
+ .setDocumentation("documentation1587405498")
+ .setListingCount(-1101038700)
+ .setIcon(ByteString.EMPTY)
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String parent = "projects/project-5833/locations/location-5833";
+ DataExchange dataExchange = DataExchange.newBuilder().build();
+
+ DataExchange actualResponse = client.createDataExchange(parent, dataExchange);
+ 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 createDataExchangeExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String parent = "projects/project-5833/locations/location-5833";
+ DataExchange dataExchange = DataExchange.newBuilder().build();
+ client.createDataExchange(parent, dataExchange);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void updateDataExchangeTest() throws Exception {
+ DataExchange expectedResponse =
+ DataExchange.newBuilder()
+ .setName(DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]").toString())
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setPrimaryContact("primaryContact-532068418")
+ .setDocumentation("documentation1587405498")
+ .setListingCount(-1101038700)
+ .setIcon(ByteString.EMPTY)
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ DataExchange dataExchange =
+ DataExchange.newBuilder()
+ .setName(DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]").toString())
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setPrimaryContact("primaryContact-532068418")
+ .setDocumentation("documentation1587405498")
+ .setListingCount(-1101038700)
+ .setIcon(ByteString.EMPTY)
+ .build();
+ FieldMask updateMask = FieldMask.newBuilder().build();
+
+ DataExchange actualResponse = client.updateDataExchange(dataExchange, updateMask);
+ 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 updateDataExchangeExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ DataExchange dataExchange =
+ DataExchange.newBuilder()
+ .setName(DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]").toString())
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setPrimaryContact("primaryContact-532068418")
+ .setDocumentation("documentation1587405498")
+ .setListingCount(-1101038700)
+ .setIcon(ByteString.EMPTY)
+ .build();
+ FieldMask updateMask = FieldMask.newBuilder().build();
+ client.updateDataExchange(dataExchange, updateMask);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void deleteDataExchangeTest() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ DataExchangeName name = DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]");
+
+ client.deleteDataExchange(name);
+
+ 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 deleteDataExchangeExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ DataExchangeName name = DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]");
+ client.deleteDataExchange(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void deleteDataExchangeTest2() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ String name = "projects/project-1196/locations/location-1196/dataExchanges/dataExchange-1196";
+
+ client.deleteDataExchange(name);
+
+ 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 deleteDataExchangeExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name = "projects/project-1196/locations/location-1196/dataExchanges/dataExchange-1196";
+ client.deleteDataExchange(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listListingsTest() throws Exception {
+ Listing responsesElement = Listing.newBuilder().build();
+ ListListingsResponse expectedResponse =
+ ListListingsResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllListings(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ DataExchangeName parent = DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]");
+
+ ListListingsPagedResponse pagedListResponse = client.listListings(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getListingsList().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 listListingsExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ DataExchangeName parent = DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]");
+ client.listListings(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listListingsTest2() throws Exception {
+ Listing responsesElement = Listing.newBuilder().build();
+ ListListingsResponse expectedResponse =
+ ListListingsResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllListings(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String parent = "projects/project-4709/locations/location-4709/dataExchanges/dataExchange-4709";
+
+ ListListingsPagedResponse pagedListResponse = client.listListings(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getListingsList().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 listListingsExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String parent =
+ "projects/project-4709/locations/location-4709/dataExchanges/dataExchange-4709";
+ client.listListings(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getListingTest() throws Exception {
+ Listing expectedResponse =
+ Listing.newBuilder()
+ .setName(
+ ListingName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]", "[LISTING]")
+ .toString())
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setPrimaryContact("primaryContact-532068418")
+ .setDocumentation("documentation1587405498")
+ .setIcon(ByteString.EMPTY)
+ .setDataProvider(DataProvider.newBuilder().build())
+ .addAllCategories(new ArrayList())
+ .setPublisher(Publisher.newBuilder().build())
+ .setRequestAccess("requestAccess871967955")
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ ListingName name = ListingName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]", "[LISTING]");
+
+ Listing actualResponse = client.getListing(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 getListingExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ ListingName name = ListingName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]", "[LISTING]");
+ client.getListing(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getListingTest2() throws Exception {
+ Listing expectedResponse =
+ Listing.newBuilder()
+ .setName(
+ ListingName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]", "[LISTING]")
+ .toString())
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setPrimaryContact("primaryContact-532068418")
+ .setDocumentation("documentation1587405498")
+ .setIcon(ByteString.EMPTY)
+ .setDataProvider(DataProvider.newBuilder().build())
+ .addAllCategories(new ArrayList())
+ .setPublisher(Publisher.newBuilder().build())
+ .setRequestAccess("requestAccess871967955")
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String name =
+ "projects/project-9891/locations/location-9891/dataExchanges/dataExchange-9891/listings/listing-9891";
+
+ Listing actualResponse = client.getListing(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 getListingExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name =
+ "projects/project-9891/locations/location-9891/dataExchanges/dataExchange-9891/listings/listing-9891";
+ client.getListing(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void createListingTest() throws Exception {
+ Listing expectedResponse =
+ Listing.newBuilder()
+ .setName(
+ ListingName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]", "[LISTING]")
+ .toString())
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setPrimaryContact("primaryContact-532068418")
+ .setDocumentation("documentation1587405498")
+ .setIcon(ByteString.EMPTY)
+ .setDataProvider(DataProvider.newBuilder().build())
+ .addAllCategories(new ArrayList())
+ .setPublisher(Publisher.newBuilder().build())
+ .setRequestAccess("requestAccess871967955")
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ DataExchangeName parent = DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]");
+ Listing listing = Listing.newBuilder().build();
+
+ Listing actualResponse = client.createListing(parent, listing);
+ 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 createListingExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ DataExchangeName parent = DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]");
+ Listing listing = Listing.newBuilder().build();
+ client.createListing(parent, listing);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void createListingTest2() throws Exception {
+ Listing expectedResponse =
+ Listing.newBuilder()
+ .setName(
+ ListingName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]", "[LISTING]")
+ .toString())
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setPrimaryContact("primaryContact-532068418")
+ .setDocumentation("documentation1587405498")
+ .setIcon(ByteString.EMPTY)
+ .setDataProvider(DataProvider.newBuilder().build())
+ .addAllCategories(new ArrayList())
+ .setPublisher(Publisher.newBuilder().build())
+ .setRequestAccess("requestAccess871967955")
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String parent = "projects/project-4709/locations/location-4709/dataExchanges/dataExchange-4709";
+ Listing listing = Listing.newBuilder().build();
+
+ Listing actualResponse = client.createListing(parent, listing);
+ 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 createListingExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String parent =
+ "projects/project-4709/locations/location-4709/dataExchanges/dataExchange-4709";
+ Listing listing = Listing.newBuilder().build();
+ client.createListing(parent, listing);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void updateListingTest() throws Exception {
+ Listing expectedResponse =
+ Listing.newBuilder()
+ .setName(
+ ListingName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]", "[LISTING]")
+ .toString())
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setPrimaryContact("primaryContact-532068418")
+ .setDocumentation("documentation1587405498")
+ .setIcon(ByteString.EMPTY)
+ .setDataProvider(DataProvider.newBuilder().build())
+ .addAllCategories(new ArrayList())
+ .setPublisher(Publisher.newBuilder().build())
+ .setRequestAccess("requestAccess871967955")
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ Listing listing =
+ Listing.newBuilder()
+ .setName(
+ ListingName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]", "[LISTING]")
+ .toString())
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setPrimaryContact("primaryContact-532068418")
+ .setDocumentation("documentation1587405498")
+ .setIcon(ByteString.EMPTY)
+ .setDataProvider(DataProvider.newBuilder().build())
+ .addAllCategories(new ArrayList())
+ .setPublisher(Publisher.newBuilder().build())
+ .setRequestAccess("requestAccess871967955")
+ .build();
+ FieldMask updateMask = FieldMask.newBuilder().build();
+
+ Listing actualResponse = client.updateListing(listing, updateMask);
+ 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 updateListingExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ Listing listing =
+ Listing.newBuilder()
+ .setName(
+ ListingName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]", "[LISTING]")
+ .toString())
+ .setDisplayName("displayName1714148973")
+ .setDescription("description-1724546052")
+ .setPrimaryContact("primaryContact-532068418")
+ .setDocumentation("documentation1587405498")
+ .setIcon(ByteString.EMPTY)
+ .setDataProvider(DataProvider.newBuilder().build())
+ .addAllCategories(new ArrayList())
+ .setPublisher(Publisher.newBuilder().build())
+ .setRequestAccess("requestAccess871967955")
+ .build();
+ FieldMask updateMask = FieldMask.newBuilder().build();
+ client.updateListing(listing, updateMask);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void deleteListingTest() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ ListingName name = ListingName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]", "[LISTING]");
+
+ client.deleteListing(name);
+
+ 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 deleteListingExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ ListingName name = ListingName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]", "[LISTING]");
+ client.deleteListing(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void deleteListingTest2() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ String name =
+ "projects/project-9891/locations/location-9891/dataExchanges/dataExchange-9891/listings/listing-9891";
+
+ client.deleteListing(name);
+
+ 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 deleteListingExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name =
+ "projects/project-9891/locations/location-9891/dataExchanges/dataExchange-9891/listings/listing-9891";
+ client.deleteListing(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void subscribeListingTest() throws Exception {
+ SubscribeListingResponse expectedResponse = SubscribeListingResponse.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ ListingName name = ListingName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]", "[LISTING]");
+
+ SubscribeListingResponse actualResponse = client.subscribeListing(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 subscribeListingExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ ListingName name = ListingName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]", "[LISTING]");
+ client.subscribeListing(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void subscribeListingTest2() throws Exception {
+ SubscribeListingResponse expectedResponse = SubscribeListingResponse.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ String name =
+ "projects/project-9891/locations/location-9891/dataExchanges/dataExchange-9891/listings/listing-9891";
+
+ SubscribeListingResponse actualResponse = client.subscribeListing(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 subscribeListingExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name =
+ "projects/project-9891/locations/location-9891/dataExchanges/dataExchange-9891/listings/listing-9891";
+ client.subscribeListing(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getIamPolicyTest() throws Exception {
+ Policy expectedResponse =
+ Policy.newBuilder()
+ .setVersion(351608024)
+ .addAllBindings(new ArrayList())
+ .addAllAuditConfigs(new ArrayList())
+ .setEtag(ByteString.EMPTY)
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ GetIamPolicyRequest request =
+ GetIamPolicyRequest.newBuilder()
+ .setResource(
+ DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]").toString())
+ .setOptions(GetPolicyOptions.newBuilder().build())
+ .build();
+
+ Policy actualResponse = client.getIamPolicy(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 getIamPolicyExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ GetIamPolicyRequest request =
+ GetIamPolicyRequest.newBuilder()
+ .setResource(
+ DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]").toString())
+ .setOptions(GetPolicyOptions.newBuilder().build())
+ .build();
+ client.getIamPolicy(request);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void setIamPolicyTest() throws Exception {
+ Policy expectedResponse =
+ Policy.newBuilder()
+ .setVersion(351608024)
+ .addAllBindings(new ArrayList())
+ .addAllAuditConfigs(new ArrayList())
+ .setEtag(ByteString.EMPTY)
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ SetIamPolicyRequest request =
+ SetIamPolicyRequest.newBuilder()
+ .setResource(
+ DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]").toString())
+ .setPolicy(Policy.newBuilder().build())
+ .setUpdateMask(FieldMask.newBuilder().build())
+ .build();
+
+ Policy actualResponse = client.setIamPolicy(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 setIamPolicyExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ SetIamPolicyRequest request =
+ SetIamPolicyRequest.newBuilder()
+ .setResource(
+ DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]").toString())
+ .setPolicy(Policy.newBuilder().build())
+ .setUpdateMask(FieldMask.newBuilder().build())
+ .build();
+ client.setIamPolicy(request);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void testIamPermissionsTest() throws Exception {
+ TestIamPermissionsResponse expectedResponse =
+ TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build();
+ mockService.addResponse(expectedResponse);
+
+ TestIamPermissionsRequest request =
+ TestIamPermissionsRequest.newBuilder()
+ .setResource(
+ DataExchangeName.of("[PROJECT]", "[LOCATION]", "[DATA_EXCHANGE]").toString())
+ .addAllPermissions(new ArrayList