diff --git a/java-data-fusion/google-cloud-data-fusion/pom.xml b/java-data-fusion/google-cloud-data-fusion/pom.xml index 1762e1a022b6..2c8695ca8a41 100644 --- a/java-data-fusion/google-cloud-data-fusion/pom.xml +++ b/java-data-fusion/google-cloud-data-fusion/pom.xml @@ -62,6 +62,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -86,12 +90,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/DataFusionClient.java b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/DataFusionClient.java index a8417755c863..934194a318f6 100644 --- a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/DataFusionClient.java +++ b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/DataFusionClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -30,7 +31,6 @@ import com.google.cloud.datafusion.v1.stub.DataFusionStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -106,13 +106,28 @@ * DataFusionClient dataFusionClient = DataFusionClient.create(dataFusionSettings); * } * + *

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.
+ * DataFusionSettings dataFusionSettings =
+ *     DataFusionSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             DataFusionSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * DataFusionClient dataFusionClient = DataFusionClient.create(dataFusionSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class DataFusionClient implements BackgroundResource { private final DataFusionSettings settings; private final DataFusionStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of DataFusionClient with default settings. */ public static final DataFusionClient create() throws IOException { @@ -142,13 +157,17 @@ public static final DataFusionClient create(DataFusionStub stub) { protected DataFusionClient(DataFusionSettings settings) throws IOException { this.settings = settings; this.stub = ((DataFusionStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected DataFusionClient(DataFusionStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final DataFusionSettings getSettings() { @@ -163,10 +182,18 @@ public DataFusionStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists possible versions for Data Fusion instances in the specified project and location. diff --git a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/DataFusionSettings.java b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/DataFusionSettings.java index 390727a697c2..c7431eab9bbe 100644 --- a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/DataFusionSettings.java +++ b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/DataFusionSettings.java @@ -24,6 +24,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; @@ -162,11 +163,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return DataFusionStubSettings.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 DataFusionStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return DataFusionStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return DataFusionStubSettings.defaultTransportChannelProvider(); } @@ -176,11 +184,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return DataFusionStubSettings.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); @@ -218,6 +232,11 @@ private static Builder createDefault() { return new Builder(DataFusionStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(DataFusionStubSettings.newHttpJsonBuilder()); + } + public DataFusionStubSettings.Builder getStubSettingsBuilder() { return ((DataFusionStubSettings.Builder) getStubSettings()); } diff --git a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/stub/DataFusionStub.java b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/stub/DataFusionStub.java index d7b962759797..55745ad45837 100644 --- a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/stub/DataFusionStub.java +++ b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/stub/DataFusionStub.java @@ -48,7 +48,11 @@ public abstract class DataFusionStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/stub/DataFusionStubSettings.java b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/stub/DataFusionStubSettings.java index 06d5041d9458..5f43780988b2 100644 --- a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/stub/DataFusionStubSettings.java +++ b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/stub/DataFusionStubSettings.java @@ -29,6 +29,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -315,6 +318,11 @@ public DataFusionStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcDataFusionStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonDataFusionStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -347,18 +355,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(DataFusionStubSettings.class)) @@ -366,11 +381,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(DataFusionStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DataFusionStubSettings.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); @@ -523,6 +557,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 .listAvailableVersionsSettings() diff --git a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/stub/HttpJsonDataFusionCallableFactory.java b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/stub/HttpJsonDataFusionCallableFactory.java new file mode 100644 index 000000000000..9dd1682fb58c --- /dev/null +++ b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/stub/HttpJsonDataFusionCallableFactory.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.datafusion.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the DataFusion service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonDataFusionCallableFactory + 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-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/stub/HttpJsonDataFusionStub.java b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/stub/HttpJsonDataFusionStub.java new file mode 100644 index 000000000000..5d409d58aad8 --- /dev/null +++ b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1/stub/HttpJsonDataFusionStub.java @@ -0,0 +1,629 @@ +/* + * 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.datafusion.v1.stub; + +import static com.google.cloud.datafusion.v1.DataFusionClient.ListAvailableVersionsPagedResponse; +import static com.google.cloud.datafusion.v1.DataFusionClient.ListInstancesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.datafusion.v1.CreateInstanceRequest; +import com.google.cloud.datafusion.v1.DeleteInstanceRequest; +import com.google.cloud.datafusion.v1.GetInstanceRequest; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.ListAvailableVersionsRequest; +import com.google.cloud.datafusion.v1.ListAvailableVersionsResponse; +import com.google.cloud.datafusion.v1.ListInstancesRequest; +import com.google.cloud.datafusion.v1.ListInstancesResponse; +import com.google.cloud.datafusion.v1.OperationMetadata; +import com.google.cloud.datafusion.v1.RestartInstanceRequest; +import com.google.cloud.datafusion.v1.UpdateInstanceRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the DataFusion service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonDataFusionStub extends DataFusionStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(Instance.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor< + ListAvailableVersionsRequest, ListAvailableVersionsResponse> + listAvailableVersionsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.datafusion.v1.DataFusion/ListAvailableVersions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/versions", + 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, "latestPatchOnly", request.getLatestPatchOnly()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListAvailableVersionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listInstancesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1.DataFusion/ListInstances") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/instances", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListInstancesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1.DataFusion/GetInstance") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/instances/*}", + 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(Instance.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1.DataFusion/CreateInstance") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/instances", + 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, "instanceId", request.getInstanceId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("instance", request.getInstance())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1.DataFusion/DeleteInstance") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/instances/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1.DataFusion/UpdateInstance") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{instance.name=projects/*/locations/*/instances/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "instance.name", request.getInstance().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("instance", request.getInstance())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + restartInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1.DataFusion/RestartInstance") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/instances/*}:restart", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RestartInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable + listAvailableVersionsCallable; + private final UnaryCallable + listAvailableVersionsPagedCallable; + private final UnaryCallable listInstancesCallable; + private final UnaryCallable + listInstancesPagedCallable; + private final UnaryCallable getInstanceCallable; + private final UnaryCallable createInstanceCallable; + private final OperationCallable + createInstanceOperationCallable; + private final UnaryCallable deleteInstanceCallable; + private final OperationCallable + deleteInstanceOperationCallable; + private final UnaryCallable updateInstanceCallable; + private final OperationCallable + updateInstanceOperationCallable; + private final UnaryCallable restartInstanceCallable; + private final OperationCallable + restartInstanceOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonDataFusionStub create(DataFusionStubSettings settings) + throws IOException { + return new HttpJsonDataFusionStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonDataFusionStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonDataFusionStub( + DataFusionStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonDataFusionStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonDataFusionStub( + DataFusionStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonDataFusionStub, 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 HttpJsonDataFusionStub(DataFusionStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonDataFusionCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonDataFusionStub, 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 HttpJsonDataFusionStub( + DataFusionStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listAvailableVersionsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listAvailableVersionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listInstancesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listInstancesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings restartInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(restartInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listAvailableVersionsCallable = + callableFactory.createUnaryCallable( + listAvailableVersionsTransportSettings, + settings.listAvailableVersionsSettings(), + clientContext); + this.listAvailableVersionsPagedCallable = + callableFactory.createPagedCallable( + listAvailableVersionsTransportSettings, + settings.listAvailableVersionsSettings(), + clientContext); + this.listInstancesCallable = + callableFactory.createUnaryCallable( + listInstancesTransportSettings, settings.listInstancesSettings(), clientContext); + this.listInstancesPagedCallable = + callableFactory.createPagedCallable( + listInstancesTransportSettings, settings.listInstancesSettings(), clientContext); + this.getInstanceCallable = + callableFactory.createUnaryCallable( + getInstanceTransportSettings, settings.getInstanceSettings(), clientContext); + this.createInstanceCallable = + callableFactory.createUnaryCallable( + createInstanceTransportSettings, settings.createInstanceSettings(), clientContext); + this.createInstanceOperationCallable = + callableFactory.createOperationCallable( + createInstanceTransportSettings, + settings.createInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteInstanceCallable = + callableFactory.createUnaryCallable( + deleteInstanceTransportSettings, settings.deleteInstanceSettings(), clientContext); + this.deleteInstanceOperationCallable = + callableFactory.createOperationCallable( + deleteInstanceTransportSettings, + settings.deleteInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateInstanceCallable = + callableFactory.createUnaryCallable( + updateInstanceTransportSettings, settings.updateInstanceSettings(), clientContext); + this.updateInstanceOperationCallable = + callableFactory.createOperationCallable( + updateInstanceTransportSettings, + settings.updateInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.restartInstanceCallable = + callableFactory.createUnaryCallable( + restartInstanceTransportSettings, settings.restartInstanceSettings(), clientContext); + this.restartInstanceOperationCallable = + callableFactory.createOperationCallable( + restartInstanceTransportSettings, + settings.restartInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listAvailableVersionsMethodDescriptor); + methodDescriptors.add(listInstancesMethodDescriptor); + methodDescriptors.add(getInstanceMethodDescriptor); + methodDescriptors.add(createInstanceMethodDescriptor); + methodDescriptors.add(deleteInstanceMethodDescriptor); + methodDescriptors.add(updateInstanceMethodDescriptor); + methodDescriptors.add(restartInstanceMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + listAvailableVersionsCallable() { + return listAvailableVersionsCallable; + } + + @Override + public UnaryCallable + listAvailableVersionsPagedCallable() { + return listAvailableVersionsPagedCallable; + } + + @Override + public UnaryCallable listInstancesCallable() { + return listInstancesCallable; + } + + @Override + public UnaryCallable + listInstancesPagedCallable() { + return listInstancesPagedCallable; + } + + @Override + public UnaryCallable getInstanceCallable() { + return getInstanceCallable; + } + + @Override + public UnaryCallable createInstanceCallable() { + return createInstanceCallable; + } + + @Override + public OperationCallable + createInstanceOperationCallable() { + return createInstanceOperationCallable; + } + + @Override + public UnaryCallable deleteInstanceCallable() { + return deleteInstanceCallable; + } + + @Override + public OperationCallable + deleteInstanceOperationCallable() { + return deleteInstanceOperationCallable; + } + + @Override + public UnaryCallable updateInstanceCallable() { + return updateInstanceCallable; + } + + @Override + public OperationCallable + updateInstanceOperationCallable() { + return updateInstanceOperationCallable; + } + + @Override + public UnaryCallable restartInstanceCallable() { + return restartInstanceCallable; + } + + @Override + public OperationCallable + restartInstanceOperationCallable() { + return restartInstanceOperationCallable; + } + + @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-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/DataFusionClient.java b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/DataFusionClient.java index b08292368ceb..b243e91b1ef0 100644 --- a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/DataFusionClient.java +++ b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/DataFusionClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.datafusion.v1beta1.stub.DataFusionStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -107,6 +107,20 @@ * DataFusionClient dataFusionClient = DataFusionClient.create(dataFusionSettings); * } * + *

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.
+ * DataFusionSettings dataFusionSettings =
+ *     DataFusionSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             DataFusionSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * DataFusionClient dataFusionClient = DataFusionClient.create(dataFusionSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -114,7 +128,8 @@ public class DataFusionClient implements BackgroundResource { private final DataFusionSettings settings; private final DataFusionStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of DataFusionClient with default settings. */ public static final DataFusionClient create() throws IOException { @@ -144,13 +159,17 @@ public static final DataFusionClient create(DataFusionStub stub) { protected DataFusionClient(DataFusionSettings settings) throws IOException { this.settings = settings; this.stub = ((DataFusionStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected DataFusionClient(DataFusionStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final DataFusionSettings getSettings() { @@ -165,10 +184,18 @@ public DataFusionStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists possible versions for Data Fusion instances in the specified project and location. diff --git a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/DataFusionSettings.java b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/DataFusionSettings.java index 6e7f9b41bb99..b918f4c946ae 100644 --- a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/DataFusionSettings.java +++ b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/DataFusionSettings.java @@ -26,6 +26,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; @@ -207,11 +208,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return DataFusionStubSettings.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 DataFusionStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return DataFusionStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return DataFusionStubSettings.defaultTransportChannelProvider(); } @@ -221,11 +229,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return DataFusionStubSettings.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); @@ -263,6 +277,11 @@ private static Builder createDefault() { return new Builder(DataFusionStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(DataFusionStubSettings.newHttpJsonBuilder()); + } + public DataFusionStubSettings.Builder getStubSettingsBuilder() { return ((DataFusionStubSettings.Builder) getStubSettings()); } diff --git a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/stub/DataFusionStub.java b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/stub/DataFusionStub.java index 9e8c419ccbad..0504a1d61ec7 100644 --- a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/stub/DataFusionStub.java +++ b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/stub/DataFusionStub.java @@ -63,7 +63,11 @@ public abstract class DataFusionStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/stub/DataFusionStubSettings.java b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/stub/DataFusionStubSettings.java index b3a9f02b2944..c8797b46c982 100644 --- a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/stub/DataFusionStubSettings.java +++ b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/stub/DataFusionStubSettings.java @@ -31,6 +31,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -498,6 +501,11 @@ public DataFusionStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcDataFusionStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonDataFusionStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -530,18 +538,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(DataFusionStubSettings.class)) @@ -549,11 +564,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(DataFusionStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DataFusionStubSettings.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); @@ -755,6 +789,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 .listAvailableVersionsSettings() diff --git a/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/stub/HttpJsonDataFusionCallableFactory.java b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/stub/HttpJsonDataFusionCallableFactory.java new file mode 100644 index 000000000000..d56714e01412 --- /dev/null +++ b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/stub/HttpJsonDataFusionCallableFactory.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.datafusion.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 DataFusion service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonDataFusionCallableFactory + 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-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/stub/HttpJsonDataFusionStub.java b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/stub/HttpJsonDataFusionStub.java new file mode 100644 index 000000000000..d992c86c10b5 --- /dev/null +++ b/java-data-fusion/google-cloud-data-fusion/src/main/java/com/google/cloud/datafusion/v1beta1/stub/HttpJsonDataFusionStub.java @@ -0,0 +1,995 @@ +/* + * 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.datafusion.v1beta1.stub; + +import static com.google.cloud.datafusion.v1beta1.DataFusionClient.ListAvailableVersionsPagedResponse; +import static com.google.cloud.datafusion.v1beta1.DataFusionClient.ListDnsPeeringsPagedResponse; +import static com.google.cloud.datafusion.v1beta1.DataFusionClient.ListInstancesPagedResponse; +import static com.google.cloud.datafusion.v1beta1.DataFusionClient.ListNamespacesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.datafusion.v1beta1.AddDnsPeeringRequest; +import com.google.cloud.datafusion.v1beta1.AddDnsPeeringResponse; +import com.google.cloud.datafusion.v1beta1.CreateInstanceRequest; +import com.google.cloud.datafusion.v1beta1.DeleteInstanceRequest; +import com.google.cloud.datafusion.v1beta1.GetInstanceRequest; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.ListAvailableVersionsRequest; +import com.google.cloud.datafusion.v1beta1.ListAvailableVersionsResponse; +import com.google.cloud.datafusion.v1beta1.ListDnsPeeringsRequest; +import com.google.cloud.datafusion.v1beta1.ListDnsPeeringsResponse; +import com.google.cloud.datafusion.v1beta1.ListInstancesRequest; +import com.google.cloud.datafusion.v1beta1.ListInstancesResponse; +import com.google.cloud.datafusion.v1beta1.ListNamespacesRequest; +import com.google.cloud.datafusion.v1beta1.ListNamespacesResponse; +import com.google.cloud.datafusion.v1beta1.OperationMetadata; +import com.google.cloud.datafusion.v1beta1.RemoveDnsPeeringRequest; +import com.google.cloud.datafusion.v1beta1.RemoveDnsPeeringResponse; +import com.google.cloud.datafusion.v1beta1.RemoveIamPolicyRequest; +import com.google.cloud.datafusion.v1beta1.RemoveIamPolicyResponse; +import com.google.cloud.datafusion.v1beta1.RestartInstanceRequest; +import com.google.cloud.datafusion.v1beta1.UpdateInstanceRequest; +import com.google.cloud.datafusion.v1beta1.UpgradeInstanceRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the DataFusion service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonDataFusionStub extends DataFusionStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(Instance.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor< + ListAvailableVersionsRequest, ListAvailableVersionsResponse> + listAvailableVersionsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.datafusion.v1beta1.DataFusion/ListAvailableVersions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/versions", + 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, "latestPatchOnly", request.getLatestPatchOnly()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListAvailableVersionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listInstancesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1beta1.DataFusion/ListInstances") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/instances", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListInstancesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1beta1.DataFusion/GetInstance") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/instances/*}", + 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(Instance.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1beta1.DataFusion/CreateInstance") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/instances", + 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, "instanceId", request.getInstanceId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("instance", request.getInstance())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1beta1.DataFusion/DeleteInstance") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/instances/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1beta1.DataFusion/UpdateInstance") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{instance.name=projects/*/locations/*/instances/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "instance.name", request.getInstance().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("instance", request.getInstance())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + restartInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1beta1.DataFusion/RestartInstance") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/instances/*}:restart", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RestartInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + upgradeInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1beta1.DataFusion/UpgradeInstance") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/instances/*}:upgrade", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpgradeInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + removeIamPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1beta1.DataFusion/RemoveIamPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{resource=projects/*/locations/*/**}:removeIamPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + }) + .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(RemoveIamPolicyResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listNamespacesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1beta1.DataFusion/ListNamespaces") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*/instances/*}/namespaces", + 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()); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListNamespacesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + addDnsPeeringMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1beta1.DataFusion/AddDnsPeering") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*/instances/*}/dnsPeerings:add", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AddDnsPeeringResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + removeDnsPeeringMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1beta1.DataFusion/RemoveDnsPeering") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*/instances/*}/dnsPeerings:remove", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(RemoveDnsPeeringResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listDnsPeeringsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.datafusion.v1beta1.DataFusion/ListDnsPeerings") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*/instances/*}/dnsPeerings:list", + 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(ListDnsPeeringsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + listAvailableVersionsCallable; + private final UnaryCallable + listAvailableVersionsPagedCallable; + private final UnaryCallable listInstancesCallable; + private final UnaryCallable + listInstancesPagedCallable; + private final UnaryCallable getInstanceCallable; + private final UnaryCallable createInstanceCallable; + private final OperationCallable + createInstanceOperationCallable; + private final UnaryCallable deleteInstanceCallable; + private final OperationCallable + deleteInstanceOperationCallable; + private final UnaryCallable updateInstanceCallable; + private final OperationCallable + updateInstanceOperationCallable; + private final UnaryCallable restartInstanceCallable; + private final OperationCallable + restartInstanceOperationCallable; + private final UnaryCallable upgradeInstanceCallable; + private final OperationCallable + upgradeInstanceOperationCallable; + private final UnaryCallable + removeIamPolicyCallable; + private final UnaryCallable listNamespacesCallable; + private final UnaryCallable + listNamespacesPagedCallable; + private final UnaryCallable addDnsPeeringCallable; + private final UnaryCallable + removeDnsPeeringCallable; + private final UnaryCallable + listDnsPeeringsCallable; + private final UnaryCallable + listDnsPeeringsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonDataFusionStub create(DataFusionStubSettings settings) + throws IOException { + return new HttpJsonDataFusionStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonDataFusionStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonDataFusionStub( + DataFusionStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonDataFusionStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonDataFusionStub( + DataFusionStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonDataFusionStub, 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 HttpJsonDataFusionStub(DataFusionStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonDataFusionCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonDataFusionStub, 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 HttpJsonDataFusionStub( + DataFusionStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listAvailableVersionsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listAvailableVersionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listInstancesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listInstancesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings restartInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(restartInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings upgradeInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(upgradeInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeIamPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeIamPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listNamespacesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listNamespacesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + addDnsPeeringTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addDnsPeeringMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + removeDnsPeeringTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removeDnsPeeringMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listDnsPeeringsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listDnsPeeringsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listAvailableVersionsCallable = + callableFactory.createUnaryCallable( + listAvailableVersionsTransportSettings, + settings.listAvailableVersionsSettings(), + clientContext); + this.listAvailableVersionsPagedCallable = + callableFactory.createPagedCallable( + listAvailableVersionsTransportSettings, + settings.listAvailableVersionsSettings(), + clientContext); + this.listInstancesCallable = + callableFactory.createUnaryCallable( + listInstancesTransportSettings, settings.listInstancesSettings(), clientContext); + this.listInstancesPagedCallable = + callableFactory.createPagedCallable( + listInstancesTransportSettings, settings.listInstancesSettings(), clientContext); + this.getInstanceCallable = + callableFactory.createUnaryCallable( + getInstanceTransportSettings, settings.getInstanceSettings(), clientContext); + this.createInstanceCallable = + callableFactory.createUnaryCallable( + createInstanceTransportSettings, settings.createInstanceSettings(), clientContext); + this.createInstanceOperationCallable = + callableFactory.createOperationCallable( + createInstanceTransportSettings, + settings.createInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteInstanceCallable = + callableFactory.createUnaryCallable( + deleteInstanceTransportSettings, settings.deleteInstanceSettings(), clientContext); + this.deleteInstanceOperationCallable = + callableFactory.createOperationCallable( + deleteInstanceTransportSettings, + settings.deleteInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateInstanceCallable = + callableFactory.createUnaryCallable( + updateInstanceTransportSettings, settings.updateInstanceSettings(), clientContext); + this.updateInstanceOperationCallable = + callableFactory.createOperationCallable( + updateInstanceTransportSettings, + settings.updateInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.restartInstanceCallable = + callableFactory.createUnaryCallable( + restartInstanceTransportSettings, settings.restartInstanceSettings(), clientContext); + this.restartInstanceOperationCallable = + callableFactory.createOperationCallable( + restartInstanceTransportSettings, + settings.restartInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.upgradeInstanceCallable = + callableFactory.createUnaryCallable( + upgradeInstanceTransportSettings, settings.upgradeInstanceSettings(), clientContext); + this.upgradeInstanceOperationCallable = + callableFactory.createOperationCallable( + upgradeInstanceTransportSettings, + settings.upgradeInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.removeIamPolicyCallable = + callableFactory.createUnaryCallable( + removeIamPolicyTransportSettings, settings.removeIamPolicySettings(), clientContext); + this.listNamespacesCallable = + callableFactory.createUnaryCallable( + listNamespacesTransportSettings, settings.listNamespacesSettings(), clientContext); + this.listNamespacesPagedCallable = + callableFactory.createPagedCallable( + listNamespacesTransportSettings, settings.listNamespacesSettings(), clientContext); + this.addDnsPeeringCallable = + callableFactory.createUnaryCallable( + addDnsPeeringTransportSettings, settings.addDnsPeeringSettings(), clientContext); + this.removeDnsPeeringCallable = + callableFactory.createUnaryCallable( + removeDnsPeeringTransportSettings, settings.removeDnsPeeringSettings(), clientContext); + this.listDnsPeeringsCallable = + callableFactory.createUnaryCallable( + listDnsPeeringsTransportSettings, settings.listDnsPeeringsSettings(), clientContext); + this.listDnsPeeringsPagedCallable = + callableFactory.createPagedCallable( + listDnsPeeringsTransportSettings, settings.listDnsPeeringsSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listAvailableVersionsMethodDescriptor); + methodDescriptors.add(listInstancesMethodDescriptor); + methodDescriptors.add(getInstanceMethodDescriptor); + methodDescriptors.add(createInstanceMethodDescriptor); + methodDescriptors.add(deleteInstanceMethodDescriptor); + methodDescriptors.add(updateInstanceMethodDescriptor); + methodDescriptors.add(restartInstanceMethodDescriptor); + methodDescriptors.add(upgradeInstanceMethodDescriptor); + methodDescriptors.add(removeIamPolicyMethodDescriptor); + methodDescriptors.add(listNamespacesMethodDescriptor); + methodDescriptors.add(addDnsPeeringMethodDescriptor); + methodDescriptors.add(removeDnsPeeringMethodDescriptor); + methodDescriptors.add(listDnsPeeringsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + listAvailableVersionsCallable() { + return listAvailableVersionsCallable; + } + + @Override + public UnaryCallable + listAvailableVersionsPagedCallable() { + return listAvailableVersionsPagedCallable; + } + + @Override + public UnaryCallable listInstancesCallable() { + return listInstancesCallable; + } + + @Override + public UnaryCallable + listInstancesPagedCallable() { + return listInstancesPagedCallable; + } + + @Override + public UnaryCallable getInstanceCallable() { + return getInstanceCallable; + } + + @Override + public UnaryCallable createInstanceCallable() { + return createInstanceCallable; + } + + @Override + public OperationCallable + createInstanceOperationCallable() { + return createInstanceOperationCallable; + } + + @Override + public UnaryCallable deleteInstanceCallable() { + return deleteInstanceCallable; + } + + @Override + public OperationCallable + deleteInstanceOperationCallable() { + return deleteInstanceOperationCallable; + } + + @Override + public UnaryCallable updateInstanceCallable() { + return updateInstanceCallable; + } + + @Override + public OperationCallable + updateInstanceOperationCallable() { + return updateInstanceOperationCallable; + } + + @Override + public UnaryCallable restartInstanceCallable() { + return restartInstanceCallable; + } + + @Override + public OperationCallable + restartInstanceOperationCallable() { + return restartInstanceOperationCallable; + } + + @Override + public UnaryCallable upgradeInstanceCallable() { + return upgradeInstanceCallable; + } + + @Override + public OperationCallable + upgradeInstanceOperationCallable() { + return upgradeInstanceOperationCallable; + } + + @Override + public UnaryCallable removeIamPolicyCallable() { + return removeIamPolicyCallable; + } + + @Override + public UnaryCallable listNamespacesCallable() { + return listNamespacesCallable; + } + + @Override + public UnaryCallable + listNamespacesPagedCallable() { + return listNamespacesPagedCallable; + } + + @Override + public UnaryCallable addDnsPeeringCallable() { + return addDnsPeeringCallable; + } + + @Override + public UnaryCallable + removeDnsPeeringCallable() { + return removeDnsPeeringCallable; + } + + @Override + public UnaryCallable listDnsPeeringsCallable() { + return listDnsPeeringsCallable; + } + + @Override + public UnaryCallable + listDnsPeeringsPagedCallable() { + return listDnsPeeringsPagedCallable; + } + + @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-data-fusion/google-cloud-data-fusion/src/test/java/com/google/cloud/datafusion/v1/DataFusionClientHttpJsonTest.java b/java-data-fusion/google-cloud-data-fusion/src/test/java/com/google/cloud/datafusion/v1/DataFusionClientHttpJsonTest.java new file mode 100644 index 000000000000..e31a6e9a70ec --- /dev/null +++ b/java-data-fusion/google-cloud-data-fusion/src/test/java/com/google/cloud/datafusion/v1/DataFusionClientHttpJsonTest.java @@ -0,0 +1,782 @@ +/* + * 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.datafusion.v1; + +import static com.google.cloud.datafusion.v1.DataFusionClient.ListAvailableVersionsPagedResponse; +import static com.google.cloud.datafusion.v1.DataFusionClient.ListInstancesPagedResponse; + +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.datafusion.v1.stub.HttpJsonDataFusionStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class DataFusionClientHttpJsonTest { + private static MockHttpService mockService; + private static DataFusionClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonDataFusionStub.getMethodDescriptors(), DataFusionSettings.getDefaultEndpoint()); + DataFusionSettings settings = + DataFusionSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + DataFusionSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DataFusionClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listAvailableVersionsTest() throws Exception { + Version responsesElement = Version.newBuilder().build(); + ListAvailableVersionsResponse expectedResponse = + ListAvailableVersionsResponse.newBuilder() + .setNextPageToken("") + .addAllAvailableVersions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListAvailableVersionsPagedResponse pagedListResponse = client.listAvailableVersions(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getAvailableVersionsList().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 listAvailableVersionsExceptionTest() 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.listAvailableVersions(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAvailableVersionsTest2() throws Exception { + Version responsesElement = Version.newBuilder().build(); + ListAvailableVersionsResponse expectedResponse = + ListAvailableVersionsResponse.newBuilder() + .setNextPageToken("") + .addAllAvailableVersions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListAvailableVersionsPagedResponse pagedListResponse = client.listAvailableVersions(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getAvailableVersionsList().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 listAvailableVersionsExceptionTest2() 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.listAvailableVersions(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInstancesTest() throws Exception { + Instance responsesElement = Instance.newBuilder().build(); + ListInstancesResponse expectedResponse = + ListInstancesResponse.newBuilder() + .setNextPageToken("") + .addAllInstances(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + + ListInstancesPagedResponse pagedListResponse = client.listInstances(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInstancesList().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 listInstancesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + client.listInstances(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + GetInstanceRequest request = + GetInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + + Instance actualResponse = client.getInstance(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 getInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetInstanceRequest request = + GetInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + client.getInstance(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + + Instance actualResponse = client.createInstanceAsync(parent, instance, instanceId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createInstanceExceptionTest() 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]"); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + client.createInstanceAsync(parent, instance, instanceId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createInstanceTest2() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + + Instance actualResponse = client.createInstanceAsync(parent, instance, instanceId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createInstanceExceptionTest2() 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"; + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + client.createInstanceAsync(parent, instance, instanceId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteInstanceTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + client.deleteInstanceAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.deleteInstanceAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteInstanceTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-9412/locations/location-9412/instances/instance-9412"; + + client.deleteInstanceAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteInstanceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9412/locations/location-9412/instances/instance-9412"; + client.deleteInstanceAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Instance instance = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Instance actualResponse = client.updateInstanceAsync(instance, updateMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Instance instance = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateInstanceAsync(instance, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void restartInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("restartInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RestartInstanceRequest request = + RestartInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + + Instance actualResponse = client.restartInstanceAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void restartInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestartInstanceRequest request = + RestartInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + client.restartInstanceAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-data-fusion/google-cloud-data-fusion/src/test/java/com/google/cloud/datafusion/v1beta1/DataFusionClientHttpJsonTest.java b/java-data-fusion/google-cloud-data-fusion/src/test/java/com/google/cloud/datafusion/v1beta1/DataFusionClientHttpJsonTest.java new file mode 100644 index 000000000000..df0dfcf8cb56 --- /dev/null +++ b/java-data-fusion/google-cloud-data-fusion/src/test/java/com/google/cloud/datafusion/v1beta1/DataFusionClientHttpJsonTest.java @@ -0,0 +1,1275 @@ +/* + * 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.datafusion.v1beta1; + +import static com.google.cloud.datafusion.v1beta1.DataFusionClient.ListAvailableVersionsPagedResponse; +import static com.google.cloud.datafusion.v1beta1.DataFusionClient.ListDnsPeeringsPagedResponse; +import static com.google.cloud.datafusion.v1beta1.DataFusionClient.ListInstancesPagedResponse; +import static com.google.cloud.datafusion.v1beta1.DataFusionClient.ListNamespacesPagedResponse; + +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.datafusion.v1beta1.stub.HttpJsonDataFusionStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class DataFusionClientHttpJsonTest { + private static MockHttpService mockService; + private static DataFusionClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonDataFusionStub.getMethodDescriptors(), DataFusionSettings.getDefaultEndpoint()); + DataFusionSettings settings = + DataFusionSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + DataFusionSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DataFusionClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listAvailableVersionsTest() throws Exception { + Version responsesElement = Version.newBuilder().build(); + ListAvailableVersionsResponse expectedResponse = + ListAvailableVersionsResponse.newBuilder() + .setNextPageToken("") + .addAllAvailableVersions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListAvailableVersionsPagedResponse pagedListResponse = client.listAvailableVersions(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getAvailableVersionsList().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 listAvailableVersionsExceptionTest() 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.listAvailableVersions(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listAvailableVersionsTest2() throws Exception { + Version responsesElement = Version.newBuilder().build(); + ListAvailableVersionsResponse expectedResponse = + ListAvailableVersionsResponse.newBuilder() + .setNextPageToken("") + .addAllAvailableVersions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListAvailableVersionsPagedResponse pagedListResponse = client.listAvailableVersions(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getAvailableVersionsList().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 listAvailableVersionsExceptionTest2() 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.listAvailableVersions(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInstancesTest() throws Exception { + Instance responsesElement = Instance.newBuilder().build(); + ListInstancesResponse expectedResponse = + ListInstancesResponse.newBuilder() + .setNextPageToken("") + .addAllInstances(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + + ListInstancesPagedResponse pagedListResponse = client.listInstances(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInstancesList().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 listInstancesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + client.listInstances(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + GetInstanceRequest request = + GetInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + + Instance actualResponse = client.getInstance(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 getInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetInstanceRequest request = + GetInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + client.getInstance(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + + Instance actualResponse = client.createInstanceAsync(parent, instance, instanceId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createInstanceExceptionTest() 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]"); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + client.createInstanceAsync(parent, instance, instanceId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createInstanceTest2() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + + Instance actualResponse = client.createInstanceAsync(parent, instance, instanceId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createInstanceExceptionTest2() 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"; + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + client.createInstanceAsync(parent, instance, instanceId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteInstanceTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + client.deleteInstanceAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.deleteInstanceAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteInstanceTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-9412/locations/location-9412/instances/instance-9412"; + + client.deleteInstanceAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteInstanceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9412/locations/location-9412/instances/instance-9412"; + client.deleteInstanceAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Instance instance = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Instance actualResponse = client.updateInstanceAsync(instance, updateMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Instance instance = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateInstanceAsync(instance, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void restartInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("restartInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RestartInstanceRequest request = + RestartInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + + Instance actualResponse = client.restartInstanceAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void restartInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestartInstanceRequest request = + RestartInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + client.restartInstanceAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void upgradeInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setEnableStackdriverLogging(true) + .setEnableStackdriverMonitoring(true) + .setPrivateInstance(true) + .setNetworkConfig(NetworkConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .putAllOptions(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setServiceEndpoint("serviceEndpoint-1323187350") + .setZone("zone3744684") + .setVersion("version351608024") + .setServiceAccount("serviceAccount1079137720") + .setDisplayName("displayName1714148973") + .addAllAvailableVersion(new ArrayList()) + .setApiEndpoint("apiEndpoint-2038677041") + .setGcsBucket("gcsBucket239654881") + .addAllAccelerators(new ArrayList()) + .setP4ServiceAccount("p4ServiceAccount-184825700") + .setTenantProjectId("tenantProjectId674318474") + .setDataprocServiceAccount("dataprocServiceAccount-1287630888") + .setEnableRbac(true) + .setCryptoKeyConfig(CryptoKeyConfig.newBuilder().build()) + .addAllDisabledReason(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("upgradeInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + UpgradeInstanceRequest request = + UpgradeInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + + Instance actualResponse = client.upgradeInstanceAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void upgradeInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpgradeInstanceRequest request = + UpgradeInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + client.upgradeInstanceAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removeIamPolicyTest() throws Exception { + RemoveIamPolicyResponse expectedResponse = RemoveIamPolicyResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + RemoveIamPolicyRequest request = + RemoveIamPolicyRequest.newBuilder() + .setResource("projects/project-6942/locations/location-6942/location-6942") + .build(); + + RemoveIamPolicyResponse actualResponse = client.removeIamPolicy(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 removeIamPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RemoveIamPolicyRequest request = + RemoveIamPolicyRequest.newBuilder() + .setResource("projects/project-6942/locations/location-6942/location-6942") + .build(); + client.removeIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listNamespacesTest() throws Exception { + Namespace responsesElement = Namespace.newBuilder().build(); + ListNamespacesResponse expectedResponse = + ListNamespacesResponse.newBuilder() + .setNextPageToken("") + .addAllNamespaces(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + ListNamespacesPagedResponse pagedListResponse = client.listNamespaces(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getNamespacesList().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 listNamespacesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.listNamespaces(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listNamespacesTest2() throws Exception { + Namespace responsesElement = Namespace.newBuilder().build(); + ListNamespacesResponse expectedResponse = + ListNamespacesResponse.newBuilder() + .setNextPageToken("") + .addAllNamespaces(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + + ListNamespacesPagedResponse pagedListResponse = client.listNamespaces(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getNamespacesList().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 listNamespacesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + client.listNamespaces(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addDnsPeeringTest() throws Exception { + AddDnsPeeringResponse expectedResponse = AddDnsPeeringResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + AddDnsPeeringResponse actualResponse = client.addDnsPeering(parent); + 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 addDnsPeeringExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.addDnsPeering(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void addDnsPeeringTest2() throws Exception { + AddDnsPeeringResponse expectedResponse = AddDnsPeeringResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + + AddDnsPeeringResponse actualResponse = client.addDnsPeering(parent); + 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 addDnsPeeringExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + client.addDnsPeering(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeDnsPeeringTest() throws Exception { + RemoveDnsPeeringResponse expectedResponse = RemoveDnsPeeringResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + RemoveDnsPeeringResponse actualResponse = client.removeDnsPeering(parent); + 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 removeDnsPeeringExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.removeDnsPeering(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void removeDnsPeeringTest2() throws Exception { + RemoveDnsPeeringResponse expectedResponse = RemoveDnsPeeringResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + + RemoveDnsPeeringResponse actualResponse = client.removeDnsPeering(parent); + 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 removeDnsPeeringExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + client.removeDnsPeering(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDnsPeeringsTest() throws Exception { + DnsPeering responsesElement = DnsPeering.newBuilder().build(); + ListDnsPeeringsResponse expectedResponse = + ListDnsPeeringsResponse.newBuilder() + .setNextPageToken("") + .addAllDnsPeerings(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + ListDnsPeeringsPagedResponse pagedListResponse = client.listDnsPeerings(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDnsPeeringsList().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 listDnsPeeringsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.listDnsPeerings(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDnsPeeringsTest2() throws Exception { + DnsPeering responsesElement = DnsPeering.newBuilder().build(); + ListDnsPeeringsResponse expectedResponse = + ListDnsPeeringsResponse.newBuilder() + .setNextPageToken("") + .addAllDnsPeerings(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + + ListDnsPeeringsPagedResponse pagedListResponse = client.listDnsPeerings(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDnsPeeringsList().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 listDnsPeeringsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + client.listDnsPeerings(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/create/SyncCreateSetCredentialsProvider.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..2aa77981f8e9 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.DataFusionSettings; +import com.google.cloud.datafusion.v1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DataFusionSettings dataFusionSettings = + DataFusionSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + DataFusionClient dataFusionClient = DataFusionClient.create(dataFusionSettings); + } +} +// [END datafusion_v1_generated_datafusionclient_create_setcredentialsprovider_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/create/SyncCreateSetCredentialsProvider1.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..d533915e0633 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_create_setcredentialsprovider1_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.DataFusionSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DataFusionSettings dataFusionSettings = + DataFusionSettings.newBuilder() + .setTransportChannelProvider( + DataFusionSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + DataFusionClient dataFusionClient = DataFusionClient.create(dataFusionSettings); + } +} +// [END datafusion_v1_generated_datafusionclient_create_setcredentialsprovider1_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/create/SyncCreateSetEndpoint.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..14c0ee84c481 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_create_setendpoint_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.DataFusionSettings; +import com.google.cloud.datafusion.v1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DataFusionSettings dataFusionSettings = + DataFusionSettings.newBuilder().setEndpoint(myEndpoint).build(); + DataFusionClient dataFusionClient = DataFusionClient.create(dataFusionSettings); + } +} +// [END datafusion_v1_generated_datafusionclient_create_setendpoint_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/AsyncCreateInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/AsyncCreateInstance.java new file mode 100644 index 000000000000..c3c3aa7601c0 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/AsyncCreateInstance.java @@ -0,0 +1,49 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_createinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1.CreateInstanceRequest; +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.LocationName; +import com.google.longrunning.Operation; + +public class AsyncCreateInstance { + + public static void main(String[] args) throws Exception { + asyncCreateInstance(); + } + + public static void asyncCreateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + CreateInstanceRequest request = + CreateInstanceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInstanceId("instanceId902024336") + .setInstance(Instance.newBuilder().build()) + .build(); + ApiFuture future = dataFusionClient.createInstanceCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_createinstance_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/AsyncCreateInstanceLRO.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/AsyncCreateInstanceLRO.java new file mode 100644 index 000000000000..cb9da0c88d96 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/AsyncCreateInstanceLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_createinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datafusion.v1.CreateInstanceRequest; +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.LocationName; +import com.google.cloud.datafusion.v1.OperationMetadata; + +public class AsyncCreateInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncCreateInstanceLRO(); + } + + public static void asyncCreateInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + CreateInstanceRequest request = + CreateInstanceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInstanceId("instanceId902024336") + .setInstance(Instance.newBuilder().build()) + .build(); + OperationFuture future = + dataFusionClient.createInstanceOperationCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_createinstance_lro_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/SyncCreateInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/SyncCreateInstance.java new file mode 100644 index 000000000000..9c80df49da00 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/SyncCreateInstance.java @@ -0,0 +1,45 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_createinstance_sync] +import com.google.cloud.datafusion.v1.CreateInstanceRequest; +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.LocationName; + +public class SyncCreateInstance { + + public static void main(String[] args) throws Exception { + syncCreateInstance(); + } + + public static void syncCreateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + CreateInstanceRequest request = + CreateInstanceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInstanceId("instanceId902024336") + .setInstance(Instance.newBuilder().build()) + .build(); + Instance response = dataFusionClient.createInstanceAsync(request).get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_createinstance_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/SyncCreateInstanceLocationnameInstanceString.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/SyncCreateInstanceLocationnameInstanceString.java new file mode 100644 index 000000000000..92aeb426d9b4 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/SyncCreateInstanceLocationnameInstanceString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_createinstance_locationnameinstancestring_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.LocationName; + +public class SyncCreateInstanceLocationnameInstanceString { + + public static void main(String[] args) throws Exception { + syncCreateInstanceLocationnameInstanceString(); + } + + public static void syncCreateInstanceLocationnameInstanceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + Instance response = dataFusionClient.createInstanceAsync(parent, instance, instanceId).get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_createinstance_locationnameinstancestring_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/SyncCreateInstanceStringInstanceString.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/SyncCreateInstanceStringInstanceString.java new file mode 100644 index 000000000000..6176de322d31 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/createinstance/SyncCreateInstanceStringInstanceString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_createinstance_stringinstancestring_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.LocationName; + +public class SyncCreateInstanceStringInstanceString { + + public static void main(String[] args) throws Exception { + syncCreateInstanceStringInstanceString(); + } + + public static void syncCreateInstanceStringInstanceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + Instance response = dataFusionClient.createInstanceAsync(parent, instance, instanceId).get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_createinstance_stringinstancestring_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/AsyncDeleteInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/AsyncDeleteInstance.java new file mode 100644 index 000000000000..1e43227f8f2a --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/AsyncDeleteInstance.java @@ -0,0 +1,46 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_deleteinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.DeleteInstanceRequest; +import com.google.cloud.datafusion.v1.InstanceName; +import com.google.longrunning.Operation; + +public class AsyncDeleteInstance { + + public static void main(String[] args) throws Exception { + asyncDeleteInstance(); + } + + public static void asyncDeleteInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + DeleteInstanceRequest request = + DeleteInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = dataFusionClient.deleteInstanceCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_deleteinstance_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/AsyncDeleteInstanceLRO.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/AsyncDeleteInstanceLRO.java new file mode 100644 index 000000000000..7dd550f386b3 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/AsyncDeleteInstanceLRO.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_deleteinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.DeleteInstanceRequest; +import com.google.cloud.datafusion.v1.InstanceName; +import com.google.cloud.datafusion.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteInstanceLRO(); + } + + public static void asyncDeleteInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + DeleteInstanceRequest request = + DeleteInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + OperationFuture future = + dataFusionClient.deleteInstanceOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_deleteinstance_lro_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/SyncDeleteInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/SyncDeleteInstance.java new file mode 100644 index 000000000000..64e01bb0c6dc --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/SyncDeleteInstance.java @@ -0,0 +1,42 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_deleteinstance_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.DeleteInstanceRequest; +import com.google.cloud.datafusion.v1.InstanceName; + +public class SyncDeleteInstance { + + public static void main(String[] args) throws Exception { + syncDeleteInstance(); + } + + public static void syncDeleteInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + DeleteInstanceRequest request = + DeleteInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + dataFusionClient.deleteInstanceAsync(request).get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_deleteinstance_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/SyncDeleteInstanceInstancename.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/SyncDeleteInstanceInstancename.java new file mode 100644 index 000000000000..97cee12e15e3 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/SyncDeleteInstanceInstancename.java @@ -0,0 +1,38 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_deleteinstance_instancename_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.InstanceName; + +public class SyncDeleteInstanceInstancename { + + public static void main(String[] args) throws Exception { + syncDeleteInstanceInstancename(); + } + + public static void syncDeleteInstanceInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + dataFusionClient.deleteInstanceAsync(name).get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_deleteinstance_instancename_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/SyncDeleteInstanceString.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/SyncDeleteInstanceString.java new file mode 100644 index 000000000000..7c2d0e7802ec --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/deleteinstance/SyncDeleteInstanceString.java @@ -0,0 +1,38 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_deleteinstance_string_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.InstanceName; + +public class SyncDeleteInstanceString { + + public static void main(String[] args) throws Exception { + syncDeleteInstanceString(); + } + + public static void syncDeleteInstanceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + String name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + dataFusionClient.deleteInstanceAsync(name).get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_deleteinstance_string_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/getinstance/AsyncGetInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/getinstance/AsyncGetInstance.java new file mode 100644 index 000000000000..a9b3b0794ad2 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/getinstance/AsyncGetInstance.java @@ -0,0 +1,46 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_getinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.GetInstanceRequest; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.InstanceName; + +public class AsyncGetInstance { + + public static void main(String[] args) throws Exception { + asyncGetInstance(); + } + + public static void asyncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + GetInstanceRequest request = + GetInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = dataFusionClient.getInstanceCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_getinstance_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/getinstance/SyncGetInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/getinstance/SyncGetInstance.java new file mode 100644 index 000000000000..fa1d996975e2 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/getinstance/SyncGetInstance.java @@ -0,0 +1,43 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_getinstance_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.GetInstanceRequest; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.InstanceName; + +public class SyncGetInstance { + + public static void main(String[] args) throws Exception { + syncGetInstance(); + } + + public static void syncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + GetInstanceRequest request = + GetInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + Instance response = dataFusionClient.getInstance(request); + } + } +} +// [END datafusion_v1_generated_datafusionclient_getinstance_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/AsyncListAvailableVersions.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/AsyncListAvailableVersions.java new file mode 100644 index 000000000000..0466766aa907 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/AsyncListAvailableVersions.java @@ -0,0 +1,52 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_listavailableversions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.ListAvailableVersionsRequest; +import com.google.cloud.datafusion.v1.LocationName; +import com.google.cloud.datafusion.v1.Version; + +public class AsyncListAvailableVersions { + + public static void main(String[] args) throws Exception { + asyncListAvailableVersions(); + } + + public static void asyncListAvailableVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListAvailableVersionsRequest request = + ListAvailableVersionsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setLatestPatchOnly(true) + .build(); + ApiFuture future = + dataFusionClient.listAvailableVersionsPagedCallable().futureCall(request); + // Do something. + for (Version element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1_generated_datafusionclient_listavailableversions_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/AsyncListAvailableVersionsPaged.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/AsyncListAvailableVersionsPaged.java new file mode 100644 index 000000000000..c4b3e8591784 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/AsyncListAvailableVersionsPaged.java @@ -0,0 +1,60 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_listavailableversions_paged_async] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.ListAvailableVersionsRequest; +import com.google.cloud.datafusion.v1.ListAvailableVersionsResponse; +import com.google.cloud.datafusion.v1.LocationName; +import com.google.cloud.datafusion.v1.Version; +import com.google.common.base.Strings; + +public class AsyncListAvailableVersionsPaged { + + public static void main(String[] args) throws Exception { + asyncListAvailableVersionsPaged(); + } + + public static void asyncListAvailableVersionsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListAvailableVersionsRequest request = + ListAvailableVersionsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setLatestPatchOnly(true) + .build(); + while (true) { + ListAvailableVersionsResponse response = + dataFusionClient.listAvailableVersionsCallable().call(request); + for (Version element : response.getAvailableVersionsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datafusion_v1_generated_datafusionclient_listavailableversions_paged_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/SyncListAvailableVersions.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/SyncListAvailableVersions.java new file mode 100644 index 000000000000..fa05cf3b82a5 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/SyncListAvailableVersions.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_listavailableversions_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.ListAvailableVersionsRequest; +import com.google.cloud.datafusion.v1.LocationName; +import com.google.cloud.datafusion.v1.Version; + +public class SyncListAvailableVersions { + + public static void main(String[] args) throws Exception { + syncListAvailableVersions(); + } + + public static void syncListAvailableVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListAvailableVersionsRequest request = + ListAvailableVersionsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setLatestPatchOnly(true) + .build(); + for (Version element : dataFusionClient.listAvailableVersions(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1_generated_datafusionclient_listavailableversions_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/SyncListAvailableVersionsLocationname.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/SyncListAvailableVersionsLocationname.java new file mode 100644 index 000000000000..c4d9f90de700 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/SyncListAvailableVersionsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_listavailableversions_locationname_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.LocationName; +import com.google.cloud.datafusion.v1.Version; + +public class SyncListAvailableVersionsLocationname { + + public static void main(String[] args) throws Exception { + syncListAvailableVersionsLocationname(); + } + + public static void syncListAvailableVersionsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Version element : dataFusionClient.listAvailableVersions(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1_generated_datafusionclient_listavailableversions_locationname_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/SyncListAvailableVersionsString.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/SyncListAvailableVersionsString.java new file mode 100644 index 000000000000..db5a76431dfa --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listavailableversions/SyncListAvailableVersionsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_listavailableversions_string_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.LocationName; +import com.google.cloud.datafusion.v1.Version; + +public class SyncListAvailableVersionsString { + + public static void main(String[] args) throws Exception { + syncListAvailableVersionsString(); + } + + public static void syncListAvailableVersionsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Version element : dataFusionClient.listAvailableVersions(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1_generated_datafusionclient_listavailableversions_string_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listinstances/AsyncListInstances.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listinstances/AsyncListInstances.java new file mode 100644 index 000000000000..e20f31395d6f --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listinstances/AsyncListInstances.java @@ -0,0 +1,53 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_listinstances_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.ListInstancesRequest; +import com.google.cloud.datafusion.v1.LocationName; + +public class AsyncListInstances { + + public static void main(String[] args) throws Exception { + asyncListInstances(); + } + + public static void asyncListInstances() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + dataFusionClient.listInstancesPagedCallable().futureCall(request); + // Do something. + for (Instance element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1_generated_datafusionclient_listinstances_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listinstances/AsyncListInstancesPaged.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listinstances/AsyncListInstancesPaged.java new file mode 100644 index 000000000000..f59fb815fe9a --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listinstances/AsyncListInstancesPaged.java @@ -0,0 +1,60 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_listinstances_paged_async] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.ListInstancesRequest; +import com.google.cloud.datafusion.v1.ListInstancesResponse; +import com.google.cloud.datafusion.v1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListInstancesPaged { + + public static void main(String[] args) throws Exception { + asyncListInstancesPaged(); + } + + public static void asyncListInstancesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListInstancesResponse response = dataFusionClient.listInstancesCallable().call(request); + for (Instance element : response.getInstancesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datafusion_v1_generated_datafusionclient_listinstances_paged_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listinstances/SyncListInstances.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listinstances/SyncListInstances.java new file mode 100644 index 000000000000..9499d370c945 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/listinstances/SyncListInstances.java @@ -0,0 +1,49 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_listinstances_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.ListInstancesRequest; +import com.google.cloud.datafusion.v1.LocationName; + +public class SyncListInstances { + + public static void main(String[] args) throws Exception { + syncListInstances(); + } + + public static void syncListInstances() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Instance element : dataFusionClient.listInstances(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1_generated_datafusionclient_listinstances_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/restartinstance/AsyncRestartInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/restartinstance/AsyncRestartInstance.java new file mode 100644 index 000000000000..eb3fcb4300af --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/restartinstance/AsyncRestartInstance.java @@ -0,0 +1,46 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_restartinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.InstanceName; +import com.google.cloud.datafusion.v1.RestartInstanceRequest; +import com.google.longrunning.Operation; + +public class AsyncRestartInstance { + + public static void main(String[] args) throws Exception { + asyncRestartInstance(); + } + + public static void asyncRestartInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + RestartInstanceRequest request = + RestartInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = dataFusionClient.restartInstanceCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_restartinstance_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/restartinstance/AsyncRestartInstanceLRO.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/restartinstance/AsyncRestartInstanceLRO.java new file mode 100644 index 000000000000..4584a194971a --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/restartinstance/AsyncRestartInstanceLRO.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_restartinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.InstanceName; +import com.google.cloud.datafusion.v1.OperationMetadata; +import com.google.cloud.datafusion.v1.RestartInstanceRequest; + +public class AsyncRestartInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncRestartInstanceLRO(); + } + + public static void asyncRestartInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + RestartInstanceRequest request = + RestartInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + OperationFuture future = + dataFusionClient.restartInstanceOperationCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_restartinstance_lro_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/restartinstance/SyncRestartInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/restartinstance/SyncRestartInstance.java new file mode 100644 index 000000000000..1485ba039b78 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/restartinstance/SyncRestartInstance.java @@ -0,0 +1,43 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_restartinstance_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.InstanceName; +import com.google.cloud.datafusion.v1.RestartInstanceRequest; + +public class SyncRestartInstance { + + public static void main(String[] args) throws Exception { + syncRestartInstance(); + } + + public static void syncRestartInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + RestartInstanceRequest request = + RestartInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + Instance response = dataFusionClient.restartInstanceAsync(request).get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_restartinstance_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/updateinstance/AsyncUpdateInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/updateinstance/AsyncUpdateInstance.java new file mode 100644 index 000000000000..550090b59404 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/updateinstance/AsyncUpdateInstance.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_updateinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.UpdateInstanceRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateInstance { + + public static void main(String[] args) throws Exception { + asyncUpdateInstance(); + } + + public static void asyncUpdateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + UpdateInstanceRequest request = + UpdateInstanceRequest.newBuilder() + .setInstance(Instance.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = dataFusionClient.updateInstanceCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_updateinstance_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/updateinstance/AsyncUpdateInstanceLRO.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/updateinstance/AsyncUpdateInstanceLRO.java new file mode 100644 index 000000000000..0cee4a4fcce0 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/updateinstance/AsyncUpdateInstanceLRO.java @@ -0,0 +1,49 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_updateinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.OperationMetadata; +import com.google.cloud.datafusion.v1.UpdateInstanceRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateInstanceLRO(); + } + + public static void asyncUpdateInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + UpdateInstanceRequest request = + UpdateInstanceRequest.newBuilder() + .setInstance(Instance.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + dataFusionClient.updateInstanceOperationCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_updateinstance_lro_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/updateinstance/SyncUpdateInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/updateinstance/SyncUpdateInstance.java new file mode 100644 index 000000000000..9631db953ab2 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/updateinstance/SyncUpdateInstance.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_updateinstance_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.Instance; +import com.google.cloud.datafusion.v1.UpdateInstanceRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateInstance { + + public static void main(String[] args) throws Exception { + syncUpdateInstance(); + } + + public static void syncUpdateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + UpdateInstanceRequest request = + UpdateInstanceRequest.newBuilder() + .setInstance(Instance.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Instance response = dataFusionClient.updateInstanceAsync(request).get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_updateinstance_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/updateinstance/SyncUpdateInstanceInstanceFieldmask.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/updateinstance/SyncUpdateInstanceInstanceFieldmask.java new file mode 100644 index 000000000000..cb280d9b5a42 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionclient/updateinstance/SyncUpdateInstanceInstanceFieldmask.java @@ -0,0 +1,40 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionclient_updateinstance_instancefieldmask_sync] +import com.google.cloud.datafusion.v1.DataFusionClient; +import com.google.cloud.datafusion.v1.Instance; +import com.google.protobuf.FieldMask; + +public class SyncUpdateInstanceInstanceFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateInstanceInstanceFieldmask(); + } + + public static void syncUpdateInstanceInstanceFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + Instance instance = Instance.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Instance response = dataFusionClient.updateInstanceAsync(instance, updateMask).get(); + } + } +} +// [END datafusion_v1_generated_datafusionclient_updateinstance_instancefieldmask_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionsettings/getinstance/SyncGetInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionsettings/getinstance/SyncGetInstance.java new file mode 100644 index 000000000000..33b3b69a711c --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/datafusionsettings/getinstance/SyncGetInstance.java @@ -0,0 +1,45 @@ +/* + * 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.datafusion.v1.samples; + +// [START datafusion_v1_generated_datafusionsettings_getinstance_sync] +import com.google.cloud.datafusion.v1.DataFusionSettings; +import java.time.Duration; + +public class SyncGetInstance { + + public static void main(String[] args) throws Exception { + syncGetInstance(); + } + + public static void syncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DataFusionSettings.Builder dataFusionSettingsBuilder = DataFusionSettings.newBuilder(); + dataFusionSettingsBuilder + .getInstanceSettings() + .setRetrySettings( + dataFusionSettingsBuilder + .getInstanceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DataFusionSettings dataFusionSettings = dataFusionSettingsBuilder.build(); + } +} +// [END datafusion_v1_generated_datafusionsettings_getinstance_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/stub/datafusionstubsettings/getinstance/SyncGetInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/stub/datafusionstubsettings/getinstance/SyncGetInstance.java new file mode 100644 index 000000000000..e59f2fa9e017 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1/stub/datafusionstubsettings/getinstance/SyncGetInstance.java @@ -0,0 +1,45 @@ +/* + * 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.datafusion.v1.stub.samples; + +// [START datafusion_v1_generated_datafusionstubsettings_getinstance_sync] +import com.google.cloud.datafusion.v1.stub.DataFusionStubSettings; +import java.time.Duration; + +public class SyncGetInstance { + + public static void main(String[] args) throws Exception { + syncGetInstance(); + } + + public static void syncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DataFusionStubSettings.Builder dataFusionSettingsBuilder = DataFusionStubSettings.newBuilder(); + dataFusionSettingsBuilder + .getInstanceSettings() + .setRetrySettings( + dataFusionSettingsBuilder + .getInstanceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DataFusionStubSettings dataFusionSettings = dataFusionSettingsBuilder.build(); + } +} +// [END datafusion_v1_generated_datafusionstubsettings_getinstance_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/adddnspeering/AsyncAddDnsPeering.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/adddnspeering/AsyncAddDnsPeering.java new file mode 100644 index 000000000000..29dc84ea43d8 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/adddnspeering/AsyncAddDnsPeering.java @@ -0,0 +1,49 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_adddnspeering_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1beta1.AddDnsPeeringRequest; +import com.google.cloud.datafusion.v1beta1.AddDnsPeeringResponse; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.DnsPeering; +import com.google.cloud.datafusion.v1beta1.InstanceName; + +public class AsyncAddDnsPeering { + + public static void main(String[] args) throws Exception { + asyncAddDnsPeering(); + } + + public static void asyncAddDnsPeering() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + AddDnsPeeringRequest request = + AddDnsPeeringRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDnsPeering(DnsPeering.newBuilder().build()) + .build(); + ApiFuture future = + dataFusionClient.addDnsPeeringCallable().futureCall(request); + // Do something. + AddDnsPeeringResponse response = future.get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_adddnspeering_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/adddnspeering/SyncAddDnsPeering.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/adddnspeering/SyncAddDnsPeering.java new file mode 100644 index 000000000000..44c8ea37009c --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/adddnspeering/SyncAddDnsPeering.java @@ -0,0 +1,45 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_adddnspeering_sync] +import com.google.cloud.datafusion.v1beta1.AddDnsPeeringRequest; +import com.google.cloud.datafusion.v1beta1.AddDnsPeeringResponse; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.DnsPeering; +import com.google.cloud.datafusion.v1beta1.InstanceName; + +public class SyncAddDnsPeering { + + public static void main(String[] args) throws Exception { + syncAddDnsPeering(); + } + + public static void syncAddDnsPeering() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + AddDnsPeeringRequest request = + AddDnsPeeringRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDnsPeering(DnsPeering.newBuilder().build()) + .build(); + AddDnsPeeringResponse response = dataFusionClient.addDnsPeering(request); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_adddnspeering_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/adddnspeering/SyncAddDnsPeeringInstancename.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/adddnspeering/SyncAddDnsPeeringInstancename.java new file mode 100644 index 000000000000..0bdff1411a52 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/adddnspeering/SyncAddDnsPeeringInstancename.java @@ -0,0 +1,39 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_adddnspeering_instancename_sync] +import com.google.cloud.datafusion.v1beta1.AddDnsPeeringResponse; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; + +public class SyncAddDnsPeeringInstancename { + + public static void main(String[] args) throws Exception { + syncAddDnsPeeringInstancename(); + } + + public static void syncAddDnsPeeringInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + AddDnsPeeringResponse response = dataFusionClient.addDnsPeering(parent); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_adddnspeering_instancename_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/adddnspeering/SyncAddDnsPeeringString.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/adddnspeering/SyncAddDnsPeeringString.java new file mode 100644 index 000000000000..856428c266f6 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/adddnspeering/SyncAddDnsPeeringString.java @@ -0,0 +1,39 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_adddnspeering_string_sync] +import com.google.cloud.datafusion.v1beta1.AddDnsPeeringResponse; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; + +public class SyncAddDnsPeeringString { + + public static void main(String[] args) throws Exception { + syncAddDnsPeeringString(); + } + + public static void syncAddDnsPeeringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + String parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + AddDnsPeeringResponse response = dataFusionClient.addDnsPeering(parent); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_adddnspeering_string_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/create/SyncCreateSetCredentialsProvider.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..5863e4e24cef --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.DataFusionSettings; +import com.google.cloud.datafusion.v1beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DataFusionSettings dataFusionSettings = + DataFusionSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + DataFusionClient dataFusionClient = DataFusionClient.create(dataFusionSettings); + } +} +// [END datafusion_v1beta1_generated_datafusionclient_create_setcredentialsprovider_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/create/SyncCreateSetCredentialsProvider1.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..7c5b844c0d70 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_create_setcredentialsprovider1_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.DataFusionSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DataFusionSettings dataFusionSettings = + DataFusionSettings.newBuilder() + .setTransportChannelProvider( + DataFusionSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + DataFusionClient dataFusionClient = DataFusionClient.create(dataFusionSettings); + } +} +// [END datafusion_v1beta1_generated_datafusionclient_create_setcredentialsprovider1_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/create/SyncCreateSetEndpoint.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..6a1e4b8c790d --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_create_setendpoint_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.DataFusionSettings; +import com.google.cloud.datafusion.v1beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DataFusionSettings dataFusionSettings = + DataFusionSettings.newBuilder().setEndpoint(myEndpoint).build(); + DataFusionClient dataFusionClient = DataFusionClient.create(dataFusionSettings); + } +} +// [END datafusion_v1beta1_generated_datafusionclient_create_setendpoint_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/AsyncCreateInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/AsyncCreateInstance.java new file mode 100644 index 000000000000..6917711b2bca --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/AsyncCreateInstance.java @@ -0,0 +1,49 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_createinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1beta1.CreateInstanceRequest; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.LocationName; +import com.google.longrunning.Operation; + +public class AsyncCreateInstance { + + public static void main(String[] args) throws Exception { + asyncCreateInstance(); + } + + public static void asyncCreateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + CreateInstanceRequest request = + CreateInstanceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInstanceId("instanceId902024336") + .setInstance(Instance.newBuilder().build()) + .build(); + ApiFuture future = dataFusionClient.createInstanceCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_createinstance_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/AsyncCreateInstanceLRO.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/AsyncCreateInstanceLRO.java new file mode 100644 index 000000000000..226b3de82897 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/AsyncCreateInstanceLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_createinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datafusion.v1beta1.CreateInstanceRequest; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.LocationName; +import com.google.cloud.datafusion.v1beta1.OperationMetadata; + +public class AsyncCreateInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncCreateInstanceLRO(); + } + + public static void asyncCreateInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + CreateInstanceRequest request = + CreateInstanceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInstanceId("instanceId902024336") + .setInstance(Instance.newBuilder().build()) + .build(); + OperationFuture future = + dataFusionClient.createInstanceOperationCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_createinstance_lro_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/SyncCreateInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/SyncCreateInstance.java new file mode 100644 index 000000000000..548b9e801202 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/SyncCreateInstance.java @@ -0,0 +1,45 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_createinstance_sync] +import com.google.cloud.datafusion.v1beta1.CreateInstanceRequest; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.LocationName; + +public class SyncCreateInstance { + + public static void main(String[] args) throws Exception { + syncCreateInstance(); + } + + public static void syncCreateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + CreateInstanceRequest request = + CreateInstanceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInstanceId("instanceId902024336") + .setInstance(Instance.newBuilder().build()) + .build(); + Instance response = dataFusionClient.createInstanceAsync(request).get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_createinstance_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/SyncCreateInstanceLocationnameInstanceString.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/SyncCreateInstanceLocationnameInstanceString.java new file mode 100644 index 000000000000..383a2abf2681 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/SyncCreateInstanceLocationnameInstanceString.java @@ -0,0 +1,43 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START +// datafusion_v1beta1_generated_datafusionclient_createinstance_locationnameinstancestring_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.LocationName; + +public class SyncCreateInstanceLocationnameInstanceString { + + public static void main(String[] args) throws Exception { + syncCreateInstanceLocationnameInstanceString(); + } + + public static void syncCreateInstanceLocationnameInstanceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + Instance response = dataFusionClient.createInstanceAsync(parent, instance, instanceId).get(); + } + } +} +// [END +// datafusion_v1beta1_generated_datafusionclient_createinstance_locationnameinstancestring_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/SyncCreateInstanceStringInstanceString.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/SyncCreateInstanceStringInstanceString.java new file mode 100644 index 000000000000..3b077a4949b8 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/createinstance/SyncCreateInstanceStringInstanceString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_createinstance_stringinstancestring_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.LocationName; + +public class SyncCreateInstanceStringInstanceString { + + public static void main(String[] args) throws Exception { + syncCreateInstanceStringInstanceString(); + } + + public static void syncCreateInstanceStringInstanceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + Instance response = dataFusionClient.createInstanceAsync(parent, instance, instanceId).get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_createinstance_stringinstancestring_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/AsyncDeleteInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/AsyncDeleteInstance.java new file mode 100644 index 000000000000..0f3497e1cc82 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/AsyncDeleteInstance.java @@ -0,0 +1,46 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_deleteinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.DeleteInstanceRequest; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.longrunning.Operation; + +public class AsyncDeleteInstance { + + public static void main(String[] args) throws Exception { + asyncDeleteInstance(); + } + + public static void asyncDeleteInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + DeleteInstanceRequest request = + DeleteInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = dataFusionClient.deleteInstanceCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_deleteinstance_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/AsyncDeleteInstanceLRO.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/AsyncDeleteInstanceLRO.java new file mode 100644 index 000000000000..cc0c3680f3b8 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/AsyncDeleteInstanceLRO.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_deleteinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.DeleteInstanceRequest; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteInstanceLRO(); + } + + public static void asyncDeleteInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + DeleteInstanceRequest request = + DeleteInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + OperationFuture future = + dataFusionClient.deleteInstanceOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_deleteinstance_lro_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/SyncDeleteInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/SyncDeleteInstance.java new file mode 100644 index 000000000000..8b737f4e729a --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/SyncDeleteInstance.java @@ -0,0 +1,42 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_deleteinstance_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.DeleteInstanceRequest; +import com.google.cloud.datafusion.v1beta1.InstanceName; + +public class SyncDeleteInstance { + + public static void main(String[] args) throws Exception { + syncDeleteInstance(); + } + + public static void syncDeleteInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + DeleteInstanceRequest request = + DeleteInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + dataFusionClient.deleteInstanceAsync(request).get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_deleteinstance_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/SyncDeleteInstanceInstancename.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/SyncDeleteInstanceInstancename.java new file mode 100644 index 000000000000..c3c52946fe81 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/SyncDeleteInstanceInstancename.java @@ -0,0 +1,38 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_deleteinstance_instancename_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; + +public class SyncDeleteInstanceInstancename { + + public static void main(String[] args) throws Exception { + syncDeleteInstanceInstancename(); + } + + public static void syncDeleteInstanceInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + dataFusionClient.deleteInstanceAsync(name).get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_deleteinstance_instancename_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/SyncDeleteInstanceString.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/SyncDeleteInstanceString.java new file mode 100644 index 000000000000..56c6e1e505a2 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/deleteinstance/SyncDeleteInstanceString.java @@ -0,0 +1,38 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_deleteinstance_string_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; + +public class SyncDeleteInstanceString { + + public static void main(String[] args) throws Exception { + syncDeleteInstanceString(); + } + + public static void syncDeleteInstanceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + String name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + dataFusionClient.deleteInstanceAsync(name).get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_deleteinstance_string_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/getinstance/AsyncGetInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/getinstance/AsyncGetInstance.java new file mode 100644 index 000000000000..1a74ea19473d --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/getinstance/AsyncGetInstance.java @@ -0,0 +1,46 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_getinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.GetInstanceRequest; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.InstanceName; + +public class AsyncGetInstance { + + public static void main(String[] args) throws Exception { + asyncGetInstance(); + } + + public static void asyncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + GetInstanceRequest request = + GetInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = dataFusionClient.getInstanceCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_getinstance_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/getinstance/SyncGetInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/getinstance/SyncGetInstance.java new file mode 100644 index 000000000000..1d6c97e7be30 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/getinstance/SyncGetInstance.java @@ -0,0 +1,43 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_getinstance_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.GetInstanceRequest; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.InstanceName; + +public class SyncGetInstance { + + public static void main(String[] args) throws Exception { + syncGetInstance(); + } + + public static void syncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + GetInstanceRequest request = + GetInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + Instance response = dataFusionClient.getInstance(request); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_getinstance_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/AsyncListAvailableVersions.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/AsyncListAvailableVersions.java new file mode 100644 index 000000000000..f5dad81e5578 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/AsyncListAvailableVersions.java @@ -0,0 +1,52 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listavailableversions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.ListAvailableVersionsRequest; +import com.google.cloud.datafusion.v1beta1.LocationName; +import com.google.cloud.datafusion.v1beta1.Version; + +public class AsyncListAvailableVersions { + + public static void main(String[] args) throws Exception { + asyncListAvailableVersions(); + } + + public static void asyncListAvailableVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListAvailableVersionsRequest request = + ListAvailableVersionsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setLatestPatchOnly(true) + .build(); + ApiFuture future = + dataFusionClient.listAvailableVersionsPagedCallable().futureCall(request); + // Do something. + for (Version element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listavailableversions_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/AsyncListAvailableVersionsPaged.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/AsyncListAvailableVersionsPaged.java new file mode 100644 index 000000000000..9e73d7931d0b --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/AsyncListAvailableVersionsPaged.java @@ -0,0 +1,60 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listavailableversions_paged_async] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.ListAvailableVersionsRequest; +import com.google.cloud.datafusion.v1beta1.ListAvailableVersionsResponse; +import com.google.cloud.datafusion.v1beta1.LocationName; +import com.google.cloud.datafusion.v1beta1.Version; +import com.google.common.base.Strings; + +public class AsyncListAvailableVersionsPaged { + + public static void main(String[] args) throws Exception { + asyncListAvailableVersionsPaged(); + } + + public static void asyncListAvailableVersionsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListAvailableVersionsRequest request = + ListAvailableVersionsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setLatestPatchOnly(true) + .build(); + while (true) { + ListAvailableVersionsResponse response = + dataFusionClient.listAvailableVersionsCallable().call(request); + for (Version element : response.getAvailableVersionsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listavailableversions_paged_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/SyncListAvailableVersions.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/SyncListAvailableVersions.java new file mode 100644 index 000000000000..bc3c8cd825ba --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/SyncListAvailableVersions.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listavailableversions_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.ListAvailableVersionsRequest; +import com.google.cloud.datafusion.v1beta1.LocationName; +import com.google.cloud.datafusion.v1beta1.Version; + +public class SyncListAvailableVersions { + + public static void main(String[] args) throws Exception { + syncListAvailableVersions(); + } + + public static void syncListAvailableVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListAvailableVersionsRequest request = + ListAvailableVersionsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setLatestPatchOnly(true) + .build(); + for (Version element : dataFusionClient.listAvailableVersions(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listavailableversions_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/SyncListAvailableVersionsLocationname.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/SyncListAvailableVersionsLocationname.java new file mode 100644 index 000000000000..7c9bd4a61a96 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/SyncListAvailableVersionsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listavailableversions_locationname_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.LocationName; +import com.google.cloud.datafusion.v1beta1.Version; + +public class SyncListAvailableVersionsLocationname { + + public static void main(String[] args) throws Exception { + syncListAvailableVersionsLocationname(); + } + + public static void syncListAvailableVersionsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Version element : dataFusionClient.listAvailableVersions(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listavailableversions_locationname_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/SyncListAvailableVersionsString.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/SyncListAvailableVersionsString.java new file mode 100644 index 000000000000..704770356450 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listavailableversions/SyncListAvailableVersionsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listavailableversions_string_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.LocationName; +import com.google.cloud.datafusion.v1beta1.Version; + +public class SyncListAvailableVersionsString { + + public static void main(String[] args) throws Exception { + syncListAvailableVersionsString(); + } + + public static void syncListAvailableVersionsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Version element : dataFusionClient.listAvailableVersions(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listavailableversions_string_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/AsyncListDnsPeerings.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/AsyncListDnsPeerings.java new file mode 100644 index 000000000000..49050b145b34 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/AsyncListDnsPeerings.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listdnspeerings_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.DnsPeering; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.ListDnsPeeringsRequest; + +public class AsyncListDnsPeerings { + + public static void main(String[] args) throws Exception { + asyncListDnsPeerings(); + } + + public static void asyncListDnsPeerings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListDnsPeeringsRequest request = + ListDnsPeeringsRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + dataFusionClient.listDnsPeeringsPagedCallable().futureCall(request); + // Do something. + for (DnsPeering element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listdnspeerings_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/AsyncListDnsPeeringsPaged.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/AsyncListDnsPeeringsPaged.java new file mode 100644 index 000000000000..d9bd1a4788a8 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/AsyncListDnsPeeringsPaged.java @@ -0,0 +1,58 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listdnspeerings_paged_async] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.DnsPeering; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.ListDnsPeeringsRequest; +import com.google.cloud.datafusion.v1beta1.ListDnsPeeringsResponse; +import com.google.common.base.Strings; + +public class AsyncListDnsPeeringsPaged { + + public static void main(String[] args) throws Exception { + asyncListDnsPeeringsPaged(); + } + + public static void asyncListDnsPeeringsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListDnsPeeringsRequest request = + ListDnsPeeringsRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListDnsPeeringsResponse response = dataFusionClient.listDnsPeeringsCallable().call(request); + for (DnsPeering element : response.getDnsPeeringsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listdnspeerings_paged_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/SyncListDnsPeerings.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/SyncListDnsPeerings.java new file mode 100644 index 000000000000..40fc85981e5e --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/SyncListDnsPeerings.java @@ -0,0 +1,47 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listdnspeerings_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.DnsPeering; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.ListDnsPeeringsRequest; + +public class SyncListDnsPeerings { + + public static void main(String[] args) throws Exception { + syncListDnsPeerings(); + } + + public static void syncListDnsPeerings() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListDnsPeeringsRequest request = + ListDnsPeeringsRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (DnsPeering element : dataFusionClient.listDnsPeerings(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listdnspeerings_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/SyncListDnsPeeringsInstancename.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/SyncListDnsPeeringsInstancename.java new file mode 100644 index 000000000000..97534c764291 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/SyncListDnsPeeringsInstancename.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listdnspeerings_instancename_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.DnsPeering; +import com.google.cloud.datafusion.v1beta1.InstanceName; + +public class SyncListDnsPeeringsInstancename { + + public static void main(String[] args) throws Exception { + syncListDnsPeeringsInstancename(); + } + + public static void syncListDnsPeeringsInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + for (DnsPeering element : dataFusionClient.listDnsPeerings(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listdnspeerings_instancename_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/SyncListDnsPeeringsString.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/SyncListDnsPeeringsString.java new file mode 100644 index 000000000000..fa18d01ecbf5 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listdnspeerings/SyncListDnsPeeringsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listdnspeerings_string_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.DnsPeering; +import com.google.cloud.datafusion.v1beta1.InstanceName; + +public class SyncListDnsPeeringsString { + + public static void main(String[] args) throws Exception { + syncListDnsPeeringsString(); + } + + public static void syncListDnsPeeringsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + String parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + for (DnsPeering element : dataFusionClient.listDnsPeerings(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listdnspeerings_string_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listinstances/AsyncListInstances.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listinstances/AsyncListInstances.java new file mode 100644 index 000000000000..2f25f9d2408b --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listinstances/AsyncListInstances.java @@ -0,0 +1,53 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listinstances_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.ListInstancesRequest; +import com.google.cloud.datafusion.v1beta1.LocationName; + +public class AsyncListInstances { + + public static void main(String[] args) throws Exception { + asyncListInstances(); + } + + public static void asyncListInstances() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + dataFusionClient.listInstancesPagedCallable().futureCall(request); + // Do something. + for (Instance element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listinstances_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listinstances/AsyncListInstancesPaged.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listinstances/AsyncListInstancesPaged.java new file mode 100644 index 000000000000..7aad66cfaddd --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listinstances/AsyncListInstancesPaged.java @@ -0,0 +1,60 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listinstances_paged_async] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.ListInstancesRequest; +import com.google.cloud.datafusion.v1beta1.ListInstancesResponse; +import com.google.cloud.datafusion.v1beta1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListInstancesPaged { + + public static void main(String[] args) throws Exception { + asyncListInstancesPaged(); + } + + public static void asyncListInstancesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListInstancesResponse response = dataFusionClient.listInstancesCallable().call(request); + for (Instance element : response.getInstancesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listinstances_paged_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listinstances/SyncListInstances.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listinstances/SyncListInstances.java new file mode 100644 index 000000000000..e29f52cbf93e --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listinstances/SyncListInstances.java @@ -0,0 +1,49 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listinstances_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.ListInstancesRequest; +import com.google.cloud.datafusion.v1beta1.LocationName; + +public class SyncListInstances { + + public static void main(String[] args) throws Exception { + syncListInstances(); + } + + public static void syncListInstances() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Instance element : dataFusionClient.listInstances(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listinstances_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/AsyncListNamespaces.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/AsyncListNamespaces.java new file mode 100644 index 000000000000..3390836140a2 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/AsyncListNamespaces.java @@ -0,0 +1,53 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listnamespaces_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.ListNamespacesRequest; +import com.google.cloud.datafusion.v1beta1.Namespace; +import com.google.cloud.datafusion.v1beta1.NamespaceView; + +public class AsyncListNamespaces { + + public static void main(String[] args) throws Exception { + asyncListNamespaces(); + } + + public static void asyncListNamespaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListNamespacesRequest request = + ListNamespacesRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setView(NamespaceView.forNumber(0)) + .build(); + ApiFuture future = + dataFusionClient.listNamespacesPagedCallable().futureCall(request); + // Do something. + for (Namespace element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listnamespaces_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/AsyncListNamespacesPaged.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/AsyncListNamespacesPaged.java new file mode 100644 index 000000000000..32a2cff7f633 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/AsyncListNamespacesPaged.java @@ -0,0 +1,60 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listnamespaces_paged_async] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.ListNamespacesRequest; +import com.google.cloud.datafusion.v1beta1.ListNamespacesResponse; +import com.google.cloud.datafusion.v1beta1.Namespace; +import com.google.cloud.datafusion.v1beta1.NamespaceView; +import com.google.common.base.Strings; + +public class AsyncListNamespacesPaged { + + public static void main(String[] args) throws Exception { + asyncListNamespacesPaged(); + } + + public static void asyncListNamespacesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListNamespacesRequest request = + ListNamespacesRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setView(NamespaceView.forNumber(0)) + .build(); + while (true) { + ListNamespacesResponse response = dataFusionClient.listNamespacesCallable().call(request); + for (Namespace element : response.getNamespacesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listnamespaces_paged_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/SyncListNamespaces.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/SyncListNamespaces.java new file mode 100644 index 000000000000..a26a185d04da --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/SyncListNamespaces.java @@ -0,0 +1,49 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listnamespaces_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.ListNamespacesRequest; +import com.google.cloud.datafusion.v1beta1.Namespace; +import com.google.cloud.datafusion.v1beta1.NamespaceView; + +public class SyncListNamespaces { + + public static void main(String[] args) throws Exception { + syncListNamespaces(); + } + + public static void syncListNamespaces() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + ListNamespacesRequest request = + ListNamespacesRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setView(NamespaceView.forNumber(0)) + .build(); + for (Namespace element : dataFusionClient.listNamespaces(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listnamespaces_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/SyncListNamespacesInstancename.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/SyncListNamespacesInstancename.java new file mode 100644 index 000000000000..1cd65958ed34 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/SyncListNamespacesInstancename.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listnamespaces_instancename_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.Namespace; + +public class SyncListNamespacesInstancename { + + public static void main(String[] args) throws Exception { + syncListNamespacesInstancename(); + } + + public static void syncListNamespacesInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + for (Namespace element : dataFusionClient.listNamespaces(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listnamespaces_instancename_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/SyncListNamespacesString.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/SyncListNamespacesString.java new file mode 100644 index 000000000000..9b9eaa78d5ac --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/listnamespaces/SyncListNamespacesString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_listnamespaces_string_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.Namespace; + +public class SyncListNamespacesString { + + public static void main(String[] args) throws Exception { + syncListNamespacesString(); + } + + public static void syncListNamespacesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + String parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + for (Namespace element : dataFusionClient.listNamespaces(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_listnamespaces_string_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removednspeering/AsyncRemoveDnsPeering.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removednspeering/AsyncRemoveDnsPeering.java new file mode 100644 index 000000000000..0eebd183e57e --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removednspeering/AsyncRemoveDnsPeering.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_removednspeering_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.RemoveDnsPeeringRequest; +import com.google.cloud.datafusion.v1beta1.RemoveDnsPeeringResponse; + +public class AsyncRemoveDnsPeering { + + public static void main(String[] args) throws Exception { + asyncRemoveDnsPeering(); + } + + public static void asyncRemoveDnsPeering() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + RemoveDnsPeeringRequest request = + RemoveDnsPeeringRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setZone("zone3744684") + .build(); + ApiFuture future = + dataFusionClient.removeDnsPeeringCallable().futureCall(request); + // Do something. + RemoveDnsPeeringResponse response = future.get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_removednspeering_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removednspeering/SyncRemoveDnsPeering.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removednspeering/SyncRemoveDnsPeering.java new file mode 100644 index 000000000000..55720ddcf581 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removednspeering/SyncRemoveDnsPeering.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_removednspeering_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.RemoveDnsPeeringRequest; +import com.google.cloud.datafusion.v1beta1.RemoveDnsPeeringResponse; + +public class SyncRemoveDnsPeering { + + public static void main(String[] args) throws Exception { + syncRemoveDnsPeering(); + } + + public static void syncRemoveDnsPeering() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + RemoveDnsPeeringRequest request = + RemoveDnsPeeringRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setZone("zone3744684") + .build(); + RemoveDnsPeeringResponse response = dataFusionClient.removeDnsPeering(request); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_removednspeering_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removednspeering/SyncRemoveDnsPeeringInstancename.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removednspeering/SyncRemoveDnsPeeringInstancename.java new file mode 100644 index 000000000000..64199da144f9 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removednspeering/SyncRemoveDnsPeeringInstancename.java @@ -0,0 +1,39 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_removednspeering_instancename_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.RemoveDnsPeeringResponse; + +public class SyncRemoveDnsPeeringInstancename { + + public static void main(String[] args) throws Exception { + syncRemoveDnsPeeringInstancename(); + } + + public static void syncRemoveDnsPeeringInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + RemoveDnsPeeringResponse response = dataFusionClient.removeDnsPeering(parent); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_removednspeering_instancename_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removednspeering/SyncRemoveDnsPeeringString.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removednspeering/SyncRemoveDnsPeeringString.java new file mode 100644 index 000000000000..d5352f28c4e9 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removednspeering/SyncRemoveDnsPeeringString.java @@ -0,0 +1,39 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_removednspeering_string_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.RemoveDnsPeeringResponse; + +public class SyncRemoveDnsPeeringString { + + public static void main(String[] args) throws Exception { + syncRemoveDnsPeeringString(); + } + + public static void syncRemoveDnsPeeringString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + String parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + RemoveDnsPeeringResponse response = dataFusionClient.removeDnsPeering(parent); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_removednspeering_string_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removeiampolicy/AsyncRemoveIamPolicy.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removeiampolicy/AsyncRemoveIamPolicy.java new file mode 100644 index 000000000000..f81f4da2a7ab --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removeiampolicy/AsyncRemoveIamPolicy.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_removeiampolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.RemoveIamPolicyRequest; +import com.google.cloud.datafusion.v1beta1.RemoveIamPolicyResponse; + +public class AsyncRemoveIamPolicy { + + public static void main(String[] args) throws Exception { + asyncRemoveIamPolicy(); + } + + public static void asyncRemoveIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + RemoveIamPolicyRequest request = + RemoveIamPolicyRequest.newBuilder().setResource("resource-341064690").build(); + ApiFuture future = + dataFusionClient.removeIamPolicyCallable().futureCall(request); + // Do something. + RemoveIamPolicyResponse response = future.get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_removeiampolicy_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removeiampolicy/SyncRemoveIamPolicy.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removeiampolicy/SyncRemoveIamPolicy.java new file mode 100644 index 000000000000..32a3397cb715 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/removeiampolicy/SyncRemoveIamPolicy.java @@ -0,0 +1,40 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_removeiampolicy_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.RemoveIamPolicyRequest; +import com.google.cloud.datafusion.v1beta1.RemoveIamPolicyResponse; + +public class SyncRemoveIamPolicy { + + public static void main(String[] args) throws Exception { + syncRemoveIamPolicy(); + } + + public static void syncRemoveIamPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + RemoveIamPolicyRequest request = + RemoveIamPolicyRequest.newBuilder().setResource("resource-341064690").build(); + RemoveIamPolicyResponse response = dataFusionClient.removeIamPolicy(request); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_removeiampolicy_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/restartinstance/AsyncRestartInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/restartinstance/AsyncRestartInstance.java new file mode 100644 index 000000000000..1fb4b3715942 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/restartinstance/AsyncRestartInstance.java @@ -0,0 +1,46 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_restartinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.RestartInstanceRequest; +import com.google.longrunning.Operation; + +public class AsyncRestartInstance { + + public static void main(String[] args) throws Exception { + asyncRestartInstance(); + } + + public static void asyncRestartInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + RestartInstanceRequest request = + RestartInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = dataFusionClient.restartInstanceCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_restartinstance_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/restartinstance/AsyncRestartInstanceLRO.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/restartinstance/AsyncRestartInstanceLRO.java new file mode 100644 index 000000000000..01e07901d33f --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/restartinstance/AsyncRestartInstanceLRO.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_restartinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.OperationMetadata; +import com.google.cloud.datafusion.v1beta1.RestartInstanceRequest; + +public class AsyncRestartInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncRestartInstanceLRO(); + } + + public static void asyncRestartInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + RestartInstanceRequest request = + RestartInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + OperationFuture future = + dataFusionClient.restartInstanceOperationCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_restartinstance_lro_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/restartinstance/SyncRestartInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/restartinstance/SyncRestartInstance.java new file mode 100644 index 000000000000..c82c8e37a582 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/restartinstance/SyncRestartInstance.java @@ -0,0 +1,43 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_restartinstance_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.RestartInstanceRequest; + +public class SyncRestartInstance { + + public static void main(String[] args) throws Exception { + syncRestartInstance(); + } + + public static void syncRestartInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + RestartInstanceRequest request = + RestartInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + Instance response = dataFusionClient.restartInstanceAsync(request).get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_restartinstance_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/updateinstance/AsyncUpdateInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/updateinstance/AsyncUpdateInstance.java new file mode 100644 index 000000000000..db362397cad7 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/updateinstance/AsyncUpdateInstance.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_updateinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.UpdateInstanceRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateInstance { + + public static void main(String[] args) throws Exception { + asyncUpdateInstance(); + } + + public static void asyncUpdateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + UpdateInstanceRequest request = + UpdateInstanceRequest.newBuilder() + .setInstance(Instance.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = dataFusionClient.updateInstanceCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_updateinstance_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/updateinstance/AsyncUpdateInstanceLRO.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/updateinstance/AsyncUpdateInstanceLRO.java new file mode 100644 index 000000000000..8af59fbb4c0e --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/updateinstance/AsyncUpdateInstanceLRO.java @@ -0,0 +1,49 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_updateinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.OperationMetadata; +import com.google.cloud.datafusion.v1beta1.UpdateInstanceRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateInstanceLRO(); + } + + public static void asyncUpdateInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + UpdateInstanceRequest request = + UpdateInstanceRequest.newBuilder() + .setInstance(Instance.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + dataFusionClient.updateInstanceOperationCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_updateinstance_lro_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/updateinstance/SyncUpdateInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/updateinstance/SyncUpdateInstance.java new file mode 100644 index 000000000000..a1f75e4fbdb0 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/updateinstance/SyncUpdateInstance.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_updateinstance_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.UpdateInstanceRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateInstance { + + public static void main(String[] args) throws Exception { + syncUpdateInstance(); + } + + public static void syncUpdateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + UpdateInstanceRequest request = + UpdateInstanceRequest.newBuilder() + .setInstance(Instance.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Instance response = dataFusionClient.updateInstanceAsync(request).get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_updateinstance_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/updateinstance/SyncUpdateInstanceInstanceFieldmask.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/updateinstance/SyncUpdateInstanceInstanceFieldmask.java new file mode 100644 index 000000000000..4b7c8126a8b5 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/updateinstance/SyncUpdateInstanceInstanceFieldmask.java @@ -0,0 +1,40 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_updateinstance_instancefieldmask_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.protobuf.FieldMask; + +public class SyncUpdateInstanceInstanceFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateInstanceInstanceFieldmask(); + } + + public static void syncUpdateInstanceInstanceFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + Instance instance = Instance.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Instance response = dataFusionClient.updateInstanceAsync(instance, updateMask).get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_updateinstance_instancefieldmask_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/upgradeinstance/AsyncUpgradeInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/upgradeinstance/AsyncUpgradeInstance.java new file mode 100644 index 000000000000..c6fdc7bf8c28 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/upgradeinstance/AsyncUpgradeInstance.java @@ -0,0 +1,46 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_upgradeinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.UpgradeInstanceRequest; +import com.google.longrunning.Operation; + +public class AsyncUpgradeInstance { + + public static void main(String[] args) throws Exception { + asyncUpgradeInstance(); + } + + public static void asyncUpgradeInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + UpgradeInstanceRequest request = + UpgradeInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = dataFusionClient.upgradeInstanceCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_upgradeinstance_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/upgradeinstance/AsyncUpgradeInstanceLRO.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/upgradeinstance/AsyncUpgradeInstanceLRO.java new file mode 100644 index 000000000000..353a967ccaa8 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/upgradeinstance/AsyncUpgradeInstanceLRO.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_upgradeinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.OperationMetadata; +import com.google.cloud.datafusion.v1beta1.UpgradeInstanceRequest; + +public class AsyncUpgradeInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncUpgradeInstanceLRO(); + } + + public static void asyncUpgradeInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + UpgradeInstanceRequest request = + UpgradeInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + OperationFuture future = + dataFusionClient.upgradeInstanceOperationCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_upgradeinstance_lro_async] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/upgradeinstance/SyncUpgradeInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/upgradeinstance/SyncUpgradeInstance.java new file mode 100644 index 000000000000..fa5a7137f6d9 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionclient/upgradeinstance/SyncUpgradeInstance.java @@ -0,0 +1,43 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionclient_upgradeinstance_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionClient; +import com.google.cloud.datafusion.v1beta1.Instance; +import com.google.cloud.datafusion.v1beta1.InstanceName; +import com.google.cloud.datafusion.v1beta1.UpgradeInstanceRequest; + +public class SyncUpgradeInstance { + + public static void main(String[] args) throws Exception { + syncUpgradeInstance(); + } + + public static void syncUpgradeInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (DataFusionClient dataFusionClient = DataFusionClient.create()) { + UpgradeInstanceRequest request = + UpgradeInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + Instance response = dataFusionClient.upgradeInstanceAsync(request).get(); + } + } +} +// [END datafusion_v1beta1_generated_datafusionclient_upgradeinstance_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionsettings/getinstance/SyncGetInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionsettings/getinstance/SyncGetInstance.java new file mode 100644 index 000000000000..62307ad66404 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/datafusionsettings/getinstance/SyncGetInstance.java @@ -0,0 +1,45 @@ +/* + * 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.datafusion.v1beta1.samples; + +// [START datafusion_v1beta1_generated_datafusionsettings_getinstance_sync] +import com.google.cloud.datafusion.v1beta1.DataFusionSettings; +import java.time.Duration; + +public class SyncGetInstance { + + public static void main(String[] args) throws Exception { + syncGetInstance(); + } + + public static void syncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DataFusionSettings.Builder dataFusionSettingsBuilder = DataFusionSettings.newBuilder(); + dataFusionSettingsBuilder + .getInstanceSettings() + .setRetrySettings( + dataFusionSettingsBuilder + .getInstanceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DataFusionSettings dataFusionSettings = dataFusionSettingsBuilder.build(); + } +} +// [END datafusion_v1beta1_generated_datafusionsettings_getinstance_sync] diff --git a/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/stub/datafusionstubsettings/getinstance/SyncGetInstance.java b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/stub/datafusionstubsettings/getinstance/SyncGetInstance.java new file mode 100644 index 000000000000..85865b4f1c16 --- /dev/null +++ b/java-data-fusion/samples/snippets/generated/com/google/cloud/datafusion/v1beta1/stub/datafusionstubsettings/getinstance/SyncGetInstance.java @@ -0,0 +1,45 @@ +/* + * 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.datafusion.v1beta1.stub.samples; + +// [START datafusion_v1beta1_generated_datafusionstubsettings_getinstance_sync] +import com.google.cloud.datafusion.v1beta1.stub.DataFusionStubSettings; +import java.time.Duration; + +public class SyncGetInstance { + + public static void main(String[] args) throws Exception { + syncGetInstance(); + } + + public static void syncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + DataFusionStubSettings.Builder dataFusionSettingsBuilder = DataFusionStubSettings.newBuilder(); + dataFusionSettingsBuilder + .getInstanceSettings() + .setRetrySettings( + dataFusionSettingsBuilder + .getInstanceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + DataFusionStubSettings dataFusionSettings = dataFusionSettingsBuilder.build(); + } +} +// [END datafusion_v1beta1_generated_datafusionstubsettings_getinstance_sync]