diff --git a/google-cloud-orchestration-airflow/pom.xml b/google-cloud-orchestration-airflow/pom.xml index c0eb474f..94835e2a 100644 --- a/google-cloud-orchestration-airflow/pom.xml +++ b/google-cloud-orchestration-airflow/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/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/EnvironmentsClient.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/EnvironmentsClient.java index a5224924..0a5c76cd 100644 --- a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/EnvironmentsClient.java +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/EnvironmentsClient.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.orchestration.airflow.service.v1.stub.EnvironmentsStubSettings; 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; @@ -102,13 +102,28 @@ * EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); * } * + *

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.
+ * EnvironmentsSettings environmentsSettings =
+ *     EnvironmentsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             EnvironmentsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class EnvironmentsClient implements BackgroundResource { private final EnvironmentsSettings settings; private final EnvironmentsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of EnvironmentsClient with default settings. */ public static final EnvironmentsClient create() throws IOException { @@ -139,13 +154,17 @@ public static final EnvironmentsClient create(EnvironmentsStub stub) { protected EnvironmentsClient(EnvironmentsSettings settings) throws IOException { this.settings = settings; this.stub = ((EnvironmentsStubSettings) 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 EnvironmentsClient(EnvironmentsStub 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 EnvironmentsSettings getSettings() { @@ -160,10 +179,18 @@ public EnvironmentsStub 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. /** * Create a new environment. diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/EnvironmentsSettings.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/EnvironmentsSettings.java index 378bb268..7cd32cb7 100644 --- a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/EnvironmentsSettings.java +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/EnvironmentsSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -143,11 +144,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return EnvironmentsStubSettings.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 EnvironmentsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return EnvironmentsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return EnvironmentsStubSettings.defaultTransportChannelProvider(); } @@ -157,11 +165,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return EnvironmentsStubSettings.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); @@ -199,6 +213,11 @@ private static Builder createDefault() { return new Builder(EnvironmentsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(EnvironmentsStubSettings.newHttpJsonBuilder()); + } + public EnvironmentsStubSettings.Builder getStubSettingsBuilder() { return ((EnvironmentsStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/ImageVersionsClient.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/ImageVersionsClient.java index 1aacf455..d139399e 100644 --- a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/ImageVersionsClient.java +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/ImageVersionsClient.java @@ -98,6 +98,20 @@ * ImageVersionsClient imageVersionsClient = ImageVersionsClient.create(imageVersionsSettings); * } * + *

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.
+ * ImageVersionsSettings imageVersionsSettings =
+ *     ImageVersionsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ImageVersionsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ImageVersionsClient imageVersionsClient = ImageVersionsClient.create(imageVersionsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/ImageVersionsSettings.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/ImageVersionsSettings.java index 49f8cfd5..6cbe1752 100644 --- a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/ImageVersionsSettings.java +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/ImageVersionsSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -102,11 +103,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ImageVersionsStubSettings.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 ImageVersionsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ImageVersionsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ImageVersionsStubSettings.defaultTransportChannelProvider(); } @@ -116,11 +124,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ImageVersionsStubSettings.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); @@ -158,6 +172,11 @@ private static Builder createDefault() { return new Builder(ImageVersionsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ImageVersionsStubSettings.newHttpJsonBuilder()); + } + public ImageVersionsStubSettings.Builder getStubSettingsBuilder() { return ((ImageVersionsStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/EnvironmentsStub.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/EnvironmentsStub.java index 8ad45ab2..0668c4bb 100644 --- a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/EnvironmentsStub.java +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/EnvironmentsStub.java @@ -44,7 +44,11 @@ public abstract class EnvironmentsStub 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 OperationCallable diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/EnvironmentsStubSettings.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/EnvironmentsStubSettings.java index 73401f76..4a669abb 100644 --- a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/EnvironmentsStubSettings.java +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/EnvironmentsStubSettings.java @@ -28,6 +28,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -227,6 +230,11 @@ public EnvironmentsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcEnvironmentsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonEnvironmentsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -259,18 +267,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(EnvironmentsStubSettings.class)) @@ -278,11 +293,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(EnvironmentsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return EnvironmentsStubSettings.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); @@ -411,6 +445,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 .createEnvironmentSettings() diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/HttpJsonEnvironmentsCallableFactory.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/HttpJsonEnvironmentsCallableFactory.java new file mode 100644 index 00000000..dd5676bc --- /dev/null +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/HttpJsonEnvironmentsCallableFactory.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.orchestration.airflow.service.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 Environments service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonEnvironmentsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/HttpJsonEnvironmentsStub.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/HttpJsonEnvironmentsStub.java new file mode 100644 index 00000000..08dfe2b2 --- /dev/null +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/HttpJsonEnvironmentsStub.java @@ -0,0 +1,493 @@ +/* + * 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.orchestration.airflow.service.v1.stub; + +import static com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient.ListEnvironmentsPagedResponse; + +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.orchestration.airflow.service.v1.CreateEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest; +import com.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsResponse; +import com.google.cloud.orchestration.airflow.service.v1.OperationMetadata; +import com.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest; +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 Environments service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonEnvironmentsStub extends EnvironmentsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Environment.getDescriptor()) + .add(Empty.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.orchestration.airflow.service.v1.Environments/CreateEnvironment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/environments", + 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("environment", request.getEnvironment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateEnvironmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.orchestration.airflow.service.v1.Environments/GetEnvironment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/environments/*}", + 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(Environment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listEnvironmentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.orchestration.airflow.service.v1.Environments/ListEnvironments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/environments", + 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(ListEnvironmentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.orchestration.airflow.service.v1.Environments/UpdateEnvironment") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/environments/*}", + 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(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("environment", request.getEnvironment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateEnvironmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.orchestration.airflow.service.v1.Environments/DeleteEnvironment") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/environments/*}", + 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( + (DeleteEnvironmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable createEnvironmentCallable; + private final OperationCallable + createEnvironmentOperationCallable; + private final UnaryCallable getEnvironmentCallable; + private final UnaryCallable + listEnvironmentsCallable; + private final UnaryCallable + listEnvironmentsPagedCallable; + private final UnaryCallable updateEnvironmentCallable; + private final OperationCallable + updateEnvironmentOperationCallable; + private final UnaryCallable deleteEnvironmentCallable; + private final OperationCallable + deleteEnvironmentOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonEnvironmentsStub create(EnvironmentsStubSettings settings) + throws IOException { + return new HttpJsonEnvironmentsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonEnvironmentsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonEnvironmentsStub( + EnvironmentsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonEnvironmentsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonEnvironmentsStub( + EnvironmentsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonEnvironmentsStub, 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 HttpJsonEnvironmentsStub(EnvironmentsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonEnvironmentsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonEnvironmentsStub, 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 HttpJsonEnvironmentsStub( + EnvironmentsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listEnvironmentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listEnvironmentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createEnvironmentCallable = + callableFactory.createUnaryCallable( + createEnvironmentTransportSettings, + settings.createEnvironmentSettings(), + clientContext); + this.createEnvironmentOperationCallable = + callableFactory.createOperationCallable( + createEnvironmentTransportSettings, + settings.createEnvironmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getEnvironmentCallable = + callableFactory.createUnaryCallable( + getEnvironmentTransportSettings, settings.getEnvironmentSettings(), clientContext); + this.listEnvironmentsCallable = + callableFactory.createUnaryCallable( + listEnvironmentsTransportSettings, settings.listEnvironmentsSettings(), clientContext); + this.listEnvironmentsPagedCallable = + callableFactory.createPagedCallable( + listEnvironmentsTransportSettings, settings.listEnvironmentsSettings(), clientContext); + this.updateEnvironmentCallable = + callableFactory.createUnaryCallable( + updateEnvironmentTransportSettings, + settings.updateEnvironmentSettings(), + clientContext); + this.updateEnvironmentOperationCallable = + callableFactory.createOperationCallable( + updateEnvironmentTransportSettings, + settings.updateEnvironmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteEnvironmentCallable = + callableFactory.createUnaryCallable( + deleteEnvironmentTransportSettings, + settings.deleteEnvironmentSettings(), + clientContext); + this.deleteEnvironmentOperationCallable = + callableFactory.createOperationCallable( + deleteEnvironmentTransportSettings, + settings.deleteEnvironmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createEnvironmentMethodDescriptor); + methodDescriptors.add(getEnvironmentMethodDescriptor); + methodDescriptors.add(listEnvironmentsMethodDescriptor); + methodDescriptors.add(updateEnvironmentMethodDescriptor); + methodDescriptors.add(deleteEnvironmentMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createEnvironmentCallable() { + return createEnvironmentCallable; + } + + @Override + public OperationCallable + createEnvironmentOperationCallable() { + return createEnvironmentOperationCallable; + } + + @Override + public UnaryCallable getEnvironmentCallable() { + return getEnvironmentCallable; + } + + @Override + public UnaryCallable + listEnvironmentsCallable() { + return listEnvironmentsCallable; + } + + @Override + public UnaryCallable + listEnvironmentsPagedCallable() { + return listEnvironmentsPagedCallable; + } + + @Override + public UnaryCallable updateEnvironmentCallable() { + return updateEnvironmentCallable; + } + + @Override + public OperationCallable + updateEnvironmentOperationCallable() { + return updateEnvironmentOperationCallable; + } + + @Override + public UnaryCallable deleteEnvironmentCallable() { + return deleteEnvironmentCallable; + } + + @Override + public OperationCallable + deleteEnvironmentOperationCallable() { + return deleteEnvironmentOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/HttpJsonImageVersionsCallableFactory.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/HttpJsonImageVersionsCallableFactory.java new file mode 100644 index 00000000..1fc85ce1 --- /dev/null +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/HttpJsonImageVersionsCallableFactory.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.orchestration.airflow.service.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 ImageVersions service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonImageVersionsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/HttpJsonImageVersionsStub.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/HttpJsonImageVersionsStub.java new file mode 100644 index 00000000..6f1aee38 --- /dev/null +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/HttpJsonImageVersionsStub.java @@ -0,0 +1,216 @@ +/* + * 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.orchestration.airflow.service.v1.stub; + +import static com.google.cloud.orchestration.airflow.service.v1.ImageVersionsClient.ListImageVersionsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest; +import com.google.cloud.orchestration.airflow.service.v1.ListImageVersionsResponse; +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 ImageVersions service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonImageVersionsStub extends ImageVersionsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listImageVersionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.orchestration.airflow.service.v1.ImageVersions/ListImageVersions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/imageVersions", + 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, "includePastReleases", request.getIncludePastReleases()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListImageVersionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + listImageVersionsCallable; + private final UnaryCallable + listImageVersionsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonImageVersionsStub create(ImageVersionsStubSettings settings) + throws IOException { + return new HttpJsonImageVersionsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonImageVersionsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonImageVersionsStub( + ImageVersionsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonImageVersionsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonImageVersionsStub( + ImageVersionsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonImageVersionsStub, 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 HttpJsonImageVersionsStub( + ImageVersionsStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonImageVersionsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonImageVersionsStub, 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 HttpJsonImageVersionsStub( + ImageVersionsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + listImageVersionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listImageVersionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listImageVersionsCallable = + callableFactory.createUnaryCallable( + listImageVersionsTransportSettings, + settings.listImageVersionsSettings(), + clientContext); + this.listImageVersionsPagedCallable = + callableFactory.createPagedCallable( + listImageVersionsTransportSettings, + settings.listImageVersionsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listImageVersionsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + listImageVersionsCallable() { + return listImageVersionsCallable; + } + + @Override + public UnaryCallable + listImageVersionsPagedCallable() { + return listImageVersionsPagedCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/ImageVersionsStubSettings.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/ImageVersionsStubSettings.java index f9eb1660..471d4b9f 100644 --- a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/ImageVersionsStubSettings.java +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1/stub/ImageVersionsStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -169,6 +172,11 @@ public ImageVersionsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcImageVersionsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonImageVersionsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -201,18 +209,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(ImageVersionsStubSettings.class)) @@ -220,11 +235,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(ImageVersionsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ImageVersionsStubSettings.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); @@ -303,6 +337,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 .listImageVersionsSettings() diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/EnvironmentsClient.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/EnvironmentsClient.java index 45774e34..ee96a445 100644 --- a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/EnvironmentsClient.java +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/EnvironmentsClient.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.orchestration.airflow.service.v1beta1.stub.EnvironmentsStubSettings; 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; @@ -103,6 +103,20 @@ * EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); * } * + *

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.
+ * EnvironmentsSettings environmentsSettings =
+ *     EnvironmentsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             EnvironmentsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -110,7 +124,8 @@ public class EnvironmentsClient implements BackgroundResource { private final EnvironmentsSettings settings; private final EnvironmentsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of EnvironmentsClient with default settings. */ public static final EnvironmentsClient create() throws IOException { @@ -141,13 +156,17 @@ public static final EnvironmentsClient create(EnvironmentsStub stub) { protected EnvironmentsClient(EnvironmentsSettings settings) throws IOException { this.settings = settings; this.stub = ((EnvironmentsStubSettings) 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 EnvironmentsClient(EnvironmentsStub 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 EnvironmentsSettings getSettings() { @@ -162,10 +181,18 @@ public EnvironmentsStub 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. /** * Create a new environment. diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/EnvironmentsSettings.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/EnvironmentsSettings.java index d4807174..4a6853e6 100644 --- a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/EnvironmentsSettings.java +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/EnvironmentsSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -166,11 +167,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return EnvironmentsStubSettings.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 EnvironmentsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return EnvironmentsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return EnvironmentsStubSettings.defaultTransportChannelProvider(); } @@ -180,11 +188,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return EnvironmentsStubSettings.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); @@ -222,6 +236,11 @@ private static Builder createDefault() { return new Builder(EnvironmentsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(EnvironmentsStubSettings.newHttpJsonBuilder()); + } + public EnvironmentsStubSettings.Builder getStubSettingsBuilder() { return ((EnvironmentsStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/ImageVersionsClient.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/ImageVersionsClient.java index 2e328310..41fa3219 100644 --- a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/ImageVersionsClient.java +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/ImageVersionsClient.java @@ -99,6 +99,20 @@ * ImageVersionsClient imageVersionsClient = ImageVersionsClient.create(imageVersionsSettings); * } * + *

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.
+ * ImageVersionsSettings imageVersionsSettings =
+ *     ImageVersionsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ImageVersionsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ImageVersionsClient imageVersionsClient = ImageVersionsClient.create(imageVersionsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/ImageVersionsSettings.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/ImageVersionsSettings.java index 1e2feaf4..603a0471 100644 --- a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/ImageVersionsSettings.java +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/ImageVersionsSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -103,11 +104,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ImageVersionsStubSettings.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 ImageVersionsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ImageVersionsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ImageVersionsStubSettings.defaultTransportChannelProvider(); } @@ -117,11 +125,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ImageVersionsStubSettings.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); @@ -159,6 +173,11 @@ private static Builder createDefault() { return new Builder(ImageVersionsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ImageVersionsStubSettings.newHttpJsonBuilder()); + } + public ImageVersionsStubSettings.Builder getStubSettingsBuilder() { return ((ImageVersionsStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/EnvironmentsStub.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/EnvironmentsStub.java index facd5781..d2683562 100644 --- a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/EnvironmentsStub.java +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/EnvironmentsStub.java @@ -49,7 +49,11 @@ public abstract class EnvironmentsStub 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 OperationCallable diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/EnvironmentsStubSettings.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/EnvironmentsStubSettings.java index ea830d91..60e39592 100644 --- a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/EnvironmentsStubSettings.java +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/EnvironmentsStubSettings.java @@ -28,6 +28,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -259,6 +262,11 @@ public EnvironmentsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcEnvironmentsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonEnvironmentsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -291,18 +299,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(EnvironmentsStubSettings.class)) @@ -310,11 +325,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(EnvironmentsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return EnvironmentsStubSettings.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); @@ -468,6 +502,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 .createEnvironmentSettings() diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/HttpJsonEnvironmentsCallableFactory.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/HttpJsonEnvironmentsCallableFactory.java new file mode 100644 index 00000000..6b3d5e25 --- /dev/null +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/HttpJsonEnvironmentsCallableFactory.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.orchestration.airflow.service.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 Environments service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonEnvironmentsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/HttpJsonEnvironmentsStub.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/HttpJsonEnvironmentsStub.java new file mode 100644 index 00000000..f6a7b56c --- /dev/null +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/HttpJsonEnvironmentsStub.java @@ -0,0 +1,636 @@ +/* + * 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.orchestration.airflow.service.v1beta1.stub; + +import static com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient.ListEnvironmentsPagedResponse; + +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.orchestration.airflow.service.v1beta1.CheckUpgradeRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeResponse; +import com.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsResponse; +import com.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata; +import com.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest; +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 Environments service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonEnvironmentsStub extends EnvironmentsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .add(Environment.getDescriptor()) + .add(CheckUpgradeResponse.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.orchestration.airflow.service.v1beta1.Environments/CreateEnvironment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/environments", + 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("environment", request.getEnvironment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateEnvironmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.orchestration.airflow.service.v1beta1.Environments/GetEnvironment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/environments/*}", + 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(Environment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listEnvironmentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.orchestration.airflow.service.v1beta1.Environments/ListEnvironments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/environments", + 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(ListEnvironmentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.orchestration.airflow.service.v1beta1.Environments/UpdateEnvironment") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/environments/*}", + 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(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("environment", request.getEnvironment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateEnvironmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.orchestration.airflow.service.v1beta1.Environments/DeleteEnvironment") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/environments/*}", + 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( + (DeleteEnvironmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + restartWebServerMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.orchestration.airflow.service.v1beta1.Environments/RestartWebServer") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/environments/*}:restartWebServer", + 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( + (RestartWebServerRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + checkUpgradeMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.orchestration.airflow.service.v1beta1.Environments/CheckUpgrade") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{environment=projects/*/locations/*/environments/*}:checkUpgrade", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "environment", request.getEnvironment()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearEnvironment().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CheckUpgradeRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable createEnvironmentCallable; + private final OperationCallable + createEnvironmentOperationCallable; + private final UnaryCallable getEnvironmentCallable; + private final UnaryCallable + listEnvironmentsCallable; + private final UnaryCallable + listEnvironmentsPagedCallable; + private final UnaryCallable updateEnvironmentCallable; + private final OperationCallable + updateEnvironmentOperationCallable; + private final UnaryCallable deleteEnvironmentCallable; + private final OperationCallable + deleteEnvironmentOperationCallable; + private final UnaryCallable restartWebServerCallable; + private final OperationCallable + restartWebServerOperationCallable; + private final UnaryCallable checkUpgradeCallable; + private final OperationCallable + checkUpgradeOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonEnvironmentsStub create(EnvironmentsStubSettings settings) + throws IOException { + return new HttpJsonEnvironmentsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonEnvironmentsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonEnvironmentsStub( + EnvironmentsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonEnvironmentsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonEnvironmentsStub( + EnvironmentsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonEnvironmentsStub, 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 HttpJsonEnvironmentsStub(EnvironmentsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonEnvironmentsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonEnvironmentsStub, 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 HttpJsonEnvironmentsStub( + EnvironmentsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listEnvironmentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listEnvironmentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings restartWebServerTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(restartWebServerMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings checkUpgradeTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(checkUpgradeMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createEnvironmentCallable = + callableFactory.createUnaryCallable( + createEnvironmentTransportSettings, + settings.createEnvironmentSettings(), + clientContext); + this.createEnvironmentOperationCallable = + callableFactory.createOperationCallable( + createEnvironmentTransportSettings, + settings.createEnvironmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getEnvironmentCallable = + callableFactory.createUnaryCallable( + getEnvironmentTransportSettings, settings.getEnvironmentSettings(), clientContext); + this.listEnvironmentsCallable = + callableFactory.createUnaryCallable( + listEnvironmentsTransportSettings, settings.listEnvironmentsSettings(), clientContext); + this.listEnvironmentsPagedCallable = + callableFactory.createPagedCallable( + listEnvironmentsTransportSettings, settings.listEnvironmentsSettings(), clientContext); + this.updateEnvironmentCallable = + callableFactory.createUnaryCallable( + updateEnvironmentTransportSettings, + settings.updateEnvironmentSettings(), + clientContext); + this.updateEnvironmentOperationCallable = + callableFactory.createOperationCallable( + updateEnvironmentTransportSettings, + settings.updateEnvironmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteEnvironmentCallable = + callableFactory.createUnaryCallable( + deleteEnvironmentTransportSettings, + settings.deleteEnvironmentSettings(), + clientContext); + this.deleteEnvironmentOperationCallable = + callableFactory.createOperationCallable( + deleteEnvironmentTransportSettings, + settings.deleteEnvironmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.restartWebServerCallable = + callableFactory.createUnaryCallable( + restartWebServerTransportSettings, settings.restartWebServerSettings(), clientContext); + this.restartWebServerOperationCallable = + callableFactory.createOperationCallable( + restartWebServerTransportSettings, + settings.restartWebServerOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.checkUpgradeCallable = + callableFactory.createUnaryCallable( + checkUpgradeTransportSettings, settings.checkUpgradeSettings(), clientContext); + this.checkUpgradeOperationCallable = + callableFactory.createOperationCallable( + checkUpgradeTransportSettings, + settings.checkUpgradeOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createEnvironmentMethodDescriptor); + methodDescriptors.add(getEnvironmentMethodDescriptor); + methodDescriptors.add(listEnvironmentsMethodDescriptor); + methodDescriptors.add(updateEnvironmentMethodDescriptor); + methodDescriptors.add(deleteEnvironmentMethodDescriptor); + methodDescriptors.add(restartWebServerMethodDescriptor); + methodDescriptors.add(checkUpgradeMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createEnvironmentCallable() { + return createEnvironmentCallable; + } + + @Override + public OperationCallable + createEnvironmentOperationCallable() { + return createEnvironmentOperationCallable; + } + + @Override + public UnaryCallable getEnvironmentCallable() { + return getEnvironmentCallable; + } + + @Override + public UnaryCallable + listEnvironmentsCallable() { + return listEnvironmentsCallable; + } + + @Override + public UnaryCallable + listEnvironmentsPagedCallable() { + return listEnvironmentsPagedCallable; + } + + @Override + public UnaryCallable updateEnvironmentCallable() { + return updateEnvironmentCallable; + } + + @Override + public OperationCallable + updateEnvironmentOperationCallable() { + return updateEnvironmentOperationCallable; + } + + @Override + public UnaryCallable deleteEnvironmentCallable() { + return deleteEnvironmentCallable; + } + + @Override + public OperationCallable + deleteEnvironmentOperationCallable() { + return deleteEnvironmentOperationCallable; + } + + @Override + public UnaryCallable restartWebServerCallable() { + return restartWebServerCallable; + } + + @Override + public OperationCallable + restartWebServerOperationCallable() { + return restartWebServerOperationCallable; + } + + @Override + public UnaryCallable checkUpgradeCallable() { + return checkUpgradeCallable; + } + + @Override + public OperationCallable + checkUpgradeOperationCallable() { + return checkUpgradeOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/HttpJsonImageVersionsCallableFactory.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/HttpJsonImageVersionsCallableFactory.java new file mode 100644 index 00000000..fa68640f --- /dev/null +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/HttpJsonImageVersionsCallableFactory.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.orchestration.airflow.service.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 ImageVersions service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonImageVersionsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/HttpJsonImageVersionsStub.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/HttpJsonImageVersionsStub.java new file mode 100644 index 00000000..0ea3e6b9 --- /dev/null +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/HttpJsonImageVersionsStub.java @@ -0,0 +1,216 @@ +/* + * 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.orchestration.airflow.service.v1beta1.stub; + +import static com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsClient.ListImageVersionsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsResponse; +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 ImageVersions service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonImageVersionsStub extends ImageVersionsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listImageVersionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.orchestration.airflow.service.v1beta1.ImageVersions/ListImageVersions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/imageVersions", + 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, "includePastReleases", request.getIncludePastReleases()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListImageVersionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + listImageVersionsCallable; + private final UnaryCallable + listImageVersionsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonImageVersionsStub create(ImageVersionsStubSettings settings) + throws IOException { + return new HttpJsonImageVersionsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonImageVersionsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonImageVersionsStub( + ImageVersionsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonImageVersionsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonImageVersionsStub( + ImageVersionsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonImageVersionsStub, 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 HttpJsonImageVersionsStub( + ImageVersionsStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonImageVersionsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonImageVersionsStub, 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 HttpJsonImageVersionsStub( + ImageVersionsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + listImageVersionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listImageVersionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listImageVersionsCallable = + callableFactory.createUnaryCallable( + listImageVersionsTransportSettings, + settings.listImageVersionsSettings(), + clientContext); + this.listImageVersionsPagedCallable = + callableFactory.createPagedCallable( + listImageVersionsTransportSettings, + settings.listImageVersionsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listImageVersionsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + listImageVersionsCallable() { + return listImageVersionsCallable; + } + + @Override + public UnaryCallable + listImageVersionsPagedCallable() { + return listImageVersionsPagedCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/ImageVersionsStubSettings.java b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/ImageVersionsStubSettings.java index eab42d9d..1d99cd92 100644 --- a/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/ImageVersionsStubSettings.java +++ b/google-cloud-orchestration-airflow/src/main/java/com/google/cloud/orchestration/airflow/service/v1beta1/stub/ImageVersionsStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -170,6 +173,11 @@ public ImageVersionsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcImageVersionsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonImageVersionsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -202,18 +210,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(ImageVersionsStubSettings.class)) @@ -221,11 +236,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(ImageVersionsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ImageVersionsStubSettings.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); @@ -304,6 +338,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 .listImageVersionsSettings() diff --git a/google-cloud-orchestration-airflow/src/test/java/com/google/cloud/orchestration/airflow/service/v1/EnvironmentsClientHttpJsonTest.java b/google-cloud-orchestration-airflow/src/test/java/com/google/cloud/orchestration/airflow/service/v1/EnvironmentsClientHttpJsonTest.java new file mode 100644 index 00000000..fae25fca --- /dev/null +++ b/google-cloud-orchestration-airflow/src/test/java/com/google/cloud/orchestration/airflow/service/v1/EnvironmentsClientHttpJsonTest.java @@ -0,0 +1,342 @@ +/* + * 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.orchestration.airflow.service.v1; + +import static com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient.ListEnvironmentsPagedResponse; + +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.orchestration.airflow.service.v1.stub.HttpJsonEnvironmentsStub; +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.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 EnvironmentsClientHttpJsonTest { + private static MockHttpService mockService; + private static EnvironmentsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonEnvironmentsStub.getMethodDescriptors(), + EnvironmentsSettings.getDefaultEndpoint()); + EnvironmentsSettings settings = + EnvironmentsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + EnvironmentsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = EnvironmentsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createEnvironmentTest() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName("name3373707") + .setConfig(EnvironmentConfig.newBuilder().build()) + .setUuid("uuid3601339") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createEnvironmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Environment environment = Environment.newBuilder().build(); + + Environment actualResponse = client.createEnvironmentAsync(parent, environment).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 createEnvironmentExceptionTest() 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"; + Environment environment = Environment.newBuilder().build(); + client.createEnvironmentAsync(parent, environment).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getEnvironmentTest() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName("name3373707") + .setConfig(EnvironmentConfig.newBuilder().build()) + .setUuid("uuid3601339") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7856/locations/location-7856/environments/environment-7856"; + + Environment actualResponse = client.getEnvironment(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7856/locations/location-7856/environments/environment-7856"; + client.getEnvironment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEnvironmentsTest() throws Exception { + Environment responsesElement = Environment.newBuilder().build(); + ListEnvironmentsResponse expectedResponse = + ListEnvironmentsResponse.newBuilder() + .setNextPageToken("") + .addAllEnvironments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListEnvironmentsPagedResponse pagedListResponse = client.listEnvironments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEnvironmentsList().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 listEnvironmentsExceptionTest() 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.listEnvironments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateEnvironmentTest() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName("name3373707") + .setConfig(EnvironmentConfig.newBuilder().build()) + .setUuid("uuid3601339") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateEnvironmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7856/locations/location-7856/environments/environment-7856"; + Environment environment = Environment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Environment actualResponse = client.updateEnvironmentAsync(name, environment, 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 updateEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7856/locations/location-7856/environments/environment-7856"; + Environment environment = Environment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateEnvironmentAsync(name, environment, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteEnvironmentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteEnvironmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7856/locations/location-7856/environments/environment-7856"; + + client.deleteEnvironmentAsync(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 deleteEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7856/locations/location-7856/environments/environment-7856"; + client.deleteEnvironmentAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-orchestration-airflow/src/test/java/com/google/cloud/orchestration/airflow/service/v1/ImageVersionsClientHttpJsonTest.java b/google-cloud-orchestration-airflow/src/test/java/com/google/cloud/orchestration/airflow/service/v1/ImageVersionsClientHttpJsonTest.java new file mode 100644 index 00000000..625ca2c6 --- /dev/null +++ b/google-cloud-orchestration-airflow/src/test/java/com/google/cloud/orchestration/airflow/service/v1/ImageVersionsClientHttpJsonTest.java @@ -0,0 +1,127 @@ +/* + * 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.orchestration.airflow.service.v1; + +import static com.google.cloud.orchestration.airflow.service.v1.ImageVersionsClient.ListImageVersionsPagedResponse; + +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.orchestration.airflow.service.v1.stub.HttpJsonImageVersionsStub; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ImageVersionsClientHttpJsonTest { + private static MockHttpService mockService; + private static ImageVersionsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonImageVersionsStub.getMethodDescriptors(), + ImageVersionsSettings.getDefaultEndpoint()); + ImageVersionsSettings settings = + ImageVersionsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ImageVersionsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ImageVersionsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listImageVersionsTest() throws Exception { + ImageVersion responsesElement = ImageVersion.newBuilder().build(); + ListImageVersionsResponse expectedResponse = + ListImageVersionsResponse.newBuilder() + .setNextPageToken("") + .addAllImageVersions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListImageVersionsPagedResponse pagedListResponse = client.listImageVersions(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getImageVersionsList().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 listImageVersionsExceptionTest() 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.listImageVersions(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-orchestration-airflow/src/test/java/com/google/cloud/orchestration/airflow/service/v1beta1/EnvironmentsClientHttpJsonTest.java b/google-cloud-orchestration-airflow/src/test/java/com/google/cloud/orchestration/airflow/service/v1beta1/EnvironmentsClientHttpJsonTest.java new file mode 100644 index 00000000..4220557b --- /dev/null +++ b/google-cloud-orchestration-airflow/src/test/java/com/google/cloud/orchestration/airflow/service/v1beta1/EnvironmentsClientHttpJsonTest.java @@ -0,0 +1,465 @@ +/* + * 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.orchestration.airflow.service.v1beta1; + +import static com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient.ListEnvironmentsPagedResponse; + +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.orchestration.airflow.service.v1beta1.stub.HttpJsonEnvironmentsStub; +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.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 EnvironmentsClientHttpJsonTest { + private static MockHttpService mockService; + private static EnvironmentsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonEnvironmentsStub.getMethodDescriptors(), + EnvironmentsSettings.getDefaultEndpoint()); + EnvironmentsSettings settings = + EnvironmentsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + EnvironmentsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = EnvironmentsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createEnvironmentTest() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName("name3373707") + .setConfig(EnvironmentConfig.newBuilder().build()) + .setUuid("uuid3601339") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createEnvironmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Environment environment = Environment.newBuilder().build(); + + Environment actualResponse = client.createEnvironmentAsync(parent, environment).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 createEnvironmentExceptionTest() 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"; + Environment environment = Environment.newBuilder().build(); + client.createEnvironmentAsync(parent, environment).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getEnvironmentTest() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName("name3373707") + .setConfig(EnvironmentConfig.newBuilder().build()) + .setUuid("uuid3601339") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7856/locations/location-7856/environments/environment-7856"; + + Environment actualResponse = client.getEnvironment(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7856/locations/location-7856/environments/environment-7856"; + client.getEnvironment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEnvironmentsTest() throws Exception { + Environment responsesElement = Environment.newBuilder().build(); + ListEnvironmentsResponse expectedResponse = + ListEnvironmentsResponse.newBuilder() + .setNextPageToken("") + .addAllEnvironments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListEnvironmentsPagedResponse pagedListResponse = client.listEnvironments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEnvironmentsList().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 listEnvironmentsExceptionTest() 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.listEnvironments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateEnvironmentTest() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName("name3373707") + .setConfig(EnvironmentConfig.newBuilder().build()) + .setUuid("uuid3601339") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateEnvironmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7856/locations/location-7856/environments/environment-7856"; + Environment environment = Environment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Environment actualResponse = client.updateEnvironmentAsync(name, environment, 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 updateEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7856/locations/location-7856/environments/environment-7856"; + Environment environment = Environment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateEnvironmentAsync(name, environment, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteEnvironmentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteEnvironmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7856/locations/location-7856/environments/environment-7856"; + + client.deleteEnvironmentAsync(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 deleteEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-7856/locations/location-7856/environments/environment-7856"; + client.deleteEnvironmentAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void restartWebServerTest() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName("name3373707") + .setConfig(EnvironmentConfig.newBuilder().build()) + .setUuid("uuid3601339") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("restartWebServerTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RestartWebServerRequest request = + RestartWebServerRequest.newBuilder() + .setName("projects/project-7856/locations/location-7856/environments/environment-7856") + .build(); + + Environment actualResponse = client.restartWebServerAsync(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 restartWebServerExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestartWebServerRequest request = + RestartWebServerRequest.newBuilder() + .setName( + "projects/project-7856/locations/location-7856/environments/environment-7856") + .build(); + client.restartWebServerAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void checkUpgradeTest() throws Exception { + CheckUpgradeResponse expectedResponse = + CheckUpgradeResponse.newBuilder() + .setBuildLogUri("buildLogUri2048482198") + .setPypiConflictBuildLogExtract("pypiConflictBuildLogExtract-1257030825") + .setImageVersion("imageVersion949870333") + .putAllPypiDependencies(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("checkUpgradeTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + CheckUpgradeRequest request = + CheckUpgradeRequest.newBuilder() + .setEnvironment( + "projects/project-4088/locations/location-4088/environments/environment-4088") + .setImageVersion("imageVersion949870333") + .build(); + + CheckUpgradeResponse actualResponse = client.checkUpgradeAsync(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 checkUpgradeExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CheckUpgradeRequest request = + CheckUpgradeRequest.newBuilder() + .setEnvironment( + "projects/project-4088/locations/location-4088/environments/environment-4088") + .setImageVersion("imageVersion949870333") + .build(); + client.checkUpgradeAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-orchestration-airflow/src/test/java/com/google/cloud/orchestration/airflow/service/v1beta1/ImageVersionsClientHttpJsonTest.java b/google-cloud-orchestration-airflow/src/test/java/com/google/cloud/orchestration/airflow/service/v1beta1/ImageVersionsClientHttpJsonTest.java new file mode 100644 index 00000000..e1b43bd6 --- /dev/null +++ b/google-cloud-orchestration-airflow/src/test/java/com/google/cloud/orchestration/airflow/service/v1beta1/ImageVersionsClientHttpJsonTest.java @@ -0,0 +1,127 @@ +/* + * 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.orchestration.airflow.service.v1beta1; + +import static com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsClient.ListImageVersionsPagedResponse; + +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.orchestration.airflow.service.v1beta1.stub.HttpJsonImageVersionsStub; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ImageVersionsClientHttpJsonTest { + private static MockHttpService mockService; + private static ImageVersionsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonImageVersionsStub.getMethodDescriptors(), + ImageVersionsSettings.getDefaultEndpoint()); + ImageVersionsSettings settings = + ImageVersionsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ImageVersionsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ImageVersionsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listImageVersionsTest() throws Exception { + ImageVersion responsesElement = ImageVersion.newBuilder().build(); + ListImageVersionsResponse expectedResponse = + ListImageVersionsResponse.newBuilder() + .setNextPageToken("") + .addAllImageVersions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListImageVersionsPagedResponse pagedListResponse = client.listImageVersions(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getImageVersionsList().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 listImageVersionsExceptionTest() 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.listImageVersions(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..97a6844d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsSettings; +import com.google.cloud.orchestration.airflow.service.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. + EnvironmentsSettings environmentsSettings = + EnvironmentsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); + } +} +// [END service_v1_generated_environmentsclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..7b5352ea --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsSettings; + +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. + EnvironmentsSettings environmentsSettings = + EnvironmentsSettings.newBuilder() + .setTransportChannelProvider( + EnvironmentsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); + } +} +// [END service_v1_generated_environmentsclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..2af5acdf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_create_setendpoint_sync] +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsSettings; +import com.google.cloud.orchestration.airflow.service.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. + EnvironmentsSettings environmentsSettings = + EnvironmentsSettings.newBuilder().setEndpoint(myEndpoint).build(); + EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); + } +} +// [END service_v1_generated_environmentsclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/createenvironment/AsyncCreateEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/createenvironment/AsyncCreateEnvironment.java new file mode 100644 index 00000000..18264e2c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/createenvironment/AsyncCreateEnvironment.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_createenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.longrunning.Operation; + +public class AsyncCreateEnvironment { + + public static void main(String[] args) throws Exception { + asyncCreateEnvironment(); + } + + public static void asyncCreateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + CreateEnvironmentRequest request = + CreateEnvironmentRequest.newBuilder() + .setParent("parent-995424086") + .setEnvironment(Environment.newBuilder().build()) + .build(); + ApiFuture future = + environmentsClient.createEnvironmentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END service_v1_generated_environmentsclient_createenvironment_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/createenvironment/AsyncCreateEnvironmentLRO.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/createenvironment/AsyncCreateEnvironmentLRO.java new file mode 100644 index 00000000..da6fe425 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/createenvironment/AsyncCreateEnvironmentLRO.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_createenvironment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1.OperationMetadata; + +public class AsyncCreateEnvironmentLRO { + + public static void main(String[] args) throws Exception { + asyncCreateEnvironmentLRO(); + } + + public static void asyncCreateEnvironmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + CreateEnvironmentRequest request = + CreateEnvironmentRequest.newBuilder() + .setParent("parent-995424086") + .setEnvironment(Environment.newBuilder().build()) + .build(); + OperationFuture future = + environmentsClient.createEnvironmentOperationCallable().futureCall(request); + // Do something. + Environment response = future.get(); + } + } +} +// [END service_v1_generated_environmentsclient_createenvironment_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/createenvironment/SyncCreateEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/createenvironment/SyncCreateEnvironment.java new file mode 100644 index 00000000..61a8cfe3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/createenvironment/SyncCreateEnvironment.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_createenvironment_sync] +import com.google.cloud.orchestration.airflow.service.v1.CreateEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; + +public class SyncCreateEnvironment { + + public static void main(String[] args) throws Exception { + syncCreateEnvironment(); + } + + public static void syncCreateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + CreateEnvironmentRequest request = + CreateEnvironmentRequest.newBuilder() + .setParent("parent-995424086") + .setEnvironment(Environment.newBuilder().build()) + .build(); + Environment response = environmentsClient.createEnvironmentAsync(request).get(); + } + } +} +// [END service_v1_generated_environmentsclient_createenvironment_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/createenvironment/SyncCreateEnvironmentStringEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/createenvironment/SyncCreateEnvironmentStringEnvironment.java new file mode 100644 index 00000000..101f95a6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/createenvironment/SyncCreateEnvironmentStringEnvironment.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_createenvironment_stringenvironment_sync] +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; + +public class SyncCreateEnvironmentStringEnvironment { + + public static void main(String[] args) throws Exception { + syncCreateEnvironmentStringEnvironment(); + } + + public static void syncCreateEnvironmentStringEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + String parent = "parent-995424086"; + Environment environment = Environment.newBuilder().build(); + Environment response = environmentsClient.createEnvironmentAsync(parent, environment).get(); + } + } +} +// [END service_v1_generated_environmentsclient_createenvironment_stringenvironment_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/deleteenvironment/AsyncDeleteEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/deleteenvironment/AsyncDeleteEnvironment.java new file mode 100644 index 00000000..3555647b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/deleteenvironment/AsyncDeleteEnvironment.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_deleteenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteEnvironment { + + public static void main(String[] args) throws Exception { + asyncDeleteEnvironment(); + } + + public static void asyncDeleteEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + DeleteEnvironmentRequest request = + DeleteEnvironmentRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + environmentsClient.deleteEnvironmentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END service_v1_generated_environmentsclient_deleteenvironment_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/deleteenvironment/AsyncDeleteEnvironmentLRO.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/deleteenvironment/AsyncDeleteEnvironmentLRO.java new file mode 100644 index 00000000..9d0c9627 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/deleteenvironment/AsyncDeleteEnvironmentLRO.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_deleteenvironment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteEnvironmentLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteEnvironmentLRO(); + } + + public static void asyncDeleteEnvironmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + DeleteEnvironmentRequest request = + DeleteEnvironmentRequest.newBuilder().setName("name3373707").build(); + OperationFuture future = + environmentsClient.deleteEnvironmentOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END service_v1_generated_environmentsclient_deleteenvironment_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/deleteenvironment/SyncDeleteEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/deleteenvironment/SyncDeleteEnvironment.java new file mode 100644 index 00000000..12268034 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/deleteenvironment/SyncDeleteEnvironment.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_deleteenvironment_sync] +import com.google.cloud.orchestration.airflow.service.v1.DeleteEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; + +public class SyncDeleteEnvironment { + + public static void main(String[] args) throws Exception { + syncDeleteEnvironment(); + } + + public static void syncDeleteEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + DeleteEnvironmentRequest request = + DeleteEnvironmentRequest.newBuilder().setName("name3373707").build(); + environmentsClient.deleteEnvironmentAsync(request).get(); + } + } +} +// [END service_v1_generated_environmentsclient_deleteenvironment_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/deleteenvironment/SyncDeleteEnvironmentString.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/deleteenvironment/SyncDeleteEnvironmentString.java new file mode 100644 index 00000000..cde50771 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/deleteenvironment/SyncDeleteEnvironmentString.java @@ -0,0 +1,37 @@ +/* + * 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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_deleteenvironment_string_sync] +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; + +public class SyncDeleteEnvironmentString { + + public static void main(String[] args) throws Exception { + syncDeleteEnvironmentString(); + } + + public static void syncDeleteEnvironmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + String name = "name3373707"; + environmentsClient.deleteEnvironmentAsync(name).get(); + } + } +} +// [END service_v1_generated_environmentsclient_deleteenvironment_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/getenvironment/AsyncGetEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/getenvironment/AsyncGetEnvironment.java new file mode 100644 index 00000000..561f7629 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/getenvironment/AsyncGetEnvironment.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_getenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest; + +public class AsyncGetEnvironment { + + public static void main(String[] args) throws Exception { + asyncGetEnvironment(); + } + + public static void asyncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + GetEnvironmentRequest request = + GetEnvironmentRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + environmentsClient.getEnvironmentCallable().futureCall(request); + // Do something. + Environment response = future.get(); + } + } +} +// [END service_v1_generated_environmentsclient_getenvironment_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/getenvironment/SyncGetEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/getenvironment/SyncGetEnvironment.java new file mode 100644 index 00000000..cf097e59 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/getenvironment/SyncGetEnvironment.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_getenvironment_sync] +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1.GetEnvironmentRequest; + +public class SyncGetEnvironment { + + public static void main(String[] args) throws Exception { + syncGetEnvironment(); + } + + public static void syncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + GetEnvironmentRequest request = + GetEnvironmentRequest.newBuilder().setName("name3373707").build(); + Environment response = environmentsClient.getEnvironment(request); + } + } +} +// [END service_v1_generated_environmentsclient_getenvironment_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/getenvironment/SyncGetEnvironmentString.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/getenvironment/SyncGetEnvironmentString.java new file mode 100644 index 00000000..dc1b426f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/getenvironment/SyncGetEnvironmentString.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_getenvironment_string_sync] +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; + +public class SyncGetEnvironmentString { + + public static void main(String[] args) throws Exception { + syncGetEnvironmentString(); + } + + public static void syncGetEnvironmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + String name = "name3373707"; + Environment response = environmentsClient.getEnvironment(name); + } + } +} +// [END service_v1_generated_environmentsclient_getenvironment_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/listenvironments/AsyncListEnvironments.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/listenvironments/AsyncListEnvironments.java new file mode 100644 index 00000000..6d44a058 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/listenvironments/AsyncListEnvironments.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_listenvironments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest; + +public class AsyncListEnvironments { + + public static void main(String[] args) throws Exception { + asyncListEnvironments(); + } + + public static void asyncListEnvironments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + ListEnvironmentsRequest request = + ListEnvironmentsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + environmentsClient.listEnvironmentsPagedCallable().futureCall(request); + // Do something. + for (Environment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END service_v1_generated_environmentsclient_listenvironments_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/listenvironments/AsyncListEnvironmentsPaged.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/listenvironments/AsyncListEnvironmentsPaged.java new file mode 100644 index 00000000..da5a5c91 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/listenvironments/AsyncListEnvironmentsPaged.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_listenvironments_paged_async] +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest; +import com.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsResponse; +import com.google.common.base.Strings; + +public class AsyncListEnvironmentsPaged { + + public static void main(String[] args) throws Exception { + asyncListEnvironmentsPaged(); + } + + public static void asyncListEnvironmentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + ListEnvironmentsRequest request = + ListEnvironmentsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListEnvironmentsResponse response = + environmentsClient.listEnvironmentsCallable().call(request); + for (Environment element : response.getEnvironmentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END service_v1_generated_environmentsclient_listenvironments_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/listenvironments/SyncListEnvironments.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/listenvironments/SyncListEnvironments.java new file mode 100644 index 00000000..af81ba09 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/listenvironments/SyncListEnvironments.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_listenvironments_sync] +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1.ListEnvironmentsRequest; + +public class SyncListEnvironments { + + public static void main(String[] args) throws Exception { + syncListEnvironments(); + } + + public static void syncListEnvironments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + ListEnvironmentsRequest request = + ListEnvironmentsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Environment element : environmentsClient.listEnvironments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END service_v1_generated_environmentsclient_listenvironments_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/listenvironments/SyncListEnvironmentsString.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/listenvironments/SyncListEnvironmentsString.java new file mode 100644 index 00000000..aa9e5269 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/listenvironments/SyncListEnvironmentsString.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_listenvironments_string_sync] +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; + +public class SyncListEnvironmentsString { + + public static void main(String[] args) throws Exception { + syncListEnvironmentsString(); + } + + public static void syncListEnvironmentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + String parent = "parent-995424086"; + for (Environment element : environmentsClient.listEnvironments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END service_v1_generated_environmentsclient_listenvironments_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/updateenvironment/AsyncUpdateEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/updateenvironment/AsyncUpdateEnvironment.java new file mode 100644 index 00000000..97616cd8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/updateenvironment/AsyncUpdateEnvironment.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_updateenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateEnvironment { + + public static void main(String[] args) throws Exception { + asyncUpdateEnvironment(); + } + + public static void asyncUpdateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + UpdateEnvironmentRequest request = + UpdateEnvironmentRequest.newBuilder() + .setName("name3373707") + .setEnvironment(Environment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + environmentsClient.updateEnvironmentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END service_v1_generated_environmentsclient_updateenvironment_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/updateenvironment/AsyncUpdateEnvironmentLRO.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/updateenvironment/AsyncUpdateEnvironmentLRO.java new file mode 100644 index 00000000..e32431c3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/updateenvironment/AsyncUpdateEnvironmentLRO.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_updateenvironment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1.OperationMetadata; +import com.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateEnvironmentLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateEnvironmentLRO(); + } + + public static void asyncUpdateEnvironmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + UpdateEnvironmentRequest request = + UpdateEnvironmentRequest.newBuilder() + .setName("name3373707") + .setEnvironment(Environment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + environmentsClient.updateEnvironmentOperationCallable().futureCall(request); + // Do something. + Environment response = future.get(); + } + } +} +// [END service_v1_generated_environmentsclient_updateenvironment_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/updateenvironment/SyncUpdateEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/updateenvironment/SyncUpdateEnvironment.java new file mode 100644 index 00000000..c532d642 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/updateenvironment/SyncUpdateEnvironment.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_updateenvironment_sync] +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1.UpdateEnvironmentRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateEnvironment { + + public static void main(String[] args) throws Exception { + syncUpdateEnvironment(); + } + + public static void syncUpdateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + UpdateEnvironmentRequest request = + UpdateEnvironmentRequest.newBuilder() + .setName("name3373707") + .setEnvironment(Environment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Environment response = environmentsClient.updateEnvironmentAsync(request).get(); + } + } +} +// [END service_v1_generated_environmentsclient_updateenvironment_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/updateenvironment/SyncUpdateEnvironmentStringEnvironmentFieldmask.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/updateenvironment/SyncUpdateEnvironmentStringEnvironmentFieldmask.java new file mode 100644 index 00000000..275762a3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentsclient/updateenvironment/SyncUpdateEnvironmentStringEnvironmentFieldmask.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentsclient_updateenvironment_stringenvironmentfieldmask_sync] +import com.google.cloud.orchestration.airflow.service.v1.Environment; +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateEnvironmentStringEnvironmentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateEnvironmentStringEnvironmentFieldmask(); + } + + public static void syncUpdateEnvironmentStringEnvironmentFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + String name = "name3373707"; + Environment environment = Environment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Environment response = + environmentsClient.updateEnvironmentAsync(name, environment, updateMask).get(); + } + } +} +// [END service_v1_generated_environmentsclient_updateenvironment_stringenvironmentfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentssettings/getenvironment/SyncGetEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentssettings/getenvironment/SyncGetEnvironment.java new file mode 100644 index 00000000..9e54217b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/environmentssettings/getenvironment/SyncGetEnvironment.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_environmentssettings_getenvironment_sync] +import com.google.cloud.orchestration.airflow.service.v1.EnvironmentsSettings; +import java.time.Duration; + +public class SyncGetEnvironment { + + public static void main(String[] args) throws Exception { + syncGetEnvironment(); + } + + public static void syncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EnvironmentsSettings.Builder environmentsSettingsBuilder = EnvironmentsSettings.newBuilder(); + environmentsSettingsBuilder + .getEnvironmentSettings() + .setRetrySettings( + environmentsSettingsBuilder + .getEnvironmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + EnvironmentsSettings environmentsSettings = environmentsSettingsBuilder.build(); + } +} +// [END service_v1_generated_environmentssettings_getenvironment_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..23b27f63 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_imageversionsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.orchestration.airflow.service.v1.ImageVersionsClient; +import com.google.cloud.orchestration.airflow.service.v1.ImageVersionsSettings; +import com.google.cloud.orchestration.airflow.service.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. + ImageVersionsSettings imageVersionsSettings = + ImageVersionsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ImageVersionsClient imageVersionsClient = ImageVersionsClient.create(imageVersionsSettings); + } +} +// [END service_v1_generated_imageversionsclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..117998b1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_imageversionsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.orchestration.airflow.service.v1.ImageVersionsClient; +import com.google.cloud.orchestration.airflow.service.v1.ImageVersionsSettings; + +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. + ImageVersionsSettings imageVersionsSettings = + ImageVersionsSettings.newBuilder() + .setTransportChannelProvider( + ImageVersionsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ImageVersionsClient imageVersionsClient = ImageVersionsClient.create(imageVersionsSettings); + } +} +// [END service_v1_generated_imageversionsclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..039a87ca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_imageversionsclient_create_setendpoint_sync] +import com.google.cloud.orchestration.airflow.service.v1.ImageVersionsClient; +import com.google.cloud.orchestration.airflow.service.v1.ImageVersionsSettings; +import com.google.cloud.orchestration.airflow.service.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. + ImageVersionsSettings imageVersionsSettings = + ImageVersionsSettings.newBuilder().setEndpoint(myEndpoint).build(); + ImageVersionsClient imageVersionsClient = ImageVersionsClient.create(imageVersionsSettings); + } +} +// [END service_v1_generated_imageversionsclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/listimageversions/AsyncListImageVersions.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/listimageversions/AsyncListImageVersions.java new file mode 100644 index 00000000..e84129ab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/listimageversions/AsyncListImageVersions.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_imageversionsclient_listimageversions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.orchestration.airflow.service.v1.ImageVersion; +import com.google.cloud.orchestration.airflow.service.v1.ImageVersionsClient; +import com.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest; + +public class AsyncListImageVersions { + + public static void main(String[] args) throws Exception { + asyncListImageVersions(); + } + + public static void asyncListImageVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageVersionsClient imageVersionsClient = ImageVersionsClient.create()) { + ListImageVersionsRequest request = + ListImageVersionsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setIncludePastReleases(true) + .build(); + ApiFuture future = + imageVersionsClient.listImageVersionsPagedCallable().futureCall(request); + // Do something. + for (ImageVersion element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END service_v1_generated_imageversionsclient_listimageversions_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/listimageversions/AsyncListImageVersionsPaged.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/listimageversions/AsyncListImageVersionsPaged.java new file mode 100644 index 00000000..da081f87 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/listimageversions/AsyncListImageVersionsPaged.java @@ -0,0 +1,59 @@ +/* + * 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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_imageversionsclient_listimageversions_paged_async] +import com.google.cloud.orchestration.airflow.service.v1.ImageVersion; +import com.google.cloud.orchestration.airflow.service.v1.ImageVersionsClient; +import com.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest; +import com.google.cloud.orchestration.airflow.service.v1.ListImageVersionsResponse; +import com.google.common.base.Strings; + +public class AsyncListImageVersionsPaged { + + public static void main(String[] args) throws Exception { + asyncListImageVersionsPaged(); + } + + public static void asyncListImageVersionsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageVersionsClient imageVersionsClient = ImageVersionsClient.create()) { + ListImageVersionsRequest request = + ListImageVersionsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setIncludePastReleases(true) + .build(); + while (true) { + ListImageVersionsResponse response = + imageVersionsClient.listImageVersionsCallable().call(request); + for (ImageVersion element : response.getImageVersionsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END service_v1_generated_imageversionsclient_listimageversions_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/listimageversions/SyncListImageVersions.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/listimageversions/SyncListImageVersions.java new file mode 100644 index 00000000..d6f93ee8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/listimageversions/SyncListImageVersions.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_imageversionsclient_listimageversions_sync] +import com.google.cloud.orchestration.airflow.service.v1.ImageVersion; +import com.google.cloud.orchestration.airflow.service.v1.ImageVersionsClient; +import com.google.cloud.orchestration.airflow.service.v1.ListImageVersionsRequest; + +public class SyncListImageVersions { + + public static void main(String[] args) throws Exception { + syncListImageVersions(); + } + + public static void syncListImageVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageVersionsClient imageVersionsClient = ImageVersionsClient.create()) { + ListImageVersionsRequest request = + ListImageVersionsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setIncludePastReleases(true) + .build(); + for (ImageVersion element : imageVersionsClient.listImageVersions(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END service_v1_generated_imageversionsclient_listimageversions_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/listimageversions/SyncListImageVersionsString.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/listimageversions/SyncListImageVersionsString.java new file mode 100644 index 00000000..8467c099 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionsclient/listimageversions/SyncListImageVersionsString.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_imageversionsclient_listimageversions_string_sync] +import com.google.cloud.orchestration.airflow.service.v1.ImageVersion; +import com.google.cloud.orchestration.airflow.service.v1.ImageVersionsClient; + +public class SyncListImageVersionsString { + + public static void main(String[] args) throws Exception { + syncListImageVersionsString(); + } + + public static void syncListImageVersionsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageVersionsClient imageVersionsClient = ImageVersionsClient.create()) { + String parent = "parent-995424086"; + for (ImageVersion element : imageVersionsClient.listImageVersions(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END service_v1_generated_imageversionsclient_listimageversions_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionssettings/listimageversions/SyncListImageVersions.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionssettings/listimageversions/SyncListImageVersions.java new file mode 100644 index 00000000..f1e17f90 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/imageversionssettings/listimageversions/SyncListImageVersions.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.orchestration.airflow.service.v1.samples; + +// [START service_v1_generated_imageversionssettings_listimageversions_sync] +import com.google.cloud.orchestration.airflow.service.v1.ImageVersionsSettings; +import java.time.Duration; + +public class SyncListImageVersions { + + public static void main(String[] args) throws Exception { + syncListImageVersions(); + } + + public static void syncListImageVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageVersionsSettings.Builder imageVersionsSettingsBuilder = ImageVersionsSettings.newBuilder(); + imageVersionsSettingsBuilder + .listImageVersionsSettings() + .setRetrySettings( + imageVersionsSettingsBuilder + .listImageVersionsSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ImageVersionsSettings imageVersionsSettings = imageVersionsSettingsBuilder.build(); + } +} +// [END service_v1_generated_imageversionssettings_listimageversions_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/stub/environmentsstubsettings/getenvironment/SyncGetEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/stub/environmentsstubsettings/getenvironment/SyncGetEnvironment.java new file mode 100644 index 00000000..38a0bcf8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/stub/environmentsstubsettings/getenvironment/SyncGetEnvironment.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.orchestration.airflow.service.v1.stub.samples; + +// [START service_v1_generated_environmentsstubsettings_getenvironment_sync] +import com.google.cloud.orchestration.airflow.service.v1.stub.EnvironmentsStubSettings; +import java.time.Duration; + +public class SyncGetEnvironment { + + public static void main(String[] args) throws Exception { + syncGetEnvironment(); + } + + public static void syncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EnvironmentsStubSettings.Builder environmentsSettingsBuilder = + EnvironmentsStubSettings.newBuilder(); + environmentsSettingsBuilder + .getEnvironmentSettings() + .setRetrySettings( + environmentsSettingsBuilder + .getEnvironmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + EnvironmentsStubSettings environmentsSettings = environmentsSettingsBuilder.build(); + } +} +// [END service_v1_generated_environmentsstubsettings_getenvironment_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/stub/imageversionsstubsettings/listimageversions/SyncListImageVersions.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/stub/imageversionsstubsettings/listimageversions/SyncListImageVersions.java new file mode 100644 index 00000000..536414a6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1/stub/imageversionsstubsettings/listimageversions/SyncListImageVersions.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.orchestration.airflow.service.v1.stub.samples; + +// [START service_v1_generated_imageversionsstubsettings_listimageversions_sync] +import com.google.cloud.orchestration.airflow.service.v1.stub.ImageVersionsStubSettings; +import java.time.Duration; + +public class SyncListImageVersions { + + public static void main(String[] args) throws Exception { + syncListImageVersions(); + } + + public static void syncListImageVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageVersionsStubSettings.Builder imageVersionsSettingsBuilder = + ImageVersionsStubSettings.newBuilder(); + imageVersionsSettingsBuilder + .listImageVersionsSettings() + .setRetrySettings( + imageVersionsSettingsBuilder + .listImageVersionsSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ImageVersionsStubSettings imageVersionsSettings = imageVersionsSettingsBuilder.build(); + } +} +// [END service_v1_generated_imageversionsstubsettings_listimageversions_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/checkupgrade/AsyncCheckUpgrade.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/checkupgrade/AsyncCheckUpgrade.java new file mode 100644 index 00000000..566d466f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/checkupgrade/AsyncCheckUpgrade.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_checkupgrade_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.longrunning.Operation; + +public class AsyncCheckUpgrade { + + public static void main(String[] args) throws Exception { + asyncCheckUpgrade(); + } + + public static void asyncCheckUpgrade() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + CheckUpgradeRequest request = + CheckUpgradeRequest.newBuilder() + .setEnvironment("environment-85904877") + .setImageVersion("imageVersion949870333") + .build(); + ApiFuture future = environmentsClient.checkUpgradeCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_checkupgrade_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/checkupgrade/AsyncCheckUpgradeLRO.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/checkupgrade/AsyncCheckUpgradeLRO.java new file mode 100644 index 00000000..1be01ef0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/checkupgrade/AsyncCheckUpgradeLRO.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_checkupgrade_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeResponse; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata; + +public class AsyncCheckUpgradeLRO { + + public static void main(String[] args) throws Exception { + asyncCheckUpgradeLRO(); + } + + public static void asyncCheckUpgradeLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + CheckUpgradeRequest request = + CheckUpgradeRequest.newBuilder() + .setEnvironment("environment-85904877") + .setImageVersion("imageVersion949870333") + .build(); + OperationFuture future = + environmentsClient.checkUpgradeOperationCallable().futureCall(request); + // Do something. + CheckUpgradeResponse response = future.get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_checkupgrade_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/checkupgrade/SyncCheckUpgrade.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/checkupgrade/SyncCheckUpgrade.java new file mode 100644 index 00000000..8d2de0a9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/checkupgrade/SyncCheckUpgrade.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_checkupgrade_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.CheckUpgradeResponse; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; + +public class SyncCheckUpgrade { + + public static void main(String[] args) throws Exception { + syncCheckUpgrade(); + } + + public static void syncCheckUpgrade() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + CheckUpgradeRequest request = + CheckUpgradeRequest.newBuilder() + .setEnvironment("environment-85904877") + .setImageVersion("imageVersion949870333") + .build(); + CheckUpgradeResponse response = environmentsClient.checkUpgradeAsync(request).get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_checkupgrade_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..607981c6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsSettings; +import com.google.cloud.orchestration.airflow.service.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. + EnvironmentsSettings environmentsSettings = + EnvironmentsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); + } +} +// [END service_v1beta1_generated_environmentsclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..5e0e9e77 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsSettings; + +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. + EnvironmentsSettings environmentsSettings = + EnvironmentsSettings.newBuilder() + .setTransportChannelProvider( + EnvironmentsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); + } +} +// [END service_v1beta1_generated_environmentsclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..d27682a9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_create_setendpoint_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsSettings; +import com.google.cloud.orchestration.airflow.service.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. + EnvironmentsSettings environmentsSettings = + EnvironmentsSettings.newBuilder().setEndpoint(myEndpoint).build(); + EnvironmentsClient environmentsClient = EnvironmentsClient.create(environmentsSettings); + } +} +// [END service_v1beta1_generated_environmentsclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/createenvironment/AsyncCreateEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/createenvironment/AsyncCreateEnvironment.java new file mode 100644 index 00000000..f7a9662b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/createenvironment/AsyncCreateEnvironment.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_createenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.longrunning.Operation; + +public class AsyncCreateEnvironment { + + public static void main(String[] args) throws Exception { + asyncCreateEnvironment(); + } + + public static void asyncCreateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + CreateEnvironmentRequest request = + CreateEnvironmentRequest.newBuilder() + .setParent("parent-995424086") + .setEnvironment(Environment.newBuilder().build()) + .build(); + ApiFuture future = + environmentsClient.createEnvironmentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_createenvironment_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/createenvironment/AsyncCreateEnvironmentLRO.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/createenvironment/AsyncCreateEnvironmentLRO.java new file mode 100644 index 00000000..7883c067 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/createenvironment/AsyncCreateEnvironmentLRO.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_createenvironment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata; + +public class AsyncCreateEnvironmentLRO { + + public static void main(String[] args) throws Exception { + asyncCreateEnvironmentLRO(); + } + + public static void asyncCreateEnvironmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + CreateEnvironmentRequest request = + CreateEnvironmentRequest.newBuilder() + .setParent("parent-995424086") + .setEnvironment(Environment.newBuilder().build()) + .build(); + OperationFuture future = + environmentsClient.createEnvironmentOperationCallable().futureCall(request); + // Do something. + Environment response = future.get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_createenvironment_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/createenvironment/SyncCreateEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/createenvironment/SyncCreateEnvironment.java new file mode 100644 index 00000000..af17ca88 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/createenvironment/SyncCreateEnvironment.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_createenvironment_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.CreateEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; + +public class SyncCreateEnvironment { + + public static void main(String[] args) throws Exception { + syncCreateEnvironment(); + } + + public static void syncCreateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + CreateEnvironmentRequest request = + CreateEnvironmentRequest.newBuilder() + .setParent("parent-995424086") + .setEnvironment(Environment.newBuilder().build()) + .build(); + Environment response = environmentsClient.createEnvironmentAsync(request).get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_createenvironment_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/createenvironment/SyncCreateEnvironmentStringEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/createenvironment/SyncCreateEnvironmentStringEnvironment.java new file mode 100644 index 00000000..b2f25eca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/createenvironment/SyncCreateEnvironmentStringEnvironment.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_createenvironment_stringenvironment_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; + +public class SyncCreateEnvironmentStringEnvironment { + + public static void main(String[] args) throws Exception { + syncCreateEnvironmentStringEnvironment(); + } + + public static void syncCreateEnvironmentStringEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + String parent = "parent-995424086"; + Environment environment = Environment.newBuilder().build(); + Environment response = environmentsClient.createEnvironmentAsync(parent, environment).get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_createenvironment_stringenvironment_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/deleteenvironment/AsyncDeleteEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/deleteenvironment/AsyncDeleteEnvironment.java new file mode 100644 index 00000000..d0ecbf6b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/deleteenvironment/AsyncDeleteEnvironment.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_deleteenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteEnvironment { + + public static void main(String[] args) throws Exception { + asyncDeleteEnvironment(); + } + + public static void asyncDeleteEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + DeleteEnvironmentRequest request = + DeleteEnvironmentRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + environmentsClient.deleteEnvironmentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_deleteenvironment_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/deleteenvironment/AsyncDeleteEnvironmentLRO.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/deleteenvironment/AsyncDeleteEnvironmentLRO.java new file mode 100644 index 00000000..36bc65ba --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/deleteenvironment/AsyncDeleteEnvironmentLRO.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_deleteenvironment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteEnvironmentLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteEnvironmentLRO(); + } + + public static void asyncDeleteEnvironmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + DeleteEnvironmentRequest request = + DeleteEnvironmentRequest.newBuilder().setName("name3373707").build(); + OperationFuture future = + environmentsClient.deleteEnvironmentOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_deleteenvironment_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/deleteenvironment/SyncDeleteEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/deleteenvironment/SyncDeleteEnvironment.java new file mode 100644 index 00000000..2d1c807e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/deleteenvironment/SyncDeleteEnvironment.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_deleteenvironment_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.DeleteEnvironmentRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; + +public class SyncDeleteEnvironment { + + public static void main(String[] args) throws Exception { + syncDeleteEnvironment(); + } + + public static void syncDeleteEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + DeleteEnvironmentRequest request = + DeleteEnvironmentRequest.newBuilder().setName("name3373707").build(); + environmentsClient.deleteEnvironmentAsync(request).get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_deleteenvironment_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/deleteenvironment/SyncDeleteEnvironmentString.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/deleteenvironment/SyncDeleteEnvironmentString.java new file mode 100644 index 00000000..c870a938 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/deleteenvironment/SyncDeleteEnvironmentString.java @@ -0,0 +1,37 @@ +/* + * 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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_deleteenvironment_string_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; + +public class SyncDeleteEnvironmentString { + + public static void main(String[] args) throws Exception { + syncDeleteEnvironmentString(); + } + + public static void syncDeleteEnvironmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + String name = "name3373707"; + environmentsClient.deleteEnvironmentAsync(name).get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_deleteenvironment_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/getenvironment/AsyncGetEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/getenvironment/AsyncGetEnvironment.java new file mode 100644 index 00000000..ff2dd8db --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/getenvironment/AsyncGetEnvironment.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_getenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest; + +public class AsyncGetEnvironment { + + public static void main(String[] args) throws Exception { + asyncGetEnvironment(); + } + + public static void asyncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + GetEnvironmentRequest request = + GetEnvironmentRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + environmentsClient.getEnvironmentCallable().futureCall(request); + // Do something. + Environment response = future.get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_getenvironment_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/getenvironment/SyncGetEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/getenvironment/SyncGetEnvironment.java new file mode 100644 index 00000000..debe73bb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/getenvironment/SyncGetEnvironment.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_getenvironment_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.GetEnvironmentRequest; + +public class SyncGetEnvironment { + + public static void main(String[] args) throws Exception { + syncGetEnvironment(); + } + + public static void syncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + GetEnvironmentRequest request = + GetEnvironmentRequest.newBuilder().setName("name3373707").build(); + Environment response = environmentsClient.getEnvironment(request); + } + } +} +// [END service_v1beta1_generated_environmentsclient_getenvironment_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/getenvironment/SyncGetEnvironmentString.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/getenvironment/SyncGetEnvironmentString.java new file mode 100644 index 00000000..9a03faf9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/getenvironment/SyncGetEnvironmentString.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_getenvironment_string_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; + +public class SyncGetEnvironmentString { + + public static void main(String[] args) throws Exception { + syncGetEnvironmentString(); + } + + public static void syncGetEnvironmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + String name = "name3373707"; + Environment response = environmentsClient.getEnvironment(name); + } + } +} +// [END service_v1beta1_generated_environmentsclient_getenvironment_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/listenvironments/AsyncListEnvironments.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/listenvironments/AsyncListEnvironments.java new file mode 100644 index 00000000..fa008d5b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/listenvironments/AsyncListEnvironments.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_listenvironments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest; + +public class AsyncListEnvironments { + + public static void main(String[] args) throws Exception { + asyncListEnvironments(); + } + + public static void asyncListEnvironments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + ListEnvironmentsRequest request = + ListEnvironmentsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + environmentsClient.listEnvironmentsPagedCallable().futureCall(request); + // Do something. + for (Environment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END service_v1beta1_generated_environmentsclient_listenvironments_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/listenvironments/AsyncListEnvironmentsPaged.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/listenvironments/AsyncListEnvironmentsPaged.java new file mode 100644 index 00000000..0757807f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/listenvironments/AsyncListEnvironmentsPaged.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_listenvironments_paged_async] +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsResponse; +import com.google.common.base.Strings; + +public class AsyncListEnvironmentsPaged { + + public static void main(String[] args) throws Exception { + asyncListEnvironmentsPaged(); + } + + public static void asyncListEnvironmentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + ListEnvironmentsRequest request = + ListEnvironmentsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListEnvironmentsResponse response = + environmentsClient.listEnvironmentsCallable().call(request); + for (Environment element : response.getEnvironmentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END service_v1beta1_generated_environmentsclient_listenvironments_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/listenvironments/SyncListEnvironments.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/listenvironments/SyncListEnvironments.java new file mode 100644 index 00000000..bbe507c7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/listenvironments/SyncListEnvironments.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_listenvironments_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.ListEnvironmentsRequest; + +public class SyncListEnvironments { + + public static void main(String[] args) throws Exception { + syncListEnvironments(); + } + + public static void syncListEnvironments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + ListEnvironmentsRequest request = + ListEnvironmentsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Environment element : environmentsClient.listEnvironments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END service_v1beta1_generated_environmentsclient_listenvironments_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/listenvironments/SyncListEnvironmentsString.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/listenvironments/SyncListEnvironmentsString.java new file mode 100644 index 00000000..448494f4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/listenvironments/SyncListEnvironmentsString.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_listenvironments_string_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; + +public class SyncListEnvironmentsString { + + public static void main(String[] args) throws Exception { + syncListEnvironmentsString(); + } + + public static void syncListEnvironmentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + String parent = "parent-995424086"; + for (Environment element : environmentsClient.listEnvironments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END service_v1beta1_generated_environmentsclient_listenvironments_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/restartwebserver/AsyncRestartWebServer.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/restartwebserver/AsyncRestartWebServer.java new file mode 100644 index 00000000..c847f54d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/restartwebserver/AsyncRestartWebServer.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_restartwebserver_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest; +import com.google.longrunning.Operation; + +public class AsyncRestartWebServer { + + public static void main(String[] args) throws Exception { + asyncRestartWebServer(); + } + + public static void asyncRestartWebServer() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + RestartWebServerRequest request = + RestartWebServerRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + environmentsClient.restartWebServerCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_restartwebserver_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/restartwebserver/AsyncRestartWebServerLRO.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/restartwebserver/AsyncRestartWebServerLRO.java new file mode 100644 index 00000000..bcf54c7c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/restartwebserver/AsyncRestartWebServerLRO.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_restartwebserver_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata; +import com.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest; + +public class AsyncRestartWebServerLRO { + + public static void main(String[] args) throws Exception { + asyncRestartWebServerLRO(); + } + + public static void asyncRestartWebServerLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + RestartWebServerRequest request = + RestartWebServerRequest.newBuilder().setName("name3373707").build(); + OperationFuture future = + environmentsClient.restartWebServerOperationCallable().futureCall(request); + // Do something. + Environment response = future.get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_restartwebserver_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/restartwebserver/SyncRestartWebServer.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/restartwebserver/SyncRestartWebServer.java new file mode 100644 index 00000000..00cacdec --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/restartwebserver/SyncRestartWebServer.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_restartwebserver_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.RestartWebServerRequest; + +public class SyncRestartWebServer { + + public static void main(String[] args) throws Exception { + syncRestartWebServer(); + } + + public static void syncRestartWebServer() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + RestartWebServerRequest request = + RestartWebServerRequest.newBuilder().setName("name3373707").build(); + Environment response = environmentsClient.restartWebServerAsync(request).get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_restartwebserver_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/updateenvironment/AsyncUpdateEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/updateenvironment/AsyncUpdateEnvironment.java new file mode 100644 index 00000000..380839fc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/updateenvironment/AsyncUpdateEnvironment.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_updateenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateEnvironment { + + public static void main(String[] args) throws Exception { + asyncUpdateEnvironment(); + } + + public static void asyncUpdateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + UpdateEnvironmentRequest request = + UpdateEnvironmentRequest.newBuilder() + .setName("name3373707") + .setEnvironment(Environment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + environmentsClient.updateEnvironmentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_updateenvironment_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/updateenvironment/AsyncUpdateEnvironmentLRO.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/updateenvironment/AsyncUpdateEnvironmentLRO.java new file mode 100644 index 00000000..4cb27d20 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/updateenvironment/AsyncUpdateEnvironmentLRO.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_updateenvironment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.OperationMetadata; +import com.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateEnvironmentLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateEnvironmentLRO(); + } + + public static void asyncUpdateEnvironmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + UpdateEnvironmentRequest request = + UpdateEnvironmentRequest.newBuilder() + .setName("name3373707") + .setEnvironment(Environment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + environmentsClient.updateEnvironmentOperationCallable().futureCall(request); + // Do something. + Environment response = future.get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_updateenvironment_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/updateenvironment/SyncUpdateEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/updateenvironment/SyncUpdateEnvironment.java new file mode 100644 index 00000000..aa93408b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/updateenvironment/SyncUpdateEnvironment.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentsclient_updateenvironment_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.UpdateEnvironmentRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateEnvironment { + + public static void main(String[] args) throws Exception { + syncUpdateEnvironment(); + } + + public static void syncUpdateEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + UpdateEnvironmentRequest request = + UpdateEnvironmentRequest.newBuilder() + .setName("name3373707") + .setEnvironment(Environment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Environment response = environmentsClient.updateEnvironmentAsync(request).get(); + } + } +} +// [END service_v1beta1_generated_environmentsclient_updateenvironment_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/updateenvironment/SyncUpdateEnvironmentStringEnvironmentFieldmask.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/updateenvironment/SyncUpdateEnvironmentStringEnvironmentFieldmask.java new file mode 100644 index 00000000..76827027 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentsclient/updateenvironment/SyncUpdateEnvironmentStringEnvironmentFieldmask.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.orchestration.airflow.service.v1beta1.samples; + +// [START +// service_v1beta1_generated_environmentsclient_updateenvironment_stringenvironmentfieldmask_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.Environment; +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateEnvironmentStringEnvironmentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateEnvironmentStringEnvironmentFieldmask(); + } + + public static void syncUpdateEnvironmentStringEnvironmentFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (EnvironmentsClient environmentsClient = EnvironmentsClient.create()) { + String name = "name3373707"; + Environment environment = Environment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Environment response = + environmentsClient.updateEnvironmentAsync(name, environment, updateMask).get(); + } + } +} +// [END +// service_v1beta1_generated_environmentsclient_updateenvironment_stringenvironmentfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentssettings/getenvironment/SyncGetEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentssettings/getenvironment/SyncGetEnvironment.java new file mode 100644 index 00000000..3e9dc450 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/environmentssettings/getenvironment/SyncGetEnvironment.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_environmentssettings_getenvironment_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.EnvironmentsSettings; +import java.time.Duration; + +public class SyncGetEnvironment { + + public static void main(String[] args) throws Exception { + syncGetEnvironment(); + } + + public static void syncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EnvironmentsSettings.Builder environmentsSettingsBuilder = EnvironmentsSettings.newBuilder(); + environmentsSettingsBuilder + .getEnvironmentSettings() + .setRetrySettings( + environmentsSettingsBuilder + .getEnvironmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + EnvironmentsSettings environmentsSettings = environmentsSettingsBuilder.build(); + } +} +// [END service_v1beta1_generated_environmentssettings_getenvironment_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..7fd589b5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_imageversionsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsSettings; +import com.google.cloud.orchestration.airflow.service.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. + ImageVersionsSettings imageVersionsSettings = + ImageVersionsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ImageVersionsClient imageVersionsClient = ImageVersionsClient.create(imageVersionsSettings); + } +} +// [END service_v1beta1_generated_imageversionsclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..5148d761 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_imageversionsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsSettings; + +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. + ImageVersionsSettings imageVersionsSettings = + ImageVersionsSettings.newBuilder() + .setTransportChannelProvider( + ImageVersionsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ImageVersionsClient imageVersionsClient = ImageVersionsClient.create(imageVersionsSettings); + } +} +// [END service_v1beta1_generated_imageversionsclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..b9698340 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_imageversionsclient_create_setendpoint_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsSettings; +import com.google.cloud.orchestration.airflow.service.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. + ImageVersionsSettings imageVersionsSettings = + ImageVersionsSettings.newBuilder().setEndpoint(myEndpoint).build(); + ImageVersionsClient imageVersionsClient = ImageVersionsClient.create(imageVersionsSettings); + } +} +// [END service_v1beta1_generated_imageversionsclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/listimageversions/AsyncListImageVersions.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/listimageversions/AsyncListImageVersions.java new file mode 100644 index 00000000..2e18f771 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/listimageversions/AsyncListImageVersions.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_imageversionsclient_listimageversions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion; +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest; + +public class AsyncListImageVersions { + + public static void main(String[] args) throws Exception { + asyncListImageVersions(); + } + + public static void asyncListImageVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageVersionsClient imageVersionsClient = ImageVersionsClient.create()) { + ListImageVersionsRequest request = + ListImageVersionsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setIncludePastReleases(true) + .build(); + ApiFuture future = + imageVersionsClient.listImageVersionsPagedCallable().futureCall(request); + // Do something. + for (ImageVersion element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END service_v1beta1_generated_imageversionsclient_listimageversions_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/listimageversions/AsyncListImageVersionsPaged.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/listimageversions/AsyncListImageVersionsPaged.java new file mode 100644 index 00000000..073fac3d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/listimageversions/AsyncListImageVersionsPaged.java @@ -0,0 +1,59 @@ +/* + * 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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_imageversionsclient_listimageversions_paged_async] +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion; +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest; +import com.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsResponse; +import com.google.common.base.Strings; + +public class AsyncListImageVersionsPaged { + + public static void main(String[] args) throws Exception { + asyncListImageVersionsPaged(); + } + + public static void asyncListImageVersionsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageVersionsClient imageVersionsClient = ImageVersionsClient.create()) { + ListImageVersionsRequest request = + ListImageVersionsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setIncludePastReleases(true) + .build(); + while (true) { + ListImageVersionsResponse response = + imageVersionsClient.listImageVersionsCallable().call(request); + for (ImageVersion element : response.getImageVersionsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END service_v1beta1_generated_imageversionsclient_listimageversions_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/listimageversions/SyncListImageVersions.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/listimageversions/SyncListImageVersions.java new file mode 100644 index 00000000..3d6804f6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/listimageversions/SyncListImageVersions.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_imageversionsclient_listimageversions_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion; +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsClient; +import com.google.cloud.orchestration.airflow.service.v1beta1.ListImageVersionsRequest; + +public class SyncListImageVersions { + + public static void main(String[] args) throws Exception { + syncListImageVersions(); + } + + public static void syncListImageVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageVersionsClient imageVersionsClient = ImageVersionsClient.create()) { + ListImageVersionsRequest request = + ListImageVersionsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setIncludePastReleases(true) + .build(); + for (ImageVersion element : imageVersionsClient.listImageVersions(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END service_v1beta1_generated_imageversionsclient_listimageversions_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/listimageversions/SyncListImageVersionsString.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/listimageversions/SyncListImageVersionsString.java new file mode 100644 index 00000000..d696ca3a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionsclient/listimageversions/SyncListImageVersionsString.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_imageversionsclient_listimageversions_string_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersion; +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsClient; + +public class SyncListImageVersionsString { + + public static void main(String[] args) throws Exception { + syncListImageVersionsString(); + } + + public static void syncListImageVersionsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ImageVersionsClient imageVersionsClient = ImageVersionsClient.create()) { + String parent = "parent-995424086"; + for (ImageVersion element : imageVersionsClient.listImageVersions(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END service_v1beta1_generated_imageversionsclient_listimageversions_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionssettings/listimageversions/SyncListImageVersions.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionssettings/listimageversions/SyncListImageVersions.java new file mode 100644 index 00000000..7a0fa06e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/imageversionssettings/listimageversions/SyncListImageVersions.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.orchestration.airflow.service.v1beta1.samples; + +// [START service_v1beta1_generated_imageversionssettings_listimageversions_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.ImageVersionsSettings; +import java.time.Duration; + +public class SyncListImageVersions { + + public static void main(String[] args) throws Exception { + syncListImageVersions(); + } + + public static void syncListImageVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageVersionsSettings.Builder imageVersionsSettingsBuilder = ImageVersionsSettings.newBuilder(); + imageVersionsSettingsBuilder + .listImageVersionsSettings() + .setRetrySettings( + imageVersionsSettingsBuilder + .listImageVersionsSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ImageVersionsSettings imageVersionsSettings = imageVersionsSettingsBuilder.build(); + } +} +// [END service_v1beta1_generated_imageversionssettings_listimageversions_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/stub/environmentsstubsettings/getenvironment/SyncGetEnvironment.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/stub/environmentsstubsettings/getenvironment/SyncGetEnvironment.java new file mode 100644 index 00000000..17ccc552 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/stub/environmentsstubsettings/getenvironment/SyncGetEnvironment.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.orchestration.airflow.service.v1beta1.stub.samples; + +// [START service_v1beta1_generated_environmentsstubsettings_getenvironment_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.stub.EnvironmentsStubSettings; +import java.time.Duration; + +public class SyncGetEnvironment { + + public static void main(String[] args) throws Exception { + syncGetEnvironment(); + } + + public static void syncGetEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + EnvironmentsStubSettings.Builder environmentsSettingsBuilder = + EnvironmentsStubSettings.newBuilder(); + environmentsSettingsBuilder + .getEnvironmentSettings() + .setRetrySettings( + environmentsSettingsBuilder + .getEnvironmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + EnvironmentsStubSettings environmentsSettings = environmentsSettingsBuilder.build(); + } +} +// [END service_v1beta1_generated_environmentsstubsettings_getenvironment_sync] diff --git a/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/stub/imageversionsstubsettings/listimageversions/SyncListImageVersions.java b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/stub/imageversionsstubsettings/listimageversions/SyncListImageVersions.java new file mode 100644 index 00000000..6c309c8a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/orchestration/airflow/service/v1beta1/stub/imageversionsstubsettings/listimageversions/SyncListImageVersions.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.orchestration.airflow.service.v1beta1.stub.samples; + +// [START service_v1beta1_generated_imageversionsstubsettings_listimageversions_sync] +import com.google.cloud.orchestration.airflow.service.v1beta1.stub.ImageVersionsStubSettings; +import java.time.Duration; + +public class SyncListImageVersions { + + public static void main(String[] args) throws Exception { + syncListImageVersions(); + } + + public static void syncListImageVersions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ImageVersionsStubSettings.Builder imageVersionsSettingsBuilder = + ImageVersionsStubSettings.newBuilder(); + imageVersionsSettingsBuilder + .listImageVersionsSettings() + .setRetrySettings( + imageVersionsSettingsBuilder + .listImageVersionsSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ImageVersionsStubSettings imageVersionsSettings = imageVersionsSettingsBuilder.build(); + } +} +// [END service_v1beta1_generated_imageversionsstubsettings_listimageversions_sync]