diff --git a/java-shell/google-cloud-shell/pom.xml b/java-shell/google-cloud-shell/pom.xml index 8a3b5fba6600..314cb2ca3f2b 100644 --- a/java-shell/google-cloud-shell/pom.xml +++ b/java-shell/google-cloud-shell/pom.xml @@ -58,6 +58,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -77,12 +81,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/CloudShellServiceClient.java b/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/CloudShellServiceClient.java index bb2e7f226298..b1cdf23b518d 100644 --- a/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/CloudShellServiceClient.java +++ b/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/CloudShellServiceClient.java @@ -18,13 +18,13 @@ 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.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.shell.v1.stub.CloudShellServiceStub; import com.google.cloud.shell.v1.stub.CloudShellServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -100,13 +100,29 @@ * CloudShellServiceClient.create(cloudShellServiceSettings); * } * + *

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.
+ * CloudShellServiceSettings cloudShellServiceSettings =
+ *     CloudShellServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CloudShellServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CloudShellServiceClient cloudShellServiceClient =
+ *     CloudShellServiceClient.create(cloudShellServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class CloudShellServiceClient implements BackgroundResource { private final CloudShellServiceSettings settings; private final CloudShellServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of CloudShellServiceClient with default settings. */ public static final CloudShellServiceClient create() throws IOException { @@ -126,7 +142,6 @@ public static final CloudShellServiceClient create(CloudShellServiceSettings set * Constructs an instance of CloudShellServiceClient, using the given stub for making calls. This * is for advanced usage - prefer using create(CloudShellServiceSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final CloudShellServiceClient create(CloudShellServiceStub stub) { return new CloudShellServiceClient(stub); } @@ -139,21 +154,23 @@ public static final CloudShellServiceClient create(CloudShellServiceStub stub) { protected CloudShellServiceClient(CloudShellServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((CloudShellServiceStubSettings) 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()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected CloudShellServiceClient(CloudShellServiceStub 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 CloudShellServiceSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public CloudShellServiceStub getStub() { return stub; } @@ -162,10 +179,19 @@ public CloudShellServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets an environment. Returns NOT_FOUND if the environment does not exist. diff --git a/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/CloudShellServiceSettings.java b/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/CloudShellServiceSettings.java index 3d40c4f6481e..48cb7c578601 100644 --- a/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/CloudShellServiceSettings.java +++ b/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/CloudShellServiceSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -148,11 +149,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CloudShellServiceStubSettings.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 CloudShellServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CloudShellServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CloudShellServiceStubSettings.defaultTransportChannelProvider(); } @@ -162,11 +170,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CloudShellServiceStubSettings.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); @@ -204,6 +218,11 @@ private static Builder createDefault() { return new Builder(CloudShellServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CloudShellServiceStubSettings.newHttpJsonBuilder()); + } + public CloudShellServiceStubSettings.Builder getStubSettingsBuilder() { return ((CloudShellServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/stub/CloudShellServiceStub.java b/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/stub/CloudShellServiceStub.java index af720c3a599c..d08ad6efb4ee 100644 --- a/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/stub/CloudShellServiceStub.java +++ b/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/stub/CloudShellServiceStub.java @@ -47,7 +47,11 @@ public abstract class CloudShellServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable getEnvironmentCallable() { diff --git a/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/stub/CloudShellServiceStubSettings.java b/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/stub/CloudShellServiceStubSettings.java index f22400941812..57f7677a173c 100644 --- a/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/stub/CloudShellServiceStubSettings.java +++ b/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/stub/CloudShellServiceStubSettings.java @@ -25,6 +25,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; @@ -171,13 +174,17 @@ public UnaryCallSettings removePublicKeySetti return removePublicKeyOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public CloudShellServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCloudShellServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCloudShellServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -210,18 +217,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(CloudShellServiceStubSettings.class)) @@ -229,11 +243,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(CloudShellServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CloudShellServiceStubSettings.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); @@ -389,6 +422,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 .getEnvironmentSettings() diff --git a/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/stub/HttpJsonCloudShellServiceCallableFactory.java b/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/stub/HttpJsonCloudShellServiceCallableFactory.java new file mode 100644 index 000000000000..02dd9277a8f9 --- /dev/null +++ b/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/stub/HttpJsonCloudShellServiceCallableFactory.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.shell.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 CloudShellService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCloudShellServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/stub/HttpJsonCloudShellServiceStub.java b/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/stub/HttpJsonCloudShellServiceStub.java new file mode 100644 index 000000000000..6fa309f56f69 --- /dev/null +++ b/java-shell/google-cloud-shell/src/main/java/com/google/cloud/shell/v1/stub/HttpJsonCloudShellServiceStub.java @@ -0,0 +1,506 @@ +/* + * 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.shell.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.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.shell.v1.AddPublicKeyMetadata; +import com.google.cloud.shell.v1.AddPublicKeyRequest; +import com.google.cloud.shell.v1.AddPublicKeyResponse; +import com.google.cloud.shell.v1.AuthorizeEnvironmentMetadata; +import com.google.cloud.shell.v1.AuthorizeEnvironmentRequest; +import com.google.cloud.shell.v1.AuthorizeEnvironmentResponse; +import com.google.cloud.shell.v1.Environment; +import com.google.cloud.shell.v1.GetEnvironmentRequest; +import com.google.cloud.shell.v1.RemovePublicKeyMetadata; +import com.google.cloud.shell.v1.RemovePublicKeyRequest; +import com.google.cloud.shell.v1.RemovePublicKeyResponse; +import com.google.cloud.shell.v1.StartEnvironmentMetadata; +import com.google.cloud.shell.v1.StartEnvironmentRequest; +import com.google.cloud.shell.v1.StartEnvironmentResponse; +import com.google.longrunning.Operation; +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 CloudShellService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCloudShellServiceStub extends CloudShellServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(StartEnvironmentResponse.getDescriptor()) + .add(RemovePublicKeyResponse.getDescriptor()) + .add(AuthorizeEnvironmentResponse.getDescriptor()) + .add(StartEnvironmentMetadata.getDescriptor()) + .add(RemovePublicKeyMetadata.getDescriptor()) + .add(AddPublicKeyResponse.getDescriptor()) + .add(AuthorizeEnvironmentMetadata.getDescriptor()) + .add(AddPublicKeyMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + getEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.shell.v1.CloudShellService/GetEnvironment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=users/*/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 + startEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.shell.v1.CloudShellService/StartEnvironment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=users/*/environments/*}:start", + 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( + (StartEnvironmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + authorizeEnvironmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.shell.v1.CloudShellService/AuthorizeEnvironment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=users/*/environments/*}:authorize", + 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( + (AuthorizeEnvironmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + addPublicKeyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.shell.v1.CloudShellService/AddPublicKey") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{environment=users/*/environments/*}:addPublicKey", + 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( + (AddPublicKeyRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + removePublicKeyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.shell.v1.CloudShellService/RemovePublicKey") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{environment=users/*/environments/*}:removePublicKey", + 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( + (RemovePublicKeyRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable getEnvironmentCallable; + private final UnaryCallable startEnvironmentCallable; + private final OperationCallable< + StartEnvironmentRequest, StartEnvironmentResponse, StartEnvironmentMetadata> + startEnvironmentOperationCallable; + private final UnaryCallable authorizeEnvironmentCallable; + private final OperationCallable< + AuthorizeEnvironmentRequest, AuthorizeEnvironmentResponse, AuthorizeEnvironmentMetadata> + authorizeEnvironmentOperationCallable; + private final UnaryCallable addPublicKeyCallable; + private final OperationCallable + addPublicKeyOperationCallable; + private final UnaryCallable removePublicKeyCallable; + private final OperationCallable< + RemovePublicKeyRequest, RemovePublicKeyResponse, RemovePublicKeyMetadata> + removePublicKeyOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCloudShellServiceStub create(CloudShellServiceStubSettings settings) + throws IOException { + return new HttpJsonCloudShellServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCloudShellServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCloudShellServiceStub( + CloudShellServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCloudShellServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCloudShellServiceStub( + CloudShellServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCloudShellServiceStub, 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 HttpJsonCloudShellServiceStub( + CloudShellServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCloudShellServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCloudShellServiceStub, 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 HttpJsonCloudShellServiceStub( + CloudShellServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings getEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings startEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(startEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + authorizeEnvironmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(authorizeEnvironmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings addPublicKeyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addPublicKeyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings removePublicKeyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(removePublicKeyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.getEnvironmentCallable = + callableFactory.createUnaryCallable( + getEnvironmentTransportSettings, settings.getEnvironmentSettings(), clientContext); + this.startEnvironmentCallable = + callableFactory.createUnaryCallable( + startEnvironmentTransportSettings, settings.startEnvironmentSettings(), clientContext); + this.startEnvironmentOperationCallable = + callableFactory.createOperationCallable( + startEnvironmentTransportSettings, + settings.startEnvironmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.authorizeEnvironmentCallable = + callableFactory.createUnaryCallable( + authorizeEnvironmentTransportSettings, + settings.authorizeEnvironmentSettings(), + clientContext); + this.authorizeEnvironmentOperationCallable = + callableFactory.createOperationCallable( + authorizeEnvironmentTransportSettings, + settings.authorizeEnvironmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.addPublicKeyCallable = + callableFactory.createUnaryCallable( + addPublicKeyTransportSettings, settings.addPublicKeySettings(), clientContext); + this.addPublicKeyOperationCallable = + callableFactory.createOperationCallable( + addPublicKeyTransportSettings, + settings.addPublicKeyOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.removePublicKeyCallable = + callableFactory.createUnaryCallable( + removePublicKeyTransportSettings, settings.removePublicKeySettings(), clientContext); + this.removePublicKeyOperationCallable = + callableFactory.createOperationCallable( + removePublicKeyTransportSettings, + settings.removePublicKeyOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(getEnvironmentMethodDescriptor); + methodDescriptors.add(startEnvironmentMethodDescriptor); + methodDescriptors.add(authorizeEnvironmentMethodDescriptor); + methodDescriptors.add(addPublicKeyMethodDescriptor); + methodDescriptors.add(removePublicKeyMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable getEnvironmentCallable() { + return getEnvironmentCallable; + } + + @Override + public UnaryCallable startEnvironmentCallable() { + return startEnvironmentCallable; + } + + @Override + public OperationCallable< + StartEnvironmentRequest, StartEnvironmentResponse, StartEnvironmentMetadata> + startEnvironmentOperationCallable() { + return startEnvironmentOperationCallable; + } + + @Override + public UnaryCallable authorizeEnvironmentCallable() { + return authorizeEnvironmentCallable; + } + + @Override + public OperationCallable< + AuthorizeEnvironmentRequest, AuthorizeEnvironmentResponse, AuthorizeEnvironmentMetadata> + authorizeEnvironmentOperationCallable() { + return authorizeEnvironmentOperationCallable; + } + + @Override + public UnaryCallable addPublicKeyCallable() { + return addPublicKeyCallable; + } + + @Override + public OperationCallable + addPublicKeyOperationCallable() { + return addPublicKeyOperationCallable; + } + + @Override + public UnaryCallable removePublicKeyCallable() { + return removePublicKeyCallable; + } + + @Override + public OperationCallable + removePublicKeyOperationCallable() { + return removePublicKeyOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-shell/google-cloud-shell/src/test/java/com/google/cloud/shell/v1/CloudShellServiceClientHttpJsonTest.java b/java-shell/google-cloud-shell/src/test/java/com/google/cloud/shell/v1/CloudShellServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..b1ee2629b79c --- /dev/null +++ b/java-shell/google-cloud-shell/src/test/java/com/google/cloud/shell/v1/CloudShellServiceClientHttpJsonTest.java @@ -0,0 +1,407 @@ +/* + * 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.shell.v1; + +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.shell.v1.stub.HttpJsonCloudShellServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +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 CloudShellServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static CloudShellServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCloudShellServiceStub.getMethodDescriptors(), + CloudShellServiceSettings.getDefaultEndpoint()); + CloudShellServiceSettings settings = + CloudShellServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CloudShellServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CloudShellServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void getEnvironmentTest() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName(EnvironmentName.of("[USER]", "[ENVIRONMENT]").toString()) + .setId("id3355") + .setDockerImage("dockerImage2086149915") + .setWebHost("webHost1223060252") + .setSshUsername("sshUsername-812965122") + .setSshHost("sshHost-1920605232") + .setSshPort(612046936) + .addAllPublicKeys(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + EnvironmentName name = EnvironmentName.of("[USER]", "[ENVIRONMENT]"); + + 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 { + EnvironmentName name = EnvironmentName.of("[USER]", "[ENVIRONMENT]"); + client.getEnvironment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEnvironmentTest2() throws Exception { + Environment expectedResponse = + Environment.newBuilder() + .setName(EnvironmentName.of("[USER]", "[ENVIRONMENT]").toString()) + .setId("id3355") + .setDockerImage("dockerImage2086149915") + .setWebHost("webHost1223060252") + .setSshUsername("sshUsername-812965122") + .setSshHost("sshHost-1920605232") + .setSshPort(612046936) + .addAllPublicKeys(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "users/user-9538/environments/environment-9538"; + + 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 getEnvironmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "users/user-9538/environments/environment-9538"; + client.getEnvironment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void startEnvironmentTest() throws Exception { + StartEnvironmentResponse expectedResponse = + StartEnvironmentResponse.newBuilder() + .setEnvironment(Environment.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("startEnvironmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + StartEnvironmentRequest request = + StartEnvironmentRequest.newBuilder() + .setName("users/user-9538/environments/environment-9538") + .setAccessToken("accessToken-1042689291") + .addAllPublicKeys(new ArrayList()) + .build(); + + StartEnvironmentResponse actualResponse = client.startEnvironmentAsync(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 startEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + StartEnvironmentRequest request = + StartEnvironmentRequest.newBuilder() + .setName("users/user-9538/environments/environment-9538") + .setAccessToken("accessToken-1042689291") + .addAllPublicKeys(new ArrayList()) + .build(); + client.startEnvironmentAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void authorizeEnvironmentTest() throws Exception { + AuthorizeEnvironmentResponse expectedResponse = + AuthorizeEnvironmentResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("authorizeEnvironmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + AuthorizeEnvironmentRequest request = + AuthorizeEnvironmentRequest.newBuilder() + .setName("users/user-9538/environments/environment-9538") + .setAccessToken("accessToken-1042689291") + .setIdToken("idToken1642509726") + .setExpireTime(Timestamp.newBuilder().build()) + .build(); + + AuthorizeEnvironmentResponse actualResponse = client.authorizeEnvironmentAsync(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 authorizeEnvironmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AuthorizeEnvironmentRequest request = + AuthorizeEnvironmentRequest.newBuilder() + .setName("users/user-9538/environments/environment-9538") + .setAccessToken("accessToken-1042689291") + .setIdToken("idToken1642509726") + .setExpireTime(Timestamp.newBuilder().build()) + .build(); + client.authorizeEnvironmentAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void addPublicKeyTest() throws Exception { + AddPublicKeyResponse expectedResponse = + AddPublicKeyResponse.newBuilder().setKey("key106079").build(); + Operation resultOperation = + Operation.newBuilder() + .setName("addPublicKeyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + AddPublicKeyRequest request = + AddPublicKeyRequest.newBuilder() + .setEnvironment("users/user-9402/environments/environment-9402") + .setKey("key106079") + .build(); + + AddPublicKeyResponse actualResponse = client.addPublicKeyAsync(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 addPublicKeyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AddPublicKeyRequest request = + AddPublicKeyRequest.newBuilder() + .setEnvironment("users/user-9402/environments/environment-9402") + .setKey("key106079") + .build(); + client.addPublicKeyAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void removePublicKeyTest() throws Exception { + RemovePublicKeyResponse expectedResponse = RemovePublicKeyResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("removePublicKeyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RemovePublicKeyRequest request = + RemovePublicKeyRequest.newBuilder() + .setEnvironment("users/user-9402/environments/environment-9402") + .setKey("key106079") + .build(); + + RemovePublicKeyResponse actualResponse = client.removePublicKeyAsync(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 removePublicKeyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RemovePublicKeyRequest request = + RemovePublicKeyRequest.newBuilder() + .setEnvironment("users/user-9402/environments/environment-9402") + .setKey("key106079") + .build(); + client.removePublicKeyAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/addpublickey/AsyncAddPublicKey.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/addpublickey/AsyncAddPublicKey.java new file mode 100644 index 000000000000..4ef2b6eda7d2 --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/addpublickey/AsyncAddPublicKey.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_addpublickey_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.shell.v1.AddPublicKeyRequest; +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.longrunning.Operation; + +public class AsyncAddPublicKey { + + public static void main(String[] args) throws Exception { + asyncAddPublicKey(); + } + + public static void asyncAddPublicKey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + AddPublicKeyRequest request = + AddPublicKeyRequest.newBuilder() + .setEnvironment("environment-85904877") + .setKey("key106079") + .build(); + ApiFuture future = + cloudShellServiceClient.addPublicKeyCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_addpublickey_async] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/addpublickey/AsyncAddPublicKeyLRO.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/addpublickey/AsyncAddPublicKeyLRO.java new file mode 100644 index 000000000000..64354f8b60ed --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/addpublickey/AsyncAddPublicKeyLRO.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_addpublickey_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.shell.v1.AddPublicKeyMetadata; +import com.google.cloud.shell.v1.AddPublicKeyRequest; +import com.google.cloud.shell.v1.AddPublicKeyResponse; +import com.google.cloud.shell.v1.CloudShellServiceClient; + +public class AsyncAddPublicKeyLRO { + + public static void main(String[] args) throws Exception { + asyncAddPublicKeyLRO(); + } + + public static void asyncAddPublicKeyLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + AddPublicKeyRequest request = + AddPublicKeyRequest.newBuilder() + .setEnvironment("environment-85904877") + .setKey("key106079") + .build(); + OperationFuture future = + cloudShellServiceClient.addPublicKeyOperationCallable().futureCall(request); + // Do something. + AddPublicKeyResponse response = future.get(); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_addpublickey_lro_async] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/addpublickey/SyncAddPublicKey.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/addpublickey/SyncAddPublicKey.java new file mode 100644 index 000000000000..fe40f82f8195 --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/addpublickey/SyncAddPublicKey.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_addpublickey_sync] +import com.google.cloud.shell.v1.AddPublicKeyRequest; +import com.google.cloud.shell.v1.AddPublicKeyResponse; +import com.google.cloud.shell.v1.CloudShellServiceClient; + +public class SyncAddPublicKey { + + public static void main(String[] args) throws Exception { + syncAddPublicKey(); + } + + public static void syncAddPublicKey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + AddPublicKeyRequest request = + AddPublicKeyRequest.newBuilder() + .setEnvironment("environment-85904877") + .setKey("key106079") + .build(); + AddPublicKeyResponse response = cloudShellServiceClient.addPublicKeyAsync(request).get(); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_addpublickey_sync] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/authorizeenvironment/AsyncAuthorizeEnvironment.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/authorizeenvironment/AsyncAuthorizeEnvironment.java new file mode 100644 index 000000000000..c2f8c336128b --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/authorizeenvironment/AsyncAuthorizeEnvironment.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_authorizeenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.shell.v1.AuthorizeEnvironmentRequest; +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.Timestamp; + +public class AsyncAuthorizeEnvironment { + + public static void main(String[] args) throws Exception { + asyncAuthorizeEnvironment(); + } + + public static void asyncAuthorizeEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + AuthorizeEnvironmentRequest request = + AuthorizeEnvironmentRequest.newBuilder() + .setName("name3373707") + .setAccessToken("accessToken-1042689291") + .setIdToken("idToken1642509726") + .setExpireTime(Timestamp.newBuilder().build()) + .build(); + ApiFuture future = + cloudShellServiceClient.authorizeEnvironmentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_authorizeenvironment_async] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/authorizeenvironment/AsyncAuthorizeEnvironmentLRO.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/authorizeenvironment/AsyncAuthorizeEnvironmentLRO.java new file mode 100644 index 000000000000..898adf6499c1 --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/authorizeenvironment/AsyncAuthorizeEnvironmentLRO.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_authorizeenvironment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.shell.v1.AuthorizeEnvironmentMetadata; +import com.google.cloud.shell.v1.AuthorizeEnvironmentRequest; +import com.google.cloud.shell.v1.AuthorizeEnvironmentResponse; +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.protobuf.Timestamp; + +public class AsyncAuthorizeEnvironmentLRO { + + public static void main(String[] args) throws Exception { + asyncAuthorizeEnvironmentLRO(); + } + + public static void asyncAuthorizeEnvironmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + AuthorizeEnvironmentRequest request = + AuthorizeEnvironmentRequest.newBuilder() + .setName("name3373707") + .setAccessToken("accessToken-1042689291") + .setIdToken("idToken1642509726") + .setExpireTime(Timestamp.newBuilder().build()) + .build(); + OperationFuture future = + cloudShellServiceClient.authorizeEnvironmentOperationCallable().futureCall(request); + // Do something. + AuthorizeEnvironmentResponse response = future.get(); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_authorizeenvironment_lro_async] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/authorizeenvironment/SyncAuthorizeEnvironment.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/authorizeenvironment/SyncAuthorizeEnvironment.java new file mode 100644 index 000000000000..1955955e08e0 --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/authorizeenvironment/SyncAuthorizeEnvironment.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_authorizeenvironment_sync] +import com.google.cloud.shell.v1.AuthorizeEnvironmentRequest; +import com.google.cloud.shell.v1.AuthorizeEnvironmentResponse; +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.protobuf.Timestamp; + +public class SyncAuthorizeEnvironment { + + public static void main(String[] args) throws Exception { + syncAuthorizeEnvironment(); + } + + public static void syncAuthorizeEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + AuthorizeEnvironmentRequest request = + AuthorizeEnvironmentRequest.newBuilder() + .setName("name3373707") + .setAccessToken("accessToken-1042689291") + .setIdToken("idToken1642509726") + .setExpireTime(Timestamp.newBuilder().build()) + .build(); + AuthorizeEnvironmentResponse response = + cloudShellServiceClient.authorizeEnvironmentAsync(request).get(); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_authorizeenvironment_sync] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..35ca7c3e6d42 --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/create/SyncCreateSetCredentialsProvider.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.cloud.shell.v1.CloudShellServiceSettings; +import com.google.cloud.shell.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. + CloudShellServiceSettings cloudShellServiceSettings = + CloudShellServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CloudShellServiceClient cloudShellServiceClient = + CloudShellServiceClient.create(cloudShellServiceSettings); + } +} +// [END shell_v1_generated_cloudshellserviceclient_create_setcredentialsprovider_sync] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..35b5b445a5c2 --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/create/SyncCreateSetCredentialsProvider1.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.cloud.shell.v1.CloudShellServiceSettings; + +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. + CloudShellServiceSettings cloudShellServiceSettings = + CloudShellServiceSettings.newBuilder() + .setTransportChannelProvider( + CloudShellServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CloudShellServiceClient cloudShellServiceClient = + CloudShellServiceClient.create(cloudShellServiceSettings); + } +} +// [END shell_v1_generated_cloudshellserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/create/SyncCreateSetEndpoint.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..b4d7c35901ad --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/create/SyncCreateSetEndpoint.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_create_setendpoint_sync] +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.cloud.shell.v1.CloudShellServiceSettings; +import com.google.cloud.shell.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. + CloudShellServiceSettings cloudShellServiceSettings = + CloudShellServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + CloudShellServiceClient cloudShellServiceClient = + CloudShellServiceClient.create(cloudShellServiceSettings); + } +} +// [END shell_v1_generated_cloudshellserviceclient_create_setendpoint_sync] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/getenvironment/AsyncGetEnvironment.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/getenvironment/AsyncGetEnvironment.java new file mode 100644 index 000000000000..784e0dff4cb9 --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/getenvironment/AsyncGetEnvironment.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_getenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.cloud.shell.v1.Environment; +import com.google.cloud.shell.v1.EnvironmentName; +import com.google.cloud.shell.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 (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + GetEnvironmentRequest request = + GetEnvironmentRequest.newBuilder() + .setName(EnvironmentName.of("[USER]", "[ENVIRONMENT]").toString()) + .build(); + ApiFuture future = + cloudShellServiceClient.getEnvironmentCallable().futureCall(request); + // Do something. + Environment response = future.get(); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_getenvironment_async] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/getenvironment/SyncGetEnvironment.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/getenvironment/SyncGetEnvironment.java new file mode 100644 index 000000000000..49db6eac431e --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/getenvironment/SyncGetEnvironment.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_getenvironment_sync] +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.cloud.shell.v1.Environment; +import com.google.cloud.shell.v1.EnvironmentName; +import com.google.cloud.shell.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 (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + GetEnvironmentRequest request = + GetEnvironmentRequest.newBuilder() + .setName(EnvironmentName.of("[USER]", "[ENVIRONMENT]").toString()) + .build(); + Environment response = cloudShellServiceClient.getEnvironment(request); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_getenvironment_sync] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/getenvironment/SyncGetEnvironmentEnvironmentname.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/getenvironment/SyncGetEnvironmentEnvironmentname.java new file mode 100644 index 000000000000..2901e6606906 --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/getenvironment/SyncGetEnvironmentEnvironmentname.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_getenvironment_environmentname_sync] +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.cloud.shell.v1.Environment; +import com.google.cloud.shell.v1.EnvironmentName; + +public class SyncGetEnvironmentEnvironmentname { + + public static void main(String[] args) throws Exception { + syncGetEnvironmentEnvironmentname(); + } + + public static void syncGetEnvironmentEnvironmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + EnvironmentName name = EnvironmentName.of("[USER]", "[ENVIRONMENT]"); + Environment response = cloudShellServiceClient.getEnvironment(name); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_getenvironment_environmentname_sync] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/getenvironment/SyncGetEnvironmentString.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/getenvironment/SyncGetEnvironmentString.java new file mode 100644 index 000000000000..9ccce8746288 --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/getenvironment/SyncGetEnvironmentString.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_getenvironment_string_sync] +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.cloud.shell.v1.Environment; +import com.google.cloud.shell.v1.EnvironmentName; + +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 (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + String name = EnvironmentName.of("[USER]", "[ENVIRONMENT]").toString(); + Environment response = cloudShellServiceClient.getEnvironment(name); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_getenvironment_string_sync] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/removepublickey/AsyncRemovePublicKey.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/removepublickey/AsyncRemovePublicKey.java new file mode 100644 index 000000000000..a212a82457f5 --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/removepublickey/AsyncRemovePublicKey.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_removepublickey_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.cloud.shell.v1.RemovePublicKeyRequest; +import com.google.longrunning.Operation; + +public class AsyncRemovePublicKey { + + public static void main(String[] args) throws Exception { + asyncRemovePublicKey(); + } + + public static void asyncRemovePublicKey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + RemovePublicKeyRequest request = + RemovePublicKeyRequest.newBuilder() + .setEnvironment("environment-85904877") + .setKey("key106079") + .build(); + ApiFuture future = + cloudShellServiceClient.removePublicKeyCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_removepublickey_async] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/removepublickey/AsyncRemovePublicKeyLRO.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/removepublickey/AsyncRemovePublicKeyLRO.java new file mode 100644 index 000000000000..86228fb5867c --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/removepublickey/AsyncRemovePublicKeyLRO.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_removepublickey_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.cloud.shell.v1.RemovePublicKeyMetadata; +import com.google.cloud.shell.v1.RemovePublicKeyRequest; +import com.google.cloud.shell.v1.RemovePublicKeyResponse; + +public class AsyncRemovePublicKeyLRO { + + public static void main(String[] args) throws Exception { + asyncRemovePublicKeyLRO(); + } + + public static void asyncRemovePublicKeyLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + RemovePublicKeyRequest request = + RemovePublicKeyRequest.newBuilder() + .setEnvironment("environment-85904877") + .setKey("key106079") + .build(); + OperationFuture future = + cloudShellServiceClient.removePublicKeyOperationCallable().futureCall(request); + // Do something. + RemovePublicKeyResponse response = future.get(); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_removepublickey_lro_async] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/removepublickey/SyncRemovePublicKey.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/removepublickey/SyncRemovePublicKey.java new file mode 100644 index 000000000000..b96d8f93a9d6 --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/removepublickey/SyncRemovePublicKey.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_removepublickey_sync] +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.cloud.shell.v1.RemovePublicKeyRequest; +import com.google.cloud.shell.v1.RemovePublicKeyResponse; + +public class SyncRemovePublicKey { + + public static void main(String[] args) throws Exception { + syncRemovePublicKey(); + } + + public static void syncRemovePublicKey() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + RemovePublicKeyRequest request = + RemovePublicKeyRequest.newBuilder() + .setEnvironment("environment-85904877") + .setKey("key106079") + .build(); + RemovePublicKeyResponse response = + cloudShellServiceClient.removePublicKeyAsync(request).get(); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_removepublickey_sync] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/startenvironment/AsyncStartEnvironment.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/startenvironment/AsyncStartEnvironment.java new file mode 100644 index 000000000000..b5186c1aa90a --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/startenvironment/AsyncStartEnvironment.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_startenvironment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.cloud.shell.v1.StartEnvironmentRequest; +import com.google.longrunning.Operation; +import java.util.ArrayList; + +public class AsyncStartEnvironment { + + public static void main(String[] args) throws Exception { + asyncStartEnvironment(); + } + + public static void asyncStartEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + StartEnvironmentRequest request = + StartEnvironmentRequest.newBuilder() + .setName("name3373707") + .setAccessToken("accessToken-1042689291") + .addAllPublicKeys(new ArrayList()) + .build(); + ApiFuture future = + cloudShellServiceClient.startEnvironmentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_startenvironment_async] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/startenvironment/AsyncStartEnvironmentLRO.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/startenvironment/AsyncStartEnvironmentLRO.java new file mode 100644 index 000000000000..1fd0a429489d --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/startenvironment/AsyncStartEnvironmentLRO.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_startenvironment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.cloud.shell.v1.StartEnvironmentMetadata; +import com.google.cloud.shell.v1.StartEnvironmentRequest; +import com.google.cloud.shell.v1.StartEnvironmentResponse; +import java.util.ArrayList; + +public class AsyncStartEnvironmentLRO { + + public static void main(String[] args) throws Exception { + asyncStartEnvironmentLRO(); + } + + public static void asyncStartEnvironmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + StartEnvironmentRequest request = + StartEnvironmentRequest.newBuilder() + .setName("name3373707") + .setAccessToken("accessToken-1042689291") + .addAllPublicKeys(new ArrayList()) + .build(); + OperationFuture future = + cloudShellServiceClient.startEnvironmentOperationCallable().futureCall(request); + // Do something. + StartEnvironmentResponse response = future.get(); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_startenvironment_lro_async] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/startenvironment/SyncStartEnvironment.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/startenvironment/SyncStartEnvironment.java new file mode 100644 index 000000000000..be5f03f8295c --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellserviceclient/startenvironment/SyncStartEnvironment.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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellserviceclient_startenvironment_sync] +import com.google.cloud.shell.v1.CloudShellServiceClient; +import com.google.cloud.shell.v1.StartEnvironmentRequest; +import com.google.cloud.shell.v1.StartEnvironmentResponse; +import java.util.ArrayList; + +public class SyncStartEnvironment { + + public static void main(String[] args) throws Exception { + syncStartEnvironment(); + } + + public static void syncStartEnvironment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudShellServiceClient cloudShellServiceClient = CloudShellServiceClient.create()) { + StartEnvironmentRequest request = + StartEnvironmentRequest.newBuilder() + .setName("name3373707") + .setAccessToken("accessToken-1042689291") + .addAllPublicKeys(new ArrayList()) + .build(); + StartEnvironmentResponse response = + cloudShellServiceClient.startEnvironmentAsync(request).get(); + } + } +} +// [END shell_v1_generated_cloudshellserviceclient_startenvironment_sync] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellservicesettings/getenvironment/SyncGetEnvironment.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellservicesettings/getenvironment/SyncGetEnvironment.java new file mode 100644 index 000000000000..91e4d8f22868 --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/cloudshellservicesettings/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.shell.v1.samples; + +// [START shell_v1_generated_cloudshellservicesettings_getenvironment_sync] +import com.google.cloud.shell.v1.CloudShellServiceSettings; +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. + CloudShellServiceSettings.Builder cloudShellServiceSettingsBuilder = + CloudShellServiceSettings.newBuilder(); + cloudShellServiceSettingsBuilder + .getEnvironmentSettings() + .setRetrySettings( + cloudShellServiceSettingsBuilder + .getEnvironmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CloudShellServiceSettings cloudShellServiceSettings = cloudShellServiceSettingsBuilder.build(); + } +} +// [END shell_v1_generated_cloudshellservicesettings_getenvironment_sync] diff --git a/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/stub/cloudshellservicestubsettings/getenvironment/SyncGetEnvironment.java b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/stub/cloudshellservicestubsettings/getenvironment/SyncGetEnvironment.java new file mode 100644 index 000000000000..ba963045c70b --- /dev/null +++ b/java-shell/samples/snippets/generated/com/google/cloud/shell/v1/stub/cloudshellservicestubsettings/getenvironment/SyncGetEnvironment.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.shell.v1.stub.samples; + +// [START shell_v1_generated_cloudshellservicestubsettings_getenvironment_sync] +import com.google.cloud.shell.v1.stub.CloudShellServiceStubSettings; +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. + CloudShellServiceStubSettings.Builder cloudShellServiceSettingsBuilder = + CloudShellServiceStubSettings.newBuilder(); + cloudShellServiceSettingsBuilder + .getEnvironmentSettings() + .setRetrySettings( + cloudShellServiceSettingsBuilder + .getEnvironmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CloudShellServiceStubSettings cloudShellServiceSettings = + cloudShellServiceSettingsBuilder.build(); + } +} +// [END shell_v1_generated_cloudshellservicestubsettings_getenvironment_sync]