diff --git a/java-gsuite-addons/README.md b/java-gsuite-addons/README.md index f0e9cf2f0248..7b456a44347c 100644 --- a/java-gsuite-addons/README.md +++ b/java-gsuite-addons/README.md @@ -19,20 +19,20 @@ If you are using Maven, add this to your pom.xml file: com.google.cloud google-cloud-gsuite-addons - 2.2.0 + 2.2.1 ``` If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-gsuite-addons:2.2.0' +implementation 'com.google.cloud:google-cloud-gsuite-addons:2.2.1' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-gsuite-addons" % "2.2.0" +libraryDependencies += "com.google.cloud" % "google-cloud-gsuite-addons" % "2.2.1" ``` ## Authentication diff --git a/java-gsuite-addons/google-cloud-gsuite-addons/pom.xml b/java-gsuite-addons/google-cloud-gsuite-addons/pom.xml index c5178ed53c93..317759bed579 100644 --- a/java-gsuite-addons/google-cloud-gsuite-addons/pom.xml +++ b/java-gsuite-addons/google-cloud-gsuite-addons/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-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/GSuiteAddOnsClient.java b/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/GSuiteAddOnsClient.java index a6aa15e55a2d..6871b9074ad4 100644 --- a/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/GSuiteAddOnsClient.java +++ b/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/GSuiteAddOnsClient.java @@ -118,6 +118,20 @@ * GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create(gSuiteAddOnsSettings); * } * + *

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.
+ * GSuiteAddOnsSettings gSuiteAddOnsSettings =
+ *     GSuiteAddOnsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             GSuiteAddOnsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create(gSuiteAddOnsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") diff --git a/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/GSuiteAddOnsSettings.java b/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/GSuiteAddOnsSettings.java index 0c67e508981e..f594d82e4952 100644 --- a/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/GSuiteAddOnsSettings.java +++ b/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/GSuiteAddOnsSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -143,11 +144,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return GSuiteAddOnsStubSettings.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 GSuiteAddOnsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return GSuiteAddOnsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return GSuiteAddOnsStubSettings.defaultTransportChannelProvider(); } @@ -157,11 +165,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return GSuiteAddOnsStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -199,6 +213,11 @@ private static Builder createDefault() { return new Builder(GSuiteAddOnsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(GSuiteAddOnsStubSettings.newHttpJsonBuilder()); + } + public GSuiteAddOnsStubSettings.Builder getStubSettingsBuilder() { return ((GSuiteAddOnsStubSettings.Builder) getStubSettings()); } diff --git a/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/stub/GSuiteAddOnsStubSettings.java b/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/stub/GSuiteAddOnsStubSettings.java index 9bd1cc95a175..923be86f1528 100644 --- a/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/stub/GSuiteAddOnsStubSettings.java +++ b/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/stub/GSuiteAddOnsStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -224,6 +227,11 @@ public GSuiteAddOnsStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcGSuiteAddOnsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonGSuiteAddOnsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -256,18 +264,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(GSuiteAddOnsStubSettings.class)) @@ -275,11 +290,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(GSuiteAddOnsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return GSuiteAddOnsStubSettings.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); @@ -448,6 +482,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 .getAuthorizationSettings() diff --git a/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/stub/HttpJsonGSuiteAddOnsCallableFactory.java b/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/stub/HttpJsonGSuiteAddOnsCallableFactory.java new file mode 100644 index 000000000000..347f4b819f04 --- /dev/null +++ b/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/stub/HttpJsonGSuiteAddOnsCallableFactory.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.gsuiteaddons.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 GSuiteAddOns service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonGSuiteAddOnsCallableFactory + 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-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/stub/HttpJsonGSuiteAddOnsStub.java b/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/stub/HttpJsonGSuiteAddOnsStub.java new file mode 100644 index 000000000000..d361039e7e1f --- /dev/null +++ b/java-gsuite-addons/google-cloud-gsuite-addons/src/main/java/com/google/cloud/gsuiteaddons/v1/stub/HttpJsonGSuiteAddOnsStub.java @@ -0,0 +1,626 @@ +/* + * 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.gsuiteaddons.v1.stub; + +import static com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient.ListDeploymentsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.gsuiteaddons.v1.Authorization; +import com.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest; +import com.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest; +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest; +import com.google.cloud.gsuiteaddons.v1.GetDeploymentRequest; +import com.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest; +import com.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest; +import com.google.cloud.gsuiteaddons.v1.InstallStatus; +import com.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest; +import com.google.cloud.gsuiteaddons.v1.ListDeploymentsResponse; +import com.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest; +import com.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the GSuiteAddOns service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonGSuiteAddOnsStub extends GSuiteAddOnsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + getAuthorizationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gsuiteaddons.v1.GSuiteAddOns/GetAuthorization") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/authorization}", + 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(Authorization.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createDeploymentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gsuiteaddons.v1.GSuiteAddOns/CreateDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/deployments", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "deploymentId", request.getDeploymentId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("deployment", request.getDeployment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Deployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + replaceDeploymentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gsuiteaddons.v1.GSuiteAddOns/ReplaceDeployment") + .setHttpMethod("PUT") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{deployment.name=projects/*/deployments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "deployment.name", request.getDeployment().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("deployment", request.getDeployment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Deployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getDeploymentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gsuiteaddons.v1.GSuiteAddOns/GetDeployment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/deployments/*}", + 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(Deployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listDeploymentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gsuiteaddons.v1.GSuiteAddOns/ListDeployments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/deployments", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListDeploymentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteDeploymentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gsuiteaddons.v1.GSuiteAddOns/DeleteDeployment") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/deployments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "etag", request.getEtag()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + installDeploymentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gsuiteaddons.v1.GSuiteAddOns/InstallDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/deployments/*}:install", + 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(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + uninstallDeploymentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gsuiteaddons.v1.GSuiteAddOns/UninstallDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/deployments/*}:uninstall", + 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(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getInstallStatusMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gsuiteaddons.v1.GSuiteAddOns/GetInstallStatus") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/deployments/*/installStatus}", + 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(InstallStatus.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable getAuthorizationCallable; + private final UnaryCallable createDeploymentCallable; + private final UnaryCallable replaceDeploymentCallable; + private final UnaryCallable getDeploymentCallable; + private final UnaryCallable + listDeploymentsCallable; + private final UnaryCallable + listDeploymentsPagedCallable; + private final UnaryCallable deleteDeploymentCallable; + private final UnaryCallable installDeploymentCallable; + private final UnaryCallable uninstallDeploymentCallable; + private final UnaryCallable getInstallStatusCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonGSuiteAddOnsStub create(GSuiteAddOnsStubSettings settings) + throws IOException { + return new HttpJsonGSuiteAddOnsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonGSuiteAddOnsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonGSuiteAddOnsStub( + GSuiteAddOnsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonGSuiteAddOnsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonGSuiteAddOnsStub( + GSuiteAddOnsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonGSuiteAddOnsStub, 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 HttpJsonGSuiteAddOnsStub(GSuiteAddOnsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonGSuiteAddOnsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonGSuiteAddOnsStub, 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 HttpJsonGSuiteAddOnsStub( + GSuiteAddOnsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings getAuthorizationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getAuthorizationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createDeploymentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings replaceDeploymentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(replaceDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getDeploymentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listDeploymentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listDeploymentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteDeploymentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings installDeploymentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(installDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings uninstallDeploymentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(uninstallDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getInstallStatusTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInstallStatusMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.getAuthorizationCallable = + callableFactory.createUnaryCallable( + getAuthorizationTransportSettings, settings.getAuthorizationSettings(), clientContext); + this.createDeploymentCallable = + callableFactory.createUnaryCallable( + createDeploymentTransportSettings, settings.createDeploymentSettings(), clientContext); + this.replaceDeploymentCallable = + callableFactory.createUnaryCallable( + replaceDeploymentTransportSettings, + settings.replaceDeploymentSettings(), + clientContext); + this.getDeploymentCallable = + callableFactory.createUnaryCallable( + getDeploymentTransportSettings, settings.getDeploymentSettings(), clientContext); + this.listDeploymentsCallable = + callableFactory.createUnaryCallable( + listDeploymentsTransportSettings, settings.listDeploymentsSettings(), clientContext); + this.listDeploymentsPagedCallable = + callableFactory.createPagedCallable( + listDeploymentsTransportSettings, settings.listDeploymentsSettings(), clientContext); + this.deleteDeploymentCallable = + callableFactory.createUnaryCallable( + deleteDeploymentTransportSettings, settings.deleteDeploymentSettings(), clientContext); + this.installDeploymentCallable = + callableFactory.createUnaryCallable( + installDeploymentTransportSettings, + settings.installDeploymentSettings(), + clientContext); + this.uninstallDeploymentCallable = + callableFactory.createUnaryCallable( + uninstallDeploymentTransportSettings, + settings.uninstallDeploymentSettings(), + clientContext); + this.getInstallStatusCallable = + callableFactory.createUnaryCallable( + getInstallStatusTransportSettings, settings.getInstallStatusSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(getAuthorizationMethodDescriptor); + methodDescriptors.add(createDeploymentMethodDescriptor); + methodDescriptors.add(replaceDeploymentMethodDescriptor); + methodDescriptors.add(getDeploymentMethodDescriptor); + methodDescriptors.add(listDeploymentsMethodDescriptor); + methodDescriptors.add(deleteDeploymentMethodDescriptor); + methodDescriptors.add(installDeploymentMethodDescriptor); + methodDescriptors.add(uninstallDeploymentMethodDescriptor); + methodDescriptors.add(getInstallStatusMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable getAuthorizationCallable() { + return getAuthorizationCallable; + } + + @Override + public UnaryCallable createDeploymentCallable() { + return createDeploymentCallable; + } + + @Override + public UnaryCallable replaceDeploymentCallable() { + return replaceDeploymentCallable; + } + + @Override + public UnaryCallable getDeploymentCallable() { + return getDeploymentCallable; + } + + @Override + public UnaryCallable listDeploymentsCallable() { + return listDeploymentsCallable; + } + + @Override + public UnaryCallable + listDeploymentsPagedCallable() { + return listDeploymentsPagedCallable; + } + + @Override + public UnaryCallable deleteDeploymentCallable() { + return deleteDeploymentCallable; + } + + @Override + public UnaryCallable installDeploymentCallable() { + return installDeploymentCallable; + } + + @Override + public UnaryCallable uninstallDeploymentCallable() { + return uninstallDeploymentCallable; + } + + @Override + public UnaryCallable getInstallStatusCallable() { + return getInstallStatusCallable; + } + + @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-gsuite-addons/google-cloud-gsuite-addons/src/test/java/com/google/cloud/gsuiteaddons/v1/GSuiteAddOnsClientHttpJsonTest.java b/java-gsuite-addons/google-cloud-gsuite-addons/src/test/java/com/google/cloud/gsuiteaddons/v1/GSuiteAddOnsClientHttpJsonTest.java new file mode 100644 index 000000000000..4abdc9b2fcd5 --- /dev/null +++ b/java-gsuite-addons/google-cloud-gsuite-addons/src/test/java/com/google/cloud/gsuiteaddons/v1/GSuiteAddOnsClientHttpJsonTest.java @@ -0,0 +1,857 @@ +/* + * 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.gsuiteaddons.v1; + +import static com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient.ListDeploymentsPagedResponse; + +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.gsuiteaddons.v1.stub.HttpJsonGSuiteAddOnsStub; +import com.google.common.collect.Lists; +import com.google.protobuf.BoolValue; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class GSuiteAddOnsClientHttpJsonTest { + private static MockHttpService mockService; + private static GSuiteAddOnsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonGSuiteAddOnsStub.getMethodDescriptors(), + GSuiteAddOnsSettings.getDefaultEndpoint()); + GSuiteAddOnsSettings settings = + GSuiteAddOnsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + GSuiteAddOnsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = GSuiteAddOnsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void getAuthorizationTest() throws Exception { + Authorization expectedResponse = + Authorization.newBuilder() + .setName(AuthorizationName.of("[PROJECT]").toString()) + .setServiceAccountEmail("serviceAccountEmail1825953988") + .setOauthClientId("oauthClientId-2001133059") + .build(); + mockService.addResponse(expectedResponse); + + AuthorizationName name = AuthorizationName.of("[PROJECT]"); + + Authorization actualResponse = client.getAuthorization(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 getAuthorizationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AuthorizationName name = AuthorizationName.of("[PROJECT]"); + client.getAuthorization(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAuthorizationTest2() throws Exception { + Authorization expectedResponse = + Authorization.newBuilder() + .setName(AuthorizationName.of("[PROJECT]").toString()) + .setServiceAccountEmail("serviceAccountEmail1825953988") + .setOauthClientId("oauthClientId-2001133059") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-4106/authorization"; + + Authorization actualResponse = client.getAuthorization(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 getAuthorizationExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-4106/authorization"; + client.getAuthorization(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDeploymentTest() throws Exception { + Deployment expectedResponse = + Deployment.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .addAllOauthScopes(new ArrayList()) + .setAddOns(AddOns.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + Deployment deployment = Deployment.newBuilder().build(); + String deploymentId = "deploymentId-136894784"; + + Deployment actualResponse = client.createDeployment(parent, deployment, deploymentId); + 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 createDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + Deployment deployment = Deployment.newBuilder().build(); + String deploymentId = "deploymentId-136894784"; + client.createDeployment(parent, deployment, deploymentId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDeploymentTest2() throws Exception { + Deployment expectedResponse = + Deployment.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .addAllOauthScopes(new ArrayList()) + .setAddOns(AddOns.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + Deployment deployment = Deployment.newBuilder().build(); + String deploymentId = "deploymentId-136894784"; + + Deployment actualResponse = client.createDeployment(parent, deployment, deploymentId); + 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 createDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + Deployment deployment = Deployment.newBuilder().build(); + String deploymentId = "deploymentId-136894784"; + client.createDeployment(parent, deployment, deploymentId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void replaceDeploymentTest() throws Exception { + Deployment expectedResponse = + Deployment.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .addAllOauthScopes(new ArrayList()) + .setAddOns(AddOns.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + Deployment deployment = + Deployment.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .addAllOauthScopes(new ArrayList()) + .setAddOns(AddOns.newBuilder().build()) + .setEtag("etag3123477") + .build(); + + Deployment actualResponse = client.replaceDeployment(deployment); + 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 replaceDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Deployment deployment = + Deployment.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .addAllOauthScopes(new ArrayList()) + .setAddOns(AddOns.newBuilder().build()) + .setEtag("etag3123477") + .build(); + client.replaceDeployment(deployment); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDeploymentTest() throws Exception { + Deployment expectedResponse = + Deployment.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .addAllOauthScopes(new ArrayList()) + .setAddOns(AddOns.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + DeploymentName name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]"); + + Deployment actualResponse = client.getDeployment(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 getDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeploymentName name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]"); + client.getDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDeploymentTest2() throws Exception { + Deployment expectedResponse = + Deployment.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .addAllOauthScopes(new ArrayList()) + .setAddOns(AddOns.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-5254/deployments/deployment-5254"; + + Deployment actualResponse = client.getDeployment(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 getDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-5254/deployments/deployment-5254"; + client.getDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDeploymentsTest() throws Exception { + Deployment responsesElement = Deployment.newBuilder().build(); + ListDeploymentsResponse expectedResponse = + ListDeploymentsResponse.newBuilder() + .setNextPageToken("") + .addAllDeployments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListDeploymentsPagedResponse pagedListResponse = client.listDeployments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDeploymentsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDeploymentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listDeployments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDeploymentsTest2() throws Exception { + Deployment responsesElement = Deployment.newBuilder().build(); + ListDeploymentsResponse expectedResponse = + ListDeploymentsResponse.newBuilder() + .setNextPageToken("") + .addAllDeployments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListDeploymentsPagedResponse pagedListResponse = client.listDeployments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDeploymentsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDeploymentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listDeployments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteDeploymentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DeploymentName name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]"); + + client.deleteDeployment(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeploymentName name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]"); + client.deleteDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteDeploymentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-5254/deployments/deployment-5254"; + + client.deleteDeployment(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-5254/deployments/deployment-5254"; + client.deleteDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void installDeploymentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DeploymentName name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]"); + + client.installDeployment(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void installDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeploymentName name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]"); + client.installDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void installDeploymentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-5254/deployments/deployment-5254"; + + client.installDeployment(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void installDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-5254/deployments/deployment-5254"; + client.installDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void uninstallDeploymentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DeploymentName name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]"); + + client.uninstallDeployment(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void uninstallDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeploymentName name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]"); + client.uninstallDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void uninstallDeploymentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-5254/deployments/deployment-5254"; + + client.uninstallDeployment(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void uninstallDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-5254/deployments/deployment-5254"; + client.uninstallDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInstallStatusTest() throws Exception { + InstallStatus expectedResponse = + InstallStatus.newBuilder() + .setName(InstallStatusName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .setInstalled(BoolValue.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + InstallStatusName name = InstallStatusName.of("[PROJECT]", "[DEPLOYMENT]"); + + InstallStatus actualResponse = client.getInstallStatus(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 getInstallStatusExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstallStatusName name = InstallStatusName.of("[PROJECT]", "[DEPLOYMENT]"); + client.getInstallStatus(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInstallStatusTest2() throws Exception { + InstallStatus expectedResponse = + InstallStatus.newBuilder() + .setName(InstallStatusName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .setInstalled(BoolValue.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-4296/deployments/deployment-4296/installStatus"; + + InstallStatus actualResponse = client.getInstallStatus(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 getInstallStatusExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-4296/deployments/deployment-4296/installStatus"; + client.getInstallStatus(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/create/SyncCreateSetCredentialsProvider.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..243da0938a84 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsSettings; +import com.google.cloud.gsuiteaddons.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. + GSuiteAddOnsSettings gSuiteAddOnsSettings = + GSuiteAddOnsSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create(gSuiteAddOnsSettings); + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_create_setcredentialsprovider_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/create/SyncCreateSetCredentialsProvider1.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..07d250f84a0d --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_create_setcredentialsprovider1_sync] +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsSettings; + +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. + GSuiteAddOnsSettings gSuiteAddOnsSettings = + GSuiteAddOnsSettings.newBuilder() + .setTransportChannelProvider( + GSuiteAddOnsSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create(gSuiteAddOnsSettings); + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_create_setcredentialsprovider1_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/create/SyncCreateSetEndpoint.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..40033316c8ba --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_create_setendpoint_sync] +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsSettings; +import com.google.cloud.gsuiteaddons.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. + GSuiteAddOnsSettings gSuiteAddOnsSettings = + GSuiteAddOnsSettings.newBuilder().setEndpoint(myEndpoint).build(); + GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create(gSuiteAddOnsSettings); + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_create_setendpoint_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/createdeployment/AsyncCreateDeployment.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/createdeployment/AsyncCreateDeployment.java new file mode 100644 index 000000000000..888cb5d46430 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/createdeployment/AsyncCreateDeployment.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_createdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest; +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.ProjectName; + +public class AsyncCreateDeployment { + + public static void main(String[] args) throws Exception { + asyncCreateDeployment(); + } + + public static void asyncCreateDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + CreateDeploymentRequest request = + CreateDeploymentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDeploymentId("deploymentId-136894784") + .setDeployment(Deployment.newBuilder().build()) + .build(); + ApiFuture future = + gSuiteAddOnsClient.createDeploymentCallable().futureCall(request); + // Do something. + Deployment response = future.get(); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_createdeployment_async] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/createdeployment/SyncCreateDeployment.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/createdeployment/SyncCreateDeployment.java new file mode 100644 index 000000000000..9fb789926936 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/createdeployment/SyncCreateDeployment.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_createdeployment_sync] +import com.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest; +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.ProjectName; + +public class SyncCreateDeployment { + + public static void main(String[] args) throws Exception { + syncCreateDeployment(); + } + + public static void syncCreateDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + CreateDeploymentRequest request = + CreateDeploymentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDeploymentId("deploymentId-136894784") + .setDeployment(Deployment.newBuilder().build()) + .build(); + Deployment response = gSuiteAddOnsClient.createDeployment(request); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_createdeployment_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/createdeployment/SyncCreateDeploymentProjectnameDeploymentString.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/createdeployment/SyncCreateDeploymentProjectnameDeploymentString.java new file mode 100644 index 000000000000..1ca055466ae9 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/createdeployment/SyncCreateDeploymentProjectnameDeploymentString.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.gsuiteaddons.v1.samples; + +// [START +// gsuiteaddons_v1_generated_gsuiteaddonsclient_createdeployment_projectnamedeploymentstring_sync] +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.ProjectName; + +public class SyncCreateDeploymentProjectnameDeploymentString { + + public static void main(String[] args) throws Exception { + syncCreateDeploymentProjectnameDeploymentString(); + } + + public static void syncCreateDeploymentProjectnameDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + Deployment deployment = Deployment.newBuilder().build(); + String deploymentId = "deploymentId-136894784"; + Deployment response = gSuiteAddOnsClient.createDeployment(parent, deployment, deploymentId); + } + } +} +// [END +// gsuiteaddons_v1_generated_gsuiteaddonsclient_createdeployment_projectnamedeploymentstring_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/createdeployment/SyncCreateDeploymentStringDeploymentString.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/createdeployment/SyncCreateDeploymentStringDeploymentString.java new file mode 100644 index 000000000000..2526906a6b3d --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/createdeployment/SyncCreateDeploymentStringDeploymentString.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_createdeployment_stringdeploymentstring_sync] +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.ProjectName; + +public class SyncCreateDeploymentStringDeploymentString { + + public static void main(String[] args) throws Exception { + syncCreateDeploymentStringDeploymentString(); + } + + public static void syncCreateDeploymentStringDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + Deployment deployment = Deployment.newBuilder().build(); + String deploymentId = "deploymentId-136894784"; + Deployment response = gSuiteAddOnsClient.createDeployment(parent, deployment, deploymentId); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_createdeployment_stringdeploymentstring_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/deletedeployment/AsyncDeleteDeployment.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/deletedeployment/AsyncDeleteDeployment.java new file mode 100644 index 000000000000..fdf318bdc3cb --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/deletedeployment/AsyncDeleteDeployment.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_deletedeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest; +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteDeployment { + + public static void main(String[] args) throws Exception { + asyncDeleteDeployment(); + } + + public static void asyncDeleteDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + DeleteDeploymentRequest request = + DeleteDeploymentRequest.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .setEtag("etag3123477") + .build(); + ApiFuture future = gSuiteAddOnsClient.deleteDeploymentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_deletedeployment_async] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/deletedeployment/SyncDeleteDeployment.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/deletedeployment/SyncDeleteDeployment.java new file mode 100644 index 000000000000..4dbfdda3105f --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/deletedeployment/SyncDeleteDeployment.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_deletedeployment_sync] +import com.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest; +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; + +public class SyncDeleteDeployment { + + public static void main(String[] args) throws Exception { + syncDeleteDeployment(); + } + + public static void syncDeleteDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + DeleteDeploymentRequest request = + DeleteDeploymentRequest.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .setEtag("etag3123477") + .build(); + gSuiteAddOnsClient.deleteDeployment(request); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_deletedeployment_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/deletedeployment/SyncDeleteDeploymentDeploymentname.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/deletedeployment/SyncDeleteDeploymentDeploymentname.java new file mode 100644 index 000000000000..4a4200ea9967 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/deletedeployment/SyncDeleteDeploymentDeploymentname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_deletedeployment_deploymentname_sync] +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; + +public class SyncDeleteDeploymentDeploymentname { + + public static void main(String[] args) throws Exception { + syncDeleteDeploymentDeploymentname(); + } + + public static void syncDeleteDeploymentDeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + DeploymentName name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]"); + gSuiteAddOnsClient.deleteDeployment(name); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_deletedeployment_deploymentname_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/deletedeployment/SyncDeleteDeploymentString.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/deletedeployment/SyncDeleteDeploymentString.java new file mode 100644 index 000000000000..a39e11e7f8c5 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/deletedeployment/SyncDeleteDeploymentString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_deletedeployment_string_sync] +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; + +public class SyncDeleteDeploymentString { + + public static void main(String[] args) throws Exception { + syncDeleteDeploymentString(); + } + + public static void syncDeleteDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + String name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString(); + gSuiteAddOnsClient.deleteDeployment(name); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_deletedeployment_string_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getauthorization/AsyncGetAuthorization.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getauthorization/AsyncGetAuthorization.java new file mode 100644 index 000000000000..68dbea5ab141 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getauthorization/AsyncGetAuthorization.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_getauthorization_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gsuiteaddons.v1.Authorization; +import com.google.cloud.gsuiteaddons.v1.AuthorizationName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest; + +public class AsyncGetAuthorization { + + public static void main(String[] args) throws Exception { + asyncGetAuthorization(); + } + + public static void asyncGetAuthorization() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + GetAuthorizationRequest request = + GetAuthorizationRequest.newBuilder() + .setName(AuthorizationName.of("[PROJECT]").toString()) + .build(); + ApiFuture future = + gSuiteAddOnsClient.getAuthorizationCallable().futureCall(request); + // Do something. + Authorization response = future.get(); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_getauthorization_async] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getauthorization/SyncGetAuthorization.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getauthorization/SyncGetAuthorization.java new file mode 100644 index 000000000000..6d6898e71007 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getauthorization/SyncGetAuthorization.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_getauthorization_sync] +import com.google.cloud.gsuiteaddons.v1.Authorization; +import com.google.cloud.gsuiteaddons.v1.AuthorizationName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest; + +public class SyncGetAuthorization { + + public static void main(String[] args) throws Exception { + syncGetAuthorization(); + } + + public static void syncGetAuthorization() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + GetAuthorizationRequest request = + GetAuthorizationRequest.newBuilder() + .setName(AuthorizationName.of("[PROJECT]").toString()) + .build(); + Authorization response = gSuiteAddOnsClient.getAuthorization(request); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_getauthorization_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getauthorization/SyncGetAuthorizationAuthorizationname.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getauthorization/SyncGetAuthorizationAuthorizationname.java new file mode 100644 index 000000000000..c37c4d99ea85 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getauthorization/SyncGetAuthorizationAuthorizationname.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_getauthorization_authorizationname_sync] +import com.google.cloud.gsuiteaddons.v1.Authorization; +import com.google.cloud.gsuiteaddons.v1.AuthorizationName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; + +public class SyncGetAuthorizationAuthorizationname { + + public static void main(String[] args) throws Exception { + syncGetAuthorizationAuthorizationname(); + } + + public static void syncGetAuthorizationAuthorizationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + AuthorizationName name = AuthorizationName.of("[PROJECT]"); + Authorization response = gSuiteAddOnsClient.getAuthorization(name); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_getauthorization_authorizationname_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getauthorization/SyncGetAuthorizationString.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getauthorization/SyncGetAuthorizationString.java new file mode 100644 index 000000000000..55f7c2b465cc --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getauthorization/SyncGetAuthorizationString.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_getauthorization_string_sync] +import com.google.cloud.gsuiteaddons.v1.Authorization; +import com.google.cloud.gsuiteaddons.v1.AuthorizationName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; + +public class SyncGetAuthorizationString { + + public static void main(String[] args) throws Exception { + syncGetAuthorizationString(); + } + + public static void syncGetAuthorizationString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + String name = AuthorizationName.of("[PROJECT]").toString(); + Authorization response = gSuiteAddOnsClient.getAuthorization(name); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_getauthorization_string_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getdeployment/AsyncGetDeployment.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getdeployment/AsyncGetDeployment.java new file mode 100644 index 000000000000..2bd54de362c4 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getdeployment/AsyncGetDeployment.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_getdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.GetDeploymentRequest; + +public class AsyncGetDeployment { + + public static void main(String[] args) throws Exception { + asyncGetDeployment(); + } + + public static void asyncGetDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + GetDeploymentRequest request = + GetDeploymentRequest.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .build(); + ApiFuture future = gSuiteAddOnsClient.getDeploymentCallable().futureCall(request); + // Do something. + Deployment response = future.get(); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_getdeployment_async] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getdeployment/SyncGetDeployment.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getdeployment/SyncGetDeployment.java new file mode 100644 index 000000000000..4c999733e974 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getdeployment/SyncGetDeployment.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_getdeployment_sync] +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.GetDeploymentRequest; + +public class SyncGetDeployment { + + public static void main(String[] args) throws Exception { + syncGetDeployment(); + } + + public static void syncGetDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + GetDeploymentRequest request = + GetDeploymentRequest.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .build(); + Deployment response = gSuiteAddOnsClient.getDeployment(request); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_getdeployment_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getdeployment/SyncGetDeploymentDeploymentname.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getdeployment/SyncGetDeploymentDeploymentname.java new file mode 100644 index 000000000000..8c22d3eaadfb --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getdeployment/SyncGetDeploymentDeploymentname.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_getdeployment_deploymentname_sync] +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; + +public class SyncGetDeploymentDeploymentname { + + public static void main(String[] args) throws Exception { + syncGetDeploymentDeploymentname(); + } + + public static void syncGetDeploymentDeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + DeploymentName name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]"); + Deployment response = gSuiteAddOnsClient.getDeployment(name); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_getdeployment_deploymentname_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getdeployment/SyncGetDeploymentString.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getdeployment/SyncGetDeploymentString.java new file mode 100644 index 000000000000..01ae501ee152 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getdeployment/SyncGetDeploymentString.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_getdeployment_string_sync] +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; + +public class SyncGetDeploymentString { + + public static void main(String[] args) throws Exception { + syncGetDeploymentString(); + } + + public static void syncGetDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + String name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString(); + Deployment response = gSuiteAddOnsClient.getDeployment(name); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_getdeployment_string_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getinstallstatus/AsyncGetInstallStatus.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getinstallstatus/AsyncGetInstallStatus.java new file mode 100644 index 000000000000..b547d57bfe4a --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getinstallstatus/AsyncGetInstallStatus.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_getinstallstatus_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest; +import com.google.cloud.gsuiteaddons.v1.InstallStatus; +import com.google.cloud.gsuiteaddons.v1.InstallStatusName; + +public class AsyncGetInstallStatus { + + public static void main(String[] args) throws Exception { + asyncGetInstallStatus(); + } + + public static void asyncGetInstallStatus() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + GetInstallStatusRequest request = + GetInstallStatusRequest.newBuilder() + .setName(InstallStatusName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .build(); + ApiFuture future = + gSuiteAddOnsClient.getInstallStatusCallable().futureCall(request); + // Do something. + InstallStatus response = future.get(); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_getinstallstatus_async] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getinstallstatus/SyncGetInstallStatus.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getinstallstatus/SyncGetInstallStatus.java new file mode 100644 index 000000000000..795e04558e00 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getinstallstatus/SyncGetInstallStatus.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_getinstallstatus_sync] +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest; +import com.google.cloud.gsuiteaddons.v1.InstallStatus; +import com.google.cloud.gsuiteaddons.v1.InstallStatusName; + +public class SyncGetInstallStatus { + + public static void main(String[] args) throws Exception { + syncGetInstallStatus(); + } + + public static void syncGetInstallStatus() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + GetInstallStatusRequest request = + GetInstallStatusRequest.newBuilder() + .setName(InstallStatusName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .build(); + InstallStatus response = gSuiteAddOnsClient.getInstallStatus(request); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_getinstallstatus_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getinstallstatus/SyncGetInstallStatusInstallstatusname.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getinstallstatus/SyncGetInstallStatusInstallstatusname.java new file mode 100644 index 000000000000..3607dbe6a238 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getinstallstatus/SyncGetInstallStatusInstallstatusname.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_getinstallstatus_installstatusname_sync] +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.InstallStatus; +import com.google.cloud.gsuiteaddons.v1.InstallStatusName; + +public class SyncGetInstallStatusInstallstatusname { + + public static void main(String[] args) throws Exception { + syncGetInstallStatusInstallstatusname(); + } + + public static void syncGetInstallStatusInstallstatusname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + InstallStatusName name = InstallStatusName.of("[PROJECT]", "[DEPLOYMENT]"); + InstallStatus response = gSuiteAddOnsClient.getInstallStatus(name); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_getinstallstatus_installstatusname_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getinstallstatus/SyncGetInstallStatusString.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getinstallstatus/SyncGetInstallStatusString.java new file mode 100644 index 000000000000..bf2d086efc64 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/getinstallstatus/SyncGetInstallStatusString.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_getinstallstatus_string_sync] +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.InstallStatus; +import com.google.cloud.gsuiteaddons.v1.InstallStatusName; + +public class SyncGetInstallStatusString { + + public static void main(String[] args) throws Exception { + syncGetInstallStatusString(); + } + + public static void syncGetInstallStatusString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + String name = InstallStatusName.of("[PROJECT]", "[DEPLOYMENT]").toString(); + InstallStatus response = gSuiteAddOnsClient.getInstallStatus(name); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_getinstallstatus_string_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/installdeployment/AsyncInstallDeployment.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/installdeployment/AsyncInstallDeployment.java new file mode 100644 index 000000000000..6c4d8d0079dc --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/installdeployment/AsyncInstallDeployment.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_installdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest; +import com.google.protobuf.Empty; + +public class AsyncInstallDeployment { + + public static void main(String[] args) throws Exception { + asyncInstallDeployment(); + } + + public static void asyncInstallDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + InstallDeploymentRequest request = + InstallDeploymentRequest.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .build(); + ApiFuture future = gSuiteAddOnsClient.installDeploymentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_installdeployment_async] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/installdeployment/SyncInstallDeployment.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/installdeployment/SyncInstallDeployment.java new file mode 100644 index 000000000000..c3f697ca4be7 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/installdeployment/SyncInstallDeployment.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_installdeployment_sync] +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest; + +public class SyncInstallDeployment { + + public static void main(String[] args) throws Exception { + syncInstallDeployment(); + } + + public static void syncInstallDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + InstallDeploymentRequest request = + InstallDeploymentRequest.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .build(); + gSuiteAddOnsClient.installDeployment(request); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_installdeployment_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/installdeployment/SyncInstallDeploymentDeploymentname.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/installdeployment/SyncInstallDeploymentDeploymentname.java new file mode 100644 index 000000000000..1d8f1c49cea6 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/installdeployment/SyncInstallDeploymentDeploymentname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_installdeployment_deploymentname_sync] +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; + +public class SyncInstallDeploymentDeploymentname { + + public static void main(String[] args) throws Exception { + syncInstallDeploymentDeploymentname(); + } + + public static void syncInstallDeploymentDeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + DeploymentName name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]"); + gSuiteAddOnsClient.installDeployment(name); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_installdeployment_deploymentname_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/installdeployment/SyncInstallDeploymentString.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/installdeployment/SyncInstallDeploymentString.java new file mode 100644 index 000000000000..d83b406e7dc3 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/installdeployment/SyncInstallDeploymentString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_installdeployment_string_sync] +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; + +public class SyncInstallDeploymentString { + + public static void main(String[] args) throws Exception { + syncInstallDeploymentString(); + } + + public static void syncInstallDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + String name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString(); + gSuiteAddOnsClient.installDeployment(name); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_installdeployment_string_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/AsyncListDeployments.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/AsyncListDeployments.java new file mode 100644 index 000000000000..0424eaebbee4 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/AsyncListDeployments.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_listdeployments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest; +import com.google.cloud.gsuiteaddons.v1.ProjectName; + +public class AsyncListDeployments { + + public static void main(String[] args) throws Exception { + asyncListDeployments(); + } + + public static void asyncListDeployments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + ListDeploymentsRequest request = + ListDeploymentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + gSuiteAddOnsClient.listDeploymentsPagedCallable().futureCall(request); + // Do something. + for (Deployment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_listdeployments_async] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/AsyncListDeploymentsPaged.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/AsyncListDeploymentsPaged.java new file mode 100644 index 000000000000..82ebf7eee2b9 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/AsyncListDeploymentsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_listdeployments_paged_async] +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest; +import com.google.cloud.gsuiteaddons.v1.ListDeploymentsResponse; +import com.google.cloud.gsuiteaddons.v1.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListDeploymentsPaged { + + public static void main(String[] args) throws Exception { + asyncListDeploymentsPaged(); + } + + public static void asyncListDeploymentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + ListDeploymentsRequest request = + ListDeploymentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListDeploymentsResponse response = + gSuiteAddOnsClient.listDeploymentsCallable().call(request); + for (Deployment element : response.getDeploymentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_listdeployments_paged_async] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/SyncListDeployments.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/SyncListDeployments.java new file mode 100644 index 000000000000..870da8b20350 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/SyncListDeployments.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_listdeployments_sync] +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest; +import com.google.cloud.gsuiteaddons.v1.ProjectName; + +public class SyncListDeployments { + + public static void main(String[] args) throws Exception { + syncListDeployments(); + } + + public static void syncListDeployments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + ListDeploymentsRequest request = + ListDeploymentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Deployment element : gSuiteAddOnsClient.listDeployments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_listdeployments_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/SyncListDeploymentsProjectname.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/SyncListDeploymentsProjectname.java new file mode 100644 index 000000000000..9cb6f726e2c3 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/SyncListDeploymentsProjectname.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_listdeployments_projectname_sync] +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.ProjectName; + +public class SyncListDeploymentsProjectname { + + public static void main(String[] args) throws Exception { + syncListDeploymentsProjectname(); + } + + public static void syncListDeploymentsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (Deployment element : gSuiteAddOnsClient.listDeployments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_listdeployments_projectname_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/SyncListDeploymentsString.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/SyncListDeploymentsString.java new file mode 100644 index 000000000000..df8903697d34 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/listdeployments/SyncListDeploymentsString.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_listdeployments_string_sync] +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.ProjectName; + +public class SyncListDeploymentsString { + + public static void main(String[] args) throws Exception { + syncListDeploymentsString(); + } + + public static void syncListDeploymentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (Deployment element : gSuiteAddOnsClient.listDeployments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_listdeployments_string_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/replacedeployment/AsyncReplaceDeployment.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/replacedeployment/AsyncReplaceDeployment.java new file mode 100644 index 000000000000..b48b948d1807 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/replacedeployment/AsyncReplaceDeployment.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_replacedeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest; + +public class AsyncReplaceDeployment { + + public static void main(String[] args) throws Exception { + asyncReplaceDeployment(); + } + + public static void asyncReplaceDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + ReplaceDeploymentRequest request = + ReplaceDeploymentRequest.newBuilder() + .setDeployment(Deployment.newBuilder().build()) + .build(); + ApiFuture future = + gSuiteAddOnsClient.replaceDeploymentCallable().futureCall(request); + // Do something. + Deployment response = future.get(); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_replacedeployment_async] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/replacedeployment/SyncReplaceDeployment.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/replacedeployment/SyncReplaceDeployment.java new file mode 100644 index 000000000000..b8e310c915a2 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/replacedeployment/SyncReplaceDeployment.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_replacedeployment_sync] +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest; + +public class SyncReplaceDeployment { + + public static void main(String[] args) throws Exception { + syncReplaceDeployment(); + } + + public static void syncReplaceDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + ReplaceDeploymentRequest request = + ReplaceDeploymentRequest.newBuilder() + .setDeployment(Deployment.newBuilder().build()) + .build(); + Deployment response = gSuiteAddOnsClient.replaceDeployment(request); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_replacedeployment_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/replacedeployment/SyncReplaceDeploymentDeployment.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/replacedeployment/SyncReplaceDeploymentDeployment.java new file mode 100644 index 000000000000..1afd474e654f --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/replacedeployment/SyncReplaceDeploymentDeployment.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_replacedeployment_deployment_sync] +import com.google.cloud.gsuiteaddons.v1.Deployment; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; + +public class SyncReplaceDeploymentDeployment { + + public static void main(String[] args) throws Exception { + syncReplaceDeploymentDeployment(); + } + + public static void syncReplaceDeploymentDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + Deployment deployment = Deployment.newBuilder().build(); + Deployment response = gSuiteAddOnsClient.replaceDeployment(deployment); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_replacedeployment_deployment_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/uninstalldeployment/AsyncUninstallDeployment.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/uninstalldeployment/AsyncUninstallDeployment.java new file mode 100644 index 000000000000..a9f662aceb33 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/uninstalldeployment/AsyncUninstallDeployment.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_uninstalldeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest; +import com.google.protobuf.Empty; + +public class AsyncUninstallDeployment { + + public static void main(String[] args) throws Exception { + asyncUninstallDeployment(); + } + + public static void asyncUninstallDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + UninstallDeploymentRequest request = + UninstallDeploymentRequest.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .build(); + ApiFuture future = + gSuiteAddOnsClient.uninstallDeploymentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_uninstalldeployment_async] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/uninstalldeployment/SyncUninstallDeployment.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/uninstalldeployment/SyncUninstallDeployment.java new file mode 100644 index 000000000000..b1934290017f --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/uninstalldeployment/SyncUninstallDeployment.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.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_uninstalldeployment_sync] +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; +import com.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest; + +public class SyncUninstallDeployment { + + public static void main(String[] args) throws Exception { + syncUninstallDeployment(); + } + + public static void syncUninstallDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + UninstallDeploymentRequest request = + UninstallDeploymentRequest.newBuilder() + .setName(DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString()) + .build(); + gSuiteAddOnsClient.uninstallDeployment(request); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_uninstalldeployment_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/uninstalldeployment/SyncUninstallDeploymentDeploymentname.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/uninstalldeployment/SyncUninstallDeploymentDeploymentname.java new file mode 100644 index 000000000000..7a1b0d42c322 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/uninstalldeployment/SyncUninstallDeploymentDeploymentname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_uninstalldeployment_deploymentname_sync] +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; + +public class SyncUninstallDeploymentDeploymentname { + + public static void main(String[] args) throws Exception { + syncUninstallDeploymentDeploymentname(); + } + + public static void syncUninstallDeploymentDeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + DeploymentName name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]"); + gSuiteAddOnsClient.uninstallDeployment(name); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_uninstalldeployment_deploymentname_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/uninstalldeployment/SyncUninstallDeploymentString.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/uninstalldeployment/SyncUninstallDeploymentString.java new file mode 100644 index 000000000000..df6c63860e5c --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonsclient/uninstalldeployment/SyncUninstallDeploymentString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsclient_uninstalldeployment_string_sync] +import com.google.cloud.gsuiteaddons.v1.DeploymentName; +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsClient; + +public class SyncUninstallDeploymentString { + + public static void main(String[] args) throws Exception { + syncUninstallDeploymentString(); + } + + public static void syncUninstallDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.create()) { + String name = DeploymentName.of("[PROJECT]", "[DEPLOYMENT]").toString(); + gSuiteAddOnsClient.uninstallDeployment(name); + } + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsclient_uninstalldeployment_string_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonssettings/getauthorization/SyncGetAuthorization.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonssettings/getauthorization/SyncGetAuthorization.java new file mode 100644 index 000000000000..1a27ab5fd9b8 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/gsuiteaddonssettings/getauthorization/SyncGetAuthorization.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gsuiteaddons.v1.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonssettings_getauthorization_sync] +import com.google.cloud.gsuiteaddons.v1.GSuiteAddOnsSettings; +import java.time.Duration; + +public class SyncGetAuthorization { + + public static void main(String[] args) throws Exception { + syncGetAuthorization(); + } + + public static void syncGetAuthorization() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + GSuiteAddOnsSettings.Builder gSuiteAddOnsSettingsBuilder = GSuiteAddOnsSettings.newBuilder(); + gSuiteAddOnsSettingsBuilder + .getAuthorizationSettings() + .setRetrySettings( + gSuiteAddOnsSettingsBuilder + .getAuthorizationSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + GSuiteAddOnsSettings gSuiteAddOnsSettings = gSuiteAddOnsSettingsBuilder.build(); + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonssettings_getauthorization_sync] diff --git a/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/stub/gsuiteaddonsstubsettings/getauthorization/SyncGetAuthorization.java b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/stub/gsuiteaddonsstubsettings/getauthorization/SyncGetAuthorization.java new file mode 100644 index 000000000000..848e0cab5236 --- /dev/null +++ b/java-gsuite-addons/samples/snippets/generated/com/google/cloud/gsuiteaddons/v1/stub/gsuiteaddonsstubsettings/getauthorization/SyncGetAuthorization.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.gsuiteaddons.v1.stub.samples; + +// [START gsuiteaddons_v1_generated_gsuiteaddonsstubsettings_getauthorization_sync] +import com.google.cloud.gsuiteaddons.v1.stub.GSuiteAddOnsStubSettings; +import java.time.Duration; + +public class SyncGetAuthorization { + + public static void main(String[] args) throws Exception { + syncGetAuthorization(); + } + + public static void syncGetAuthorization() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + GSuiteAddOnsStubSettings.Builder gSuiteAddOnsSettingsBuilder = + GSuiteAddOnsStubSettings.newBuilder(); + gSuiteAddOnsSettingsBuilder + .getAuthorizationSettings() + .setRetrySettings( + gSuiteAddOnsSettingsBuilder + .getAuthorizationSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + GSuiteAddOnsStubSettings gSuiteAddOnsSettings = gSuiteAddOnsSettingsBuilder.build(); + } +} +// [END gsuiteaddons_v1_generated_gsuiteaddonsstubsettings_getauthorization_sync]