diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index a79f0627..a454a61e 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:2567a120ce90fadb6201999b87d649d9f67459de28815ad239bce9ebfaa18a74 -# created: 2022-05-19T15:12:45.278246753Z + digest: sha256:6d4e3a15c62cfdcb823d60e16da7521e7c6fc00eba07c8ff12e4de9924a57d28 +# created: 2022-06-29T23:17:33.110417661Z diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 6f09d695..dd5626f3 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -11,7 +11,6 @@ branchProtectionRules: - dependencies (8) - dependencies (11) - lint - - clirr - units (8) - units (11) - 'Kokoro - Test: Integration' @@ -26,7 +25,6 @@ branchProtectionRules: - dependencies (8) - dependencies (11) - lint - - clirr - units (7) - units (8) - units (11) diff --git a/.kokoro/common.sh b/.kokoro/common.sh index ace89f45..f8f957af 100644 --- a/.kokoro/common.sh +++ b/.kokoro/common.sh @@ -55,4 +55,6 @@ function retry_with_backoff { ## Helper functionss function now() { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n'; } function msg() { println "$*" >&2; } -function println() { printf '%s\n' "$(now) $*"; } \ No newline at end of file +function println() { printf '%s\n' "$(now) $*"; } + +## Helper comment to trigger updated repo dependency release \ No newline at end of file diff --git a/.kokoro/release/stage.sh b/.kokoro/release/stage.sh index 77dc4e8f..1dba8de1 100755 --- a/.kokoro/release/stage.sh +++ b/.kokoro/release/stage.sh @@ -32,6 +32,7 @@ retry_with_backoff 3 10 \ mvn clean deploy -B \ --settings ${MAVEN_SETTINGS_FILE} \ -DskipTests=true \ + -Dclirr.skip=true \ -DperformRelease=true \ -Dgpg.executable=gpg \ -Dgpg.passphrase=${GPG_PASSPHRASE} \ @@ -42,4 +43,4 @@ then mvn nexus-staging:release -B \ -DperformRelease=true \ --settings=settings.xml -fi \ No newline at end of file +fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 64fb42dd..c21d849b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [1.3.0](https://github.com/googleapis/java-service-control/compare/v1.2.0...v1.3.0) (2022-07-01) + + +### Features + +* Add Java REST transport to analytics, servicecontrol, servicemanagement, serviceusage and langauge APIs ([e5c082d](https://github.com/googleapis/java-service-control/commit/e5c082d34f9c881219cbf66d2424ca74860c9c2f)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#186](https://github.com/googleapis/java-service-control/issues/186)) ([9935da2](https://github.com/googleapis/java-service-control/commit/9935da242d93cd580debb873fb6cc90ebd98be53)) + ## [1.2.0](https://github.com/googleapis/java-service-control/compare/v1.1.11...v1.2.0) (2022-05-19) diff --git a/README.md b/README.md index 54aa97d7..37db08d2 100644 --- a/README.md +++ b/README.md @@ -19,20 +19,20 @@ If you are using Maven, add this to your pom.xml file: com.google.cloud google-cloud-service-control - 1.1.11 + 1.2.0 ``` If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-service-control:1.1.11' +implementation 'com.google.cloud:google-cloud-service-control:1.2.0' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-service-control" % "1.1.11" +libraryDependencies += "com.google.cloud" % "google-cloud-service-control" % "1.2.0" ``` ## Authentication diff --git a/google-cloud-service-control-bom/pom.xml b/google-cloud-service-control-bom/pom.xml index 185f59e6..3367c47f 100644 --- a/google-cloud-service-control-bom/pom.xml +++ b/google-cloud-service-control-bom/pom.xml @@ -3,12 +3,12 @@ 4.0.0 com.google.cloud google-cloud-service-control-bom - 1.2.0 + 1.3.0 pom com.google.cloud google-cloud-shared-config - 1.4.0 + 1.5.0 Google Service Control API BOM @@ -56,27 +56,27 @@ com.google.cloud google-cloud-service-control - 1.2.0 + 1.3.0 com.google.api.grpc grpc-google-cloud-service-control-v1 - 1.2.0 + 1.3.0 com.google.api.grpc grpc-google-cloud-service-control-v2 - 1.2.0 + 1.3.0 com.google.api.grpc proto-google-cloud-service-control-v1 - 1.2.0 + 1.3.0 com.google.api.grpc proto-google-cloud-service-control-v2 - 1.2.0 + 1.3.0 diff --git a/google-cloud-service-control/pom.xml b/google-cloud-service-control/pom.xml index 865ea1c3..34efc6df 100644 --- a/google-cloud-service-control/pom.xml +++ b/google-cloud-service-control/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-service-control - 1.2.0 + 1.3.0 jar Google Service Control API https://github.com/googleapis/java-service-control @@ -11,7 +11,7 @@ com.google.cloud google-cloud-service-control-parent - 1.2.0 + 1.3.0 google-cloud-service-control @@ -62,6 +62,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -86,12 +90,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/QuotaControllerClient.java b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/QuotaControllerClient.java index fa1a1a33..1ac6255b 100644 --- a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/QuotaControllerClient.java +++ b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/QuotaControllerClient.java @@ -16,7 +16,6 @@ package com.google.api.servicecontrol.v1; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.UnaryCallable; import com.google.api.servicecontrol.v1.stub.QuotaControllerStub; @@ -100,6 +99,21 @@ * QuotaControllerClient.create(quotaControllerSettings); * } * + *

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.
+ * QuotaControllerSettings quotaControllerSettings =
+ *     QuotaControllerSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             QuotaControllerSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * QuotaControllerClient quotaControllerClient =
+ *     QuotaControllerClient.create(quotaControllerSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") @@ -125,7 +139,6 @@ public static final QuotaControllerClient create(QuotaControllerSettings setting * Constructs an instance of QuotaControllerClient, using the given stub for making calls. This is * for advanced usage - prefer using create(QuotaControllerSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final QuotaControllerClient create(QuotaControllerStub stub) { return new QuotaControllerClient(stub); } @@ -140,7 +153,6 @@ protected QuotaControllerClient(QuotaControllerSettings settings) throws IOExcep this.stub = ((QuotaControllerStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected QuotaControllerClient(QuotaControllerStub stub) { this.settings = null; this.stub = stub; @@ -150,7 +162,6 @@ public final QuotaControllerSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public QuotaControllerStub getStub() { return stub; } diff --git a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/QuotaControllerSettings.java b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/QuotaControllerSettings.java index 3527060f..bb438383 100644 --- a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/QuotaControllerSettings.java +++ b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/QuotaControllerSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -99,11 +100,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return QuotaControllerStubSettings.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 QuotaControllerStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return QuotaControllerStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return QuotaControllerStubSettings.defaultTransportChannelProvider(); } @@ -113,11 +121,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return QuotaControllerStubSettings.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); @@ -155,6 +169,11 @@ private static Builder createDefault() { return new Builder(QuotaControllerStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(QuotaControllerStubSettings.newHttpJsonBuilder()); + } + public QuotaControllerStubSettings.Builder getStubSettingsBuilder() { return ((QuotaControllerStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/ServiceControllerClient.java b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/ServiceControllerClient.java index 8025654f..b82e693a 100644 --- a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/ServiceControllerClient.java +++ b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/ServiceControllerClient.java @@ -16,7 +16,6 @@ package com.google.api.servicecontrol.v1; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.UnaryCallable; import com.google.api.servicecontrol.v1.stub.ServiceControllerStub; @@ -100,6 +99,21 @@ * ServiceControllerClient.create(serviceControllerSettings); * } * + *

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.
+ * ServiceControllerSettings serviceControllerSettings =
+ *     ServiceControllerSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ServiceControllerSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ServiceControllerClient serviceControllerClient =
+ *     ServiceControllerClient.create(serviceControllerSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") @@ -125,7 +139,6 @@ public static final ServiceControllerClient create(ServiceControllerSettings set * Constructs an instance of ServiceControllerClient, using the given stub for making calls. This * is for advanced usage - prefer using create(ServiceControllerSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ServiceControllerClient create(ServiceControllerStub stub) { return new ServiceControllerClient(stub); } @@ -140,7 +153,6 @@ protected ServiceControllerClient(ServiceControllerSettings settings) throws IOE this.stub = ((ServiceControllerStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected ServiceControllerClient(ServiceControllerStub stub) { this.settings = null; this.stub = stub; @@ -150,7 +162,6 @@ public final ServiceControllerSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ServiceControllerStub getStub() { return stub; } diff --git a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/ServiceControllerSettings.java b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/ServiceControllerSettings.java index 0751c829..8f7c77af 100644 --- a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/ServiceControllerSettings.java +++ b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/ServiceControllerSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -104,11 +105,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ServiceControllerStubSettings.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 ServiceControllerStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ServiceControllerStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ServiceControllerStubSettings.defaultTransportChannelProvider(); } @@ -118,11 +126,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ServiceControllerStubSettings.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); @@ -160,6 +174,11 @@ private static Builder createDefault() { return new Builder(ServiceControllerStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ServiceControllerStubSettings.newHttpJsonBuilder()); + } + public ServiceControllerStubSettings.Builder getStubSettingsBuilder() { return ((ServiceControllerStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/HttpJsonQuotaControllerCallableFactory.java b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/HttpJsonQuotaControllerCallableFactory.java new file mode 100644 index 00000000..36efa70a --- /dev/null +++ b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/HttpJsonQuotaControllerCallableFactory.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.api.servicecontrol.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 QuotaController service API. + * + *

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

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonQuotaControllerStub extends QuotaControllerStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + allocateQuotaMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.api.servicecontrol.v1.QuotaController/AllocateQuota") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/services/{serviceName}:allocateQuota", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "serviceName", request.getServiceName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearServiceName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AllocateQuotaResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable allocateQuotaCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonQuotaControllerStub create(QuotaControllerStubSettings settings) + throws IOException { + return new HttpJsonQuotaControllerStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonQuotaControllerStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonQuotaControllerStub( + QuotaControllerStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonQuotaControllerStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonQuotaControllerStub( + QuotaControllerStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonQuotaControllerStub, 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 HttpJsonQuotaControllerStub( + QuotaControllerStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonQuotaControllerCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonQuotaControllerStub, 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 HttpJsonQuotaControllerStub( + QuotaControllerStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + allocateQuotaTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(allocateQuotaMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.allocateQuotaCallable = + callableFactory.createUnaryCallable( + allocateQuotaTransportSettings, settings.allocateQuotaSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(allocateQuotaMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable allocateQuotaCallable() { + return allocateQuotaCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/HttpJsonServiceControllerCallableFactory.java b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/HttpJsonServiceControllerCallableFactory.java new file mode 100644 index 00000000..384584d4 --- /dev/null +++ b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/HttpJsonServiceControllerCallableFactory.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.api.servicecontrol.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 ServiceController service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonServiceControllerCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/HttpJsonServiceControllerStub.java b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/HttpJsonServiceControllerStub.java new file mode 100644 index 00000000..91caf6f9 --- /dev/null +++ b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/HttpJsonServiceControllerStub.java @@ -0,0 +1,243 @@ +/* + * 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.api.servicecontrol.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.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.api.servicecontrol.v1.CheckRequest; +import com.google.api.servicecontrol.v1.CheckResponse; +import com.google.api.servicecontrol.v1.ReportRequest; +import com.google.api.servicecontrol.v1.ReportResponse; +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 ServiceController service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonServiceControllerStub extends ServiceControllerStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor checkMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.api.servicecontrol.v1.ServiceController/Check") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/services/{serviceName}:check", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = ProtoRestSerializer.create(); + serializer.putPathParam(fields, "serviceName", request.getServiceName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearServiceName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CheckResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor reportMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.api.servicecontrol.v1.ServiceController/Report") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/services/{serviceName}:report", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "serviceName", request.getServiceName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearServiceName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ReportResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable checkCallable; + private final UnaryCallable reportCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonServiceControllerStub create(ServiceControllerStubSettings settings) + throws IOException { + return new HttpJsonServiceControllerStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonServiceControllerStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonServiceControllerStub( + ServiceControllerStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonServiceControllerStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonServiceControllerStub( + ServiceControllerStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonServiceControllerStub, 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 HttpJsonServiceControllerStub( + ServiceControllerStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonServiceControllerCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonServiceControllerStub, 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 HttpJsonServiceControllerStub( + ServiceControllerStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings checkTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(checkMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings reportTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(reportMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.checkCallable = + callableFactory.createUnaryCallable( + checkTransportSettings, settings.checkSettings(), clientContext); + this.reportCallable = + callableFactory.createUnaryCallable( + reportTransportSettings, settings.reportSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(checkMethodDescriptor); + methodDescriptors.add(reportMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable checkCallable() { + return checkCallable; + } + + @Override + public UnaryCallable reportCallable() { + return reportCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/QuotaControllerStubSettings.java b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/QuotaControllerStubSettings.java index 6939ed88..1beec9f6 100644 --- a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/QuotaControllerStubSettings.java +++ b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/QuotaControllerStubSettings.java @@ -24,6 +24,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.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -93,13 +96,17 @@ public UnaryCallSettings allocateQu return allocateQuotaSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public QuotaControllerStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcQuotaControllerStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonQuotaControllerStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -132,18 +139,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(QuotaControllerStubSettings.class)) @@ -151,11 +165,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(QuotaControllerStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return QuotaControllerStubSettings.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); @@ -233,6 +266,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 .allocateQuotaSettings() diff --git a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/ServiceControllerStubSettings.java b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/ServiceControllerStubSettings.java index a861871f..d8b05eec 100644 --- a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/ServiceControllerStubSettings.java +++ b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v1/stub/ServiceControllerStubSettings.java @@ -24,6 +24,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.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -102,13 +105,17 @@ public UnaryCallSettings reportSettings() { return reportSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ServiceControllerStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcServiceControllerStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonServiceControllerStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -141,18 +148,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(ServiceControllerStubSettings.class)) @@ -160,11 +174,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(ServiceControllerStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ServiceControllerStubSettings.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); @@ -266,6 +299,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 .checkSettings() diff --git a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/ServiceControllerClient.java b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/ServiceControllerClient.java index 82138a70..6987abbb 100644 --- a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/ServiceControllerClient.java +++ b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/ServiceControllerClient.java @@ -16,7 +16,6 @@ package com.google.api.servicecontrol.v2; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.UnaryCallable; import com.google.api.servicecontrol.v2.stub.ServiceControllerStub; @@ -105,6 +104,21 @@ * ServiceControllerClient.create(serviceControllerSettings); * } * + *

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.
+ * ServiceControllerSettings serviceControllerSettings =
+ *     ServiceControllerSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ServiceControllerSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ServiceControllerClient serviceControllerClient =
+ *     ServiceControllerClient.create(serviceControllerSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") @@ -130,7 +144,6 @@ public static final ServiceControllerClient create(ServiceControllerSettings set * Constructs an instance of ServiceControllerClient, using the given stub for making calls. This * is for advanced usage - prefer using create(ServiceControllerSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ServiceControllerClient create(ServiceControllerStub stub) { return new ServiceControllerClient(stub); } @@ -145,7 +158,6 @@ protected ServiceControllerClient(ServiceControllerSettings settings) throws IOE this.stub = ((ServiceControllerStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected ServiceControllerClient(ServiceControllerStub stub) { this.settings = null; this.stub = stub; @@ -155,7 +167,6 @@ public final ServiceControllerSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ServiceControllerStub getStub() { return stub; } diff --git a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/ServiceControllerSettings.java b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/ServiceControllerSettings.java index c34c9719..7aa34a2a 100644 --- a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/ServiceControllerSettings.java +++ b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/ServiceControllerSettings.java @@ -21,6 +21,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -104,11 +105,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ServiceControllerStubSettings.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 ServiceControllerStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ServiceControllerStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ServiceControllerStubSettings.defaultTransportChannelProvider(); } @@ -118,11 +126,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ServiceControllerStubSettings.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); @@ -160,6 +174,11 @@ private static Builder createDefault() { return new Builder(ServiceControllerStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ServiceControllerStubSettings.newHttpJsonBuilder()); + } + public ServiceControllerStubSettings.Builder getStubSettingsBuilder() { return ((ServiceControllerStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/stub/HttpJsonServiceControllerCallableFactory.java b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/stub/HttpJsonServiceControllerCallableFactory.java new file mode 100644 index 00000000..aa475e1c --- /dev/null +++ b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/stub/HttpJsonServiceControllerCallableFactory.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.api.servicecontrol.v2.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 ServiceController service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonServiceControllerCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/stub/HttpJsonServiceControllerStub.java b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/stub/HttpJsonServiceControllerStub.java new file mode 100644 index 00000000..ff00dc8a --- /dev/null +++ b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/stub/HttpJsonServiceControllerStub.java @@ -0,0 +1,243 @@ +/* + * 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.api.servicecontrol.v2.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.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.api.servicecontrol.v2.CheckRequest; +import com.google.api.servicecontrol.v2.CheckResponse; +import com.google.api.servicecontrol.v2.ReportRequest; +import com.google.api.servicecontrol.v2.ReportResponse; +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 ServiceController service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonServiceControllerStub extends ServiceControllerStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor checkMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.api.servicecontrol.v2.ServiceController/Check") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/services/{serviceName}:check", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = ProtoRestSerializer.create(); + serializer.putPathParam(fields, "serviceName", request.getServiceName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearServiceName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CheckResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor reportMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.api.servicecontrol.v2.ServiceController/Report") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2/services/{serviceName}:report", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "serviceName", request.getServiceName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearServiceName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ReportResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable checkCallable; + private final UnaryCallable reportCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonServiceControllerStub create(ServiceControllerStubSettings settings) + throws IOException { + return new HttpJsonServiceControllerStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonServiceControllerStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonServiceControllerStub( + ServiceControllerStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonServiceControllerStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonServiceControllerStub( + ServiceControllerStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonServiceControllerStub, 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 HttpJsonServiceControllerStub( + ServiceControllerStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonServiceControllerCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonServiceControllerStub, 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 HttpJsonServiceControllerStub( + ServiceControllerStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings checkTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(checkMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings reportTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(reportMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.checkCallable = + callableFactory.createUnaryCallable( + checkTransportSettings, settings.checkSettings(), clientContext); + this.reportCallable = + callableFactory.createUnaryCallable( + reportTransportSettings, settings.reportSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(checkMethodDescriptor); + methodDescriptors.add(reportMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable checkCallable() { + return checkCallable; + } + + @Override + public UnaryCallable reportCallable() { + return reportCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/stub/ServiceControllerStubSettings.java b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/stub/ServiceControllerStubSettings.java index 240d1852..edc8408d 100644 --- a/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/stub/ServiceControllerStubSettings.java +++ b/google-cloud-service-control/src/main/java/com/google/api/servicecontrol/v2/stub/ServiceControllerStubSettings.java @@ -24,6 +24,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.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -102,13 +105,17 @@ public UnaryCallSettings reportSettings() { return reportSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ServiceControllerStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcServiceControllerStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonServiceControllerStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -141,18 +148,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(ServiceControllerStubSettings.class)) @@ -160,11 +174,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(ServiceControllerStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ServiceControllerStubSettings.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); @@ -259,6 +292,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 .checkSettings() diff --git a/google-cloud-service-control/src/test/java/com/google/api/servicecontrol/v1/QuotaControllerClientHttpJsonTest.java b/google-cloud-service-control/src/test/java/com/google/api/servicecontrol/v1/QuotaControllerClientHttpJsonTest.java new file mode 100644 index 00000000..7ab4836d --- /dev/null +++ b/google-cloud-service-control/src/test/java/com/google/api/servicecontrol/v1/QuotaControllerClientHttpJsonTest.java @@ -0,0 +1,131 @@ +/* + * 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.api.servicecontrol.v1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.api.servicecontrol.v1.stub.HttpJsonQuotaControllerStub; +import java.io.IOException; +import java.util.ArrayList; +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 QuotaControllerClientHttpJsonTest { + private static MockHttpService mockService; + private static QuotaControllerClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonQuotaControllerStub.getMethodDescriptors(), + QuotaControllerSettings.getDefaultEndpoint()); + QuotaControllerSettings settings = + QuotaControllerSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + QuotaControllerSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = QuotaControllerClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void allocateQuotaTest() throws Exception { + AllocateQuotaResponse expectedResponse = + AllocateQuotaResponse.newBuilder() + .setOperationId("operationId129704162") + .addAllAllocateErrors(new ArrayList()) + .addAllQuotaMetrics(new ArrayList()) + .setServiceConfigId("serviceConfigId650537426") + .build(); + mockService.addResponse(expectedResponse); + + AllocateQuotaRequest request = + AllocateQuotaRequest.newBuilder() + .setServiceName("serviceName-4234") + .setAllocateOperation(QuotaOperation.newBuilder().build()) + .setServiceConfigId("serviceConfigId650537426") + .build(); + + AllocateQuotaResponse actualResponse = client.allocateQuota(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void allocateQuotaExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + AllocateQuotaRequest request = + AllocateQuotaRequest.newBuilder() + .setServiceName("serviceName-4234") + .setAllocateOperation(QuotaOperation.newBuilder().build()) + .setServiceConfigId("serviceConfigId650537426") + .build(); + client.allocateQuota(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-service-control/src/test/java/com/google/api/servicecontrol/v1/ServiceControllerClientHttpJsonTest.java b/google-cloud-service-control/src/test/java/com/google/api/servicecontrol/v1/ServiceControllerClientHttpJsonTest.java new file mode 100644 index 00000000..01b2f245 --- /dev/null +++ b/google-cloud-service-control/src/test/java/com/google/api/servicecontrol/v1/ServiceControllerClientHttpJsonTest.java @@ -0,0 +1,188 @@ +/* + * 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.api.servicecontrol.v1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.api.servicecontrol.v1.stub.HttpJsonServiceControllerStub; +import java.io.IOException; +import java.util.ArrayList; +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 ServiceControllerClientHttpJsonTest { + private static MockHttpService mockService; + private static ServiceControllerClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonServiceControllerStub.getMethodDescriptors(), + ServiceControllerSettings.getDefaultEndpoint()); + ServiceControllerSettings settings = + ServiceControllerSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ServiceControllerSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ServiceControllerClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void checkTest() throws Exception { + CheckResponse expectedResponse = + CheckResponse.newBuilder() + .setOperationId("operationId129704162") + .addAllCheckErrors(new ArrayList()) + .setServiceConfigId("serviceConfigId650537426") + .setServiceRolloutId("serviceRolloutId47544183") + .setCheckInfo(CheckResponse.CheckInfo.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + CheckRequest request = + CheckRequest.newBuilder() + .setServiceName("serviceName-4234") + .setOperation(Operation.newBuilder().build()) + .setServiceConfigId("serviceConfigId650537426") + .build(); + + CheckResponse actualResponse = client.check(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void checkExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CheckRequest request = + CheckRequest.newBuilder() + .setServiceName("serviceName-4234") + .setOperation(Operation.newBuilder().build()) + .setServiceConfigId("serviceConfigId650537426") + .build(); + client.check(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void reportTest() throws Exception { + ReportResponse expectedResponse = + ReportResponse.newBuilder() + .addAllReportErrors(new ArrayList()) + .setServiceConfigId("serviceConfigId650537426") + .setServiceRolloutId("serviceRolloutId47544183") + .build(); + mockService.addResponse(expectedResponse); + + ReportRequest request = + ReportRequest.newBuilder() + .setServiceName("serviceName-4234") + .addAllOperations(new ArrayList()) + .setServiceConfigId("serviceConfigId650537426") + .build(); + + ReportResponse actualResponse = client.report(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void reportExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReportRequest request = + ReportRequest.newBuilder() + .setServiceName("serviceName-4234") + .addAllOperations(new ArrayList()) + .setServiceConfigId("serviceConfigId650537426") + .build(); + client.report(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-service-control/src/test/java/com/google/api/servicecontrol/v2/ServiceControllerClientHttpJsonTest.java b/google-cloud-service-control/src/test/java/com/google/api/servicecontrol/v2/ServiceControllerClientHttpJsonTest.java new file mode 100644 index 00000000..b4cc80a6 --- /dev/null +++ b/google-cloud-service-control/src/test/java/com/google/api/servicecontrol/v2/ServiceControllerClientHttpJsonTest.java @@ -0,0 +1,187 @@ +/* + * 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.api.servicecontrol.v2; + +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.api.servicecontrol.v2.stub.HttpJsonServiceControllerStub; +import com.google.rpc.Status; +import com.google.rpc.context.AttributeContext; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +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 ServiceControllerClientHttpJsonTest { + private static MockHttpService mockService; + private static ServiceControllerClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonServiceControllerStub.getMethodDescriptors(), + ServiceControllerSettings.getDefaultEndpoint()); + ServiceControllerSettings settings = + ServiceControllerSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ServiceControllerSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ServiceControllerClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void checkTest() throws Exception { + CheckResponse expectedResponse = + CheckResponse.newBuilder() + .setStatus(Status.newBuilder().build()) + .putAllHeaders(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + CheckRequest request = + CheckRequest.newBuilder() + .setServiceName("serviceName-4234") + .setServiceConfigId("serviceConfigId650537426") + .setAttributes(AttributeContext.newBuilder().build()) + .addAllResources(new ArrayList()) + .setFlags("flags97513095") + .build(); + + CheckResponse actualResponse = client.check(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void checkExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CheckRequest request = + CheckRequest.newBuilder() + .setServiceName("serviceName-4234") + .setServiceConfigId("serviceConfigId650537426") + .setAttributes(AttributeContext.newBuilder().build()) + .addAllResources(new ArrayList()) + .setFlags("flags97513095") + .build(); + client.check(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void reportTest() throws Exception { + ReportResponse expectedResponse = ReportResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ReportRequest request = + ReportRequest.newBuilder() + .setServiceName("serviceName-4234") + .setServiceConfigId("serviceConfigId650537426") + .addAllOperations(new ArrayList()) + .build(); + + ReportResponse actualResponse = client.report(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void reportExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReportRequest request = + ReportRequest.newBuilder() + .setServiceName("serviceName-4234") + .setServiceConfigId("serviceConfigId650537426") + .addAllOperations(new ArrayList()) + .build(); + client.report(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/grpc-google-cloud-service-control-v1/pom.xml b/grpc-google-cloud-service-control-v1/pom.xml index d8fb1a40..14109b48 100644 --- a/grpc-google-cloud-service-control-v1/pom.xml +++ b/grpc-google-cloud-service-control-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-service-control-v1 - 1.2.0 + 1.3.0 grpc-google-cloud-service-control-v1 GRPC library for google-cloud-service-control com.google.cloud google-cloud-service-control-parent - 1.2.0 + 1.3.0 diff --git a/grpc-google-cloud-service-control-v2/pom.xml b/grpc-google-cloud-service-control-v2/pom.xml index 7de98fca..8c507a5b 100644 --- a/grpc-google-cloud-service-control-v2/pom.xml +++ b/grpc-google-cloud-service-control-v2/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-service-control-v2 - 1.2.0 + 1.3.0 grpc-google-cloud-service-control-v2 GRPC library for google-cloud-service-control com.google.cloud google-cloud-service-control-parent - 1.2.0 + 1.3.0 diff --git a/pom.xml b/pom.xml index fd4fc990..c61a7c34 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-service-control-parent pom - 1.2.0 + 1.3.0 Google Service Control API Parent https://github.com/googleapis/java-service-control @@ -14,7 +14,7 @@ com.google.cloud google-cloud-shared-config - 1.4.0 + 1.5.0 @@ -69,33 +69,33 @@ com.google.cloud google-cloud-service-control - 1.2.0 + 1.3.0 com.google.api.grpc proto-google-cloud-service-control-v2 - 1.2.0 + 1.3.0 com.google.api.grpc grpc-google-cloud-service-control-v2 - 1.2.0 + 1.3.0 com.google.api.grpc grpc-google-cloud-service-control-v1 - 1.2.0 + 1.3.0 com.google.api.grpc proto-google-cloud-service-control-v1 - 1.2.0 + 1.3.0 com.google.cloud google-cloud-shared-dependencies - 2.12.0 + 2.13.0 pom import diff --git a/proto-google-cloud-service-control-v1/pom.xml b/proto-google-cloud-service-control-v1/pom.xml index c0a1f1fa..0a3c40c5 100644 --- a/proto-google-cloud-service-control-v1/pom.xml +++ b/proto-google-cloud-service-control-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-service-control-v1 - 1.2.0 + 1.3.0 proto-google-cloud-service-control-v1 Proto library for google-cloud-service-control com.google.cloud google-cloud-service-control-parent - 1.2.0 + 1.3.0 diff --git a/proto-google-cloud-service-control-v2/pom.xml b/proto-google-cloud-service-control-v2/pom.xml index bc7e5e9e..019c2482 100644 --- a/proto-google-cloud-service-control-v2/pom.xml +++ b/proto-google-cloud-service-control-v2/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-service-control-v2 - 1.2.0 + 1.3.0 proto-google-cloud-service-control-v2 Proto library for google-cloud-service-control com.google.cloud google-cloud-service-control-parent - 1.2.0 + 1.3.0 diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 2f77b5bb..19366c3c 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -29,7 +29,7 @@ com.google.cloud google-cloud-service-control - 1.1.11 + 1.2.0 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index be87a29e..f480b2fe 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-service-control - 1.1.11 + 1.2.0 diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 064595c4..84d82e9a 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-service-control - 1.1.11 + 1.2.0 diff --git a/versions.txt b/versions.txt index dff9ef1a..9559c853 100644 --- a/versions.txt +++ b/versions.txt @@ -1,8 +1,8 @@ # Format: # module:released-version:current-version -google-cloud-service-control:1.2.0:1.2.0 -grpc-google-cloud-service-control-v1:1.2.0:1.2.0 -proto-google-cloud-service-control-v1:1.2.0:1.2.0 -proto-google-cloud-service-control-v2:1.2.0:1.2.0 -grpc-google-cloud-service-control-v2:1.2.0:1.2.0 +google-cloud-service-control:1.3.0:1.3.0 +grpc-google-cloud-service-control-v1:1.3.0:1.3.0 +proto-google-cloud-service-control-v1:1.3.0:1.3.0 +proto-google-cloud-service-control-v2:1.3.0:1.3.0 +grpc-google-cloud-service-control-v2:1.3.0:1.3.0