diff --git a/java-appengine-admin/google-cloud-appengine-admin/pom.xml b/java-appengine-admin/google-cloud-appengine-admin/pom.xml index d5964de5f698..dcb540b6bbc8 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/pom.xml +++ b/java-appengine-admin/google-cloud-appengine-admin/pom.xml @@ -58,6 +58,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -77,12 +81,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ApplicationsClient.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ApplicationsClient.java index e816f70a01ec..98936f3535da 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ApplicationsClient.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ApplicationsClient.java @@ -18,13 +18,13 @@ import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.appengine.v1.stub.ApplicationsStub; import com.google.appengine.v1.stub.ApplicationsStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -93,13 +93,28 @@ * ApplicationsClient applicationsClient = ApplicationsClient.create(applicationsSettings); * } * + *

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.
+ * ApplicationsSettings applicationsSettings =
+ *     ApplicationsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ApplicationsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ApplicationsClient applicationsClient = ApplicationsClient.create(applicationsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class ApplicationsClient implements BackgroundResource { private final ApplicationsSettings settings; private final ApplicationsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ApplicationsClient with default settings. */ public static final ApplicationsClient create() throws IOException { @@ -118,7 +133,6 @@ public static final ApplicationsClient create(ApplicationsSettings settings) thr * Constructs an instance of ApplicationsClient, using the given stub for making calls. This is * for advanced usage - prefer using create(ApplicationsSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ApplicationsClient create(ApplicationsStub stub) { return new ApplicationsClient(stub); } @@ -131,21 +145,23 @@ public static final ApplicationsClient create(ApplicationsStub stub) { protected ApplicationsClient(ApplicationsSettings settings) throws IOException { this.settings = settings; this.stub = ((ApplicationsStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected ApplicationsClient(ApplicationsStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ApplicationsSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ApplicationsStub getStub() { return stub; } @@ -154,10 +170,19 @@ public ApplicationsStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets information about an application. diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ApplicationsSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ApplicationsSettings.java index b0691a46591c..e47a5f719fa5 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ApplicationsSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ApplicationsSettings.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; @@ -132,11 +133,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ApplicationsStubSettings.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 ApplicationsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ApplicationsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ApplicationsStubSettings.defaultTransportChannelProvider(); } @@ -146,11 +154,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ApplicationsStubSettings.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); @@ -188,6 +202,11 @@ private static Builder createDefault() { return new Builder(ApplicationsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ApplicationsStubSettings.newHttpJsonBuilder()); + } + public ApplicationsStubSettings.Builder getStubSettingsBuilder() { return ((ApplicationsStubSettings.Builder) getStubSettings()); } diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedCertificatesClient.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedCertificatesClient.java index 7f3ee6f43cab..2f032fe7d9fe 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedCertificatesClient.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedCertificatesClient.java @@ -18,7 +18,6 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -108,6 +107,21 @@ * AuthorizedCertificatesClient.create(authorizedCertificatesSettings); * } * + *

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.
+ * AuthorizedCertificatesSettings authorizedCertificatesSettings =
+ *     AuthorizedCertificatesSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             AuthorizedCertificatesSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * AuthorizedCertificatesClient authorizedCertificatesClient =
+ *     AuthorizedCertificatesClient.create(authorizedCertificatesSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") @@ -133,7 +147,6 @@ public static final AuthorizedCertificatesClient create(AuthorizedCertificatesSe * Constructs an instance of AuthorizedCertificatesClient, using the given stub for making calls. * This is for advanced usage - prefer using create(AuthorizedCertificatesSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final AuthorizedCertificatesClient create(AuthorizedCertificatesStub stub) { return new AuthorizedCertificatesClient(stub); } @@ -149,7 +162,6 @@ protected AuthorizedCertificatesClient(AuthorizedCertificatesSettings settings) this.stub = ((AuthorizedCertificatesStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected AuthorizedCertificatesClient(AuthorizedCertificatesStub stub) { this.settings = null; this.stub = stub; @@ -159,7 +171,6 @@ public final AuthorizedCertificatesSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public AuthorizedCertificatesStub getStub() { return stub; } @@ -253,7 +264,7 @@ public final ListAuthorizedCertificatesPagedResponse listAuthorizedCertificates( * while (true) { * ListAuthorizedCertificatesResponse response = * authorizedCertificatesClient.listAuthorizedCertificatesCallable().call(request); - * for (AuthorizedCertificate element : response.getResponsesList()) { + * for (AuthorizedCertificate element : response.getCertificatesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedCertificatesSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedCertificatesSettings.java index bd859c29b073..42213f60991f 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedCertificatesSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedCertificatesSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -136,11 +137,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return AuthorizedCertificatesStubSettings.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 AuthorizedCertificatesStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return AuthorizedCertificatesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return AuthorizedCertificatesStubSettings.defaultTransportChannelProvider(); } @@ -150,11 +158,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return AuthorizedCertificatesStubSettings.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); @@ -193,6 +207,11 @@ private static Builder createDefault() { return new Builder(AuthorizedCertificatesStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(AuthorizedCertificatesStubSettings.newHttpJsonBuilder()); + } + public AuthorizedCertificatesStubSettings.Builder getStubSettingsBuilder() { return ((AuthorizedCertificatesStubSettings.Builder) getStubSettings()); } diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedDomainsClient.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedDomainsClient.java index 431aa52f1531..dea2e3282a6a 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedDomainsClient.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedDomainsClient.java @@ -18,7 +18,6 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -110,6 +109,21 @@ * AuthorizedDomainsClient.create(authorizedDomainsSettings); * } * + *

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.
+ * AuthorizedDomainsSettings authorizedDomainsSettings =
+ *     AuthorizedDomainsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             AuthorizedDomainsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * AuthorizedDomainsClient authorizedDomainsClient =
+ *     AuthorizedDomainsClient.create(authorizedDomainsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") @@ -135,7 +149,6 @@ public static final AuthorizedDomainsClient create(AuthorizedDomainsSettings set * Constructs an instance of AuthorizedDomainsClient, using the given stub for making calls. This * is for advanced usage - prefer using create(AuthorizedDomainsSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final AuthorizedDomainsClient create(AuthorizedDomainsStub stub) { return new AuthorizedDomainsClient(stub); } @@ -150,7 +163,6 @@ protected AuthorizedDomainsClient(AuthorizedDomainsSettings settings) throws IOE this.stub = ((AuthorizedDomainsStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected AuthorizedDomainsClient(AuthorizedDomainsStub stub) { this.settings = null; this.stub = stub; @@ -160,7 +172,6 @@ public final AuthorizedDomainsSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public AuthorizedDomainsStub getStub() { return stub; } @@ -245,7 +256,7 @@ public final ListAuthorizedDomainsPagedResponse listAuthorizedDomains( * while (true) { * ListAuthorizedDomainsResponse response = * authorizedDomainsClient.listAuthorizedDomainsCallable().call(request); - * for (AuthorizedDomain element : response.getResponsesList()) { + * for (AuthorizedDomain element : response.getDomainsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedDomainsSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedDomainsSettings.java index 35cd464d86df..762544736cf1 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedDomainsSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/AuthorizedDomainsSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -105,11 +106,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return AuthorizedDomainsStubSettings.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 AuthorizedDomainsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return AuthorizedDomainsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return AuthorizedDomainsStubSettings.defaultTransportChannelProvider(); } @@ -119,11 +127,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return AuthorizedDomainsStubSettings.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); @@ -161,6 +175,11 @@ private static Builder createDefault() { return new Builder(AuthorizedDomainsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(AuthorizedDomainsStubSettings.newHttpJsonBuilder()); + } + public AuthorizedDomainsStubSettings.Builder getStubSettingsBuilder() { return ((AuthorizedDomainsStubSettings.Builder) getStubSettings()); } diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/DomainMappingsClient.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/DomainMappingsClient.java index 4e081faaa81d..3ed91d0eeac5 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/DomainMappingsClient.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/DomainMappingsClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.appengine.v1.stub.DomainMappingsStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; @@ -103,13 +103,28 @@ * DomainMappingsClient domainMappingsClient = DomainMappingsClient.create(domainMappingsSettings); * } * + *

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.
+ * DomainMappingsSettings domainMappingsSettings =
+ *     DomainMappingsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             DomainMappingsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * DomainMappingsClient domainMappingsClient = DomainMappingsClient.create(domainMappingsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class DomainMappingsClient implements BackgroundResource { private final DomainMappingsSettings settings; private final DomainMappingsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of DomainMappingsClient with default settings. */ public static final DomainMappingsClient create() throws IOException { @@ -129,7 +144,6 @@ public static final DomainMappingsClient create(DomainMappingsSettings settings) * Constructs an instance of DomainMappingsClient, using the given stub for making calls. This is * for advanced usage - prefer using create(DomainMappingsSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final DomainMappingsClient create(DomainMappingsStub stub) { return new DomainMappingsClient(stub); } @@ -142,21 +156,23 @@ public static final DomainMappingsClient create(DomainMappingsStub stub) { protected DomainMappingsClient(DomainMappingsSettings settings) throws IOException { this.settings = settings; this.stub = ((DomainMappingsStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected DomainMappingsClient(DomainMappingsStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final DomainMappingsSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public DomainMappingsStub getStub() { return stub; } @@ -165,10 +181,19 @@ public DomainMappingsStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the domain mappings on an application. @@ -248,7 +273,7 @@ public final ListDomainMappingsPagedResponse listDomainMappings( * while (true) { * ListDomainMappingsResponse response = * domainMappingsClient.listDomainMappingsCallable().call(request); - * for (DomainMapping element : response.getResponsesList()) { + * for (DomainMapping element : response.getDomainMappingsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/DomainMappingsSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/DomainMappingsSettings.java index cd13c6231e4d..b8e6265c2e9b 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/DomainMappingsSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/DomainMappingsSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -144,11 +145,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return DomainMappingsStubSettings.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 DomainMappingsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return DomainMappingsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return DomainMappingsStubSettings.defaultTransportChannelProvider(); } @@ -158,11 +166,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return DomainMappingsStubSettings.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); @@ -200,6 +214,11 @@ private static Builder createDefault() { return new Builder(DomainMappingsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(DomainMappingsStubSettings.newHttpJsonBuilder()); + } + public DomainMappingsStubSettings.Builder getStubSettingsBuilder() { return ((DomainMappingsStubSettings.Builder) getStubSettings()); } diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/FirewallClient.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/FirewallClient.java index d73c5a8b583a..05317b9cdf8a 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/FirewallClient.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/FirewallClient.java @@ -18,7 +18,6 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -111,6 +110,20 @@ * FirewallClient firewallClient = FirewallClient.create(firewallSettings); * } * + *

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.
+ * FirewallSettings firewallSettings =
+ *     FirewallSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             FirewallSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * FirewallClient firewallClient = FirewallClient.create(firewallSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") @@ -135,7 +148,6 @@ public static final FirewallClient create(FirewallSettings settings) throws IOEx * Constructs an instance of FirewallClient, using the given stub for making calls. This is for * advanced usage - prefer using create(FirewallSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final FirewallClient create(FirewallStub stub) { return new FirewallClient(stub); } @@ -149,7 +161,6 @@ protected FirewallClient(FirewallSettings settings) throws IOException { this.stub = ((FirewallStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected FirewallClient(FirewallStub stub) { this.settings = null; this.stub = stub; @@ -159,7 +170,6 @@ public final FirewallSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public FirewallStub getStub() { return stub; } @@ -244,7 +254,7 @@ public final ListIngressRulesPagedResponse listIngressRules(ListIngressRulesRequ * .build(); * while (true) { * ListIngressRulesResponse response = firewallClient.listIngressRulesCallable().call(request); - * for (FirewallRule element : response.getResponsesList()) { + * for (FirewallRule element : response.getIngressRulesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/FirewallSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/FirewallSettings.java index 0898e161d7cc..cf6191be100c 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/FirewallSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/FirewallSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -129,11 +130,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return FirewallStubSettings.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 FirewallStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return FirewallStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return FirewallStubSettings.defaultTransportChannelProvider(); } @@ -143,11 +151,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return FirewallStubSettings.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); @@ -185,6 +199,11 @@ private static Builder createDefault() { return new Builder(FirewallStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(FirewallStubSettings.newHttpJsonBuilder()); + } + public FirewallStubSettings.Builder getStubSettingsBuilder() { return ((FirewallStubSettings.Builder) getStubSettings()); } diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/InstancesClient.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/InstancesClient.java index 322ddddcead2..53c0aa810dfa 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/InstancesClient.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/InstancesClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.appengine.v1.stub.InstancesStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; @@ -102,13 +102,28 @@ * InstancesClient instancesClient = InstancesClient.create(instancesSettings); * } * + *

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.
+ * InstancesSettings instancesSettings =
+ *     InstancesSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             InstancesSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * InstancesClient instancesClient = InstancesClient.create(instancesSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class InstancesClient implements BackgroundResource { private final InstancesSettings settings; private final InstancesStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of InstancesClient with default settings. */ public static final InstancesClient create() throws IOException { @@ -127,7 +142,6 @@ public static final InstancesClient create(InstancesSettings settings) throws IO * Constructs an instance of InstancesClient, using the given stub for making calls. This is for * advanced usage - prefer using create(InstancesSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final InstancesClient create(InstancesStub stub) { return new InstancesClient(stub); } @@ -139,21 +153,23 @@ public static final InstancesClient create(InstancesStub stub) { protected InstancesClient(InstancesSettings settings) throws IOException { this.settings = settings; this.stub = ((InstancesStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected InstancesClient(InstancesStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final InstancesSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public InstancesStub getStub() { return stub; } @@ -162,10 +178,19 @@ public InstancesStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the instances of a version. @@ -251,7 +276,7 @@ public final ListInstancesPagedResponse listInstances(ListInstancesRequest reque * .build(); * while (true) { * ListInstancesResponse response = instancesClient.listInstancesCallable().call(request); - * for (Instance element : response.getResponsesList()) { + * for (Instance element : response.getInstancesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/InstancesSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/InstancesSettings.java index 192c896b3c4d..4c0c3f03561d 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/InstancesSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/InstancesSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -130,11 +131,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return InstancesStubSettings.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 InstancesStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstancesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return InstancesStubSettings.defaultTransportChannelProvider(); } @@ -144,11 +152,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return InstancesStubSettings.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); @@ -186,6 +200,11 @@ private static Builder createDefault() { return new Builder(InstancesStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(InstancesStubSettings.newHttpJsonBuilder()); + } + public InstancesStubSettings.Builder getStubSettingsBuilder() { return ((InstancesStubSettings.Builder) getStubSettings()); } diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ServicesClient.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ServicesClient.java index 5b45701072c3..ccbf0f8b7752 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ServicesClient.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ServicesClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.appengine.v1.stub.ServicesStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; @@ -102,13 +102,28 @@ * ServicesClient servicesClient = ServicesClient.create(servicesSettings); * } * + *

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.
+ * ServicesSettings servicesSettings =
+ *     ServicesSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ServicesSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ServicesClient servicesClient = ServicesClient.create(servicesSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class ServicesClient implements BackgroundResource { private final ServicesSettings settings; private final ServicesStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ServicesClient with default settings. */ public static final ServicesClient create() throws IOException { @@ -127,7 +142,6 @@ public static final ServicesClient create(ServicesSettings settings) throws IOEx * Constructs an instance of ServicesClient, using the given stub for making calls. This is for * advanced usage - prefer using create(ServicesSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ServicesClient create(ServicesStub stub) { return new ServicesClient(stub); } @@ -139,21 +153,23 @@ public static final ServicesClient create(ServicesStub stub) { protected ServicesClient(ServicesSettings settings) throws IOException { this.settings = settings; this.stub = ((ServicesStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected ServicesClient(ServicesStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ServicesSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ServicesStub getStub() { return stub; } @@ -162,10 +178,19 @@ public ServicesStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all the services in the application. @@ -242,7 +267,7 @@ public final ListServicesPagedResponse listServices(ListServicesRequest request) * .build(); * while (true) { * ListServicesResponse response = servicesClient.listServicesCallable().call(request); - * for (Service element : response.getResponsesList()) { + * for (Service element : response.getServicesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ServicesSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ServicesSettings.java index 8a795c729c53..f6223acf95ca 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ServicesSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/ServicesSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -130,11 +131,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ServicesStubSettings.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 ServicesStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ServicesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ServicesStubSettings.defaultTransportChannelProvider(); } @@ -144,11 +152,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ServicesStubSettings.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); @@ -186,6 +200,11 @@ private static Builder createDefault() { return new Builder(ServicesStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ServicesStubSettings.newHttpJsonBuilder()); + } + public ServicesStubSettings.Builder getStubSettingsBuilder() { return ((ServicesStubSettings.Builder) getStubSettings()); } diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/VersionsClient.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/VersionsClient.java index f9f6f0481eec..05977fc70a8a 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/VersionsClient.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/VersionsClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.appengine.v1.stub.VersionsStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; @@ -106,13 +106,28 @@ * VersionsClient versionsClient = VersionsClient.create(versionsSettings); * } * + *

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.
+ * VersionsSettings versionsSettings =
+ *     VersionsSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             VersionsSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * VersionsClient versionsClient = VersionsClient.create(versionsSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class VersionsClient implements BackgroundResource { private final VersionsSettings settings; private final VersionsStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of VersionsClient with default settings. */ public static final VersionsClient create() throws IOException { @@ -131,7 +146,6 @@ public static final VersionsClient create(VersionsSettings settings) throws IOEx * Constructs an instance of VersionsClient, using the given stub for making calls. This is for * advanced usage - prefer using create(VersionsSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final VersionsClient create(VersionsStub stub) { return new VersionsClient(stub); } @@ -143,21 +157,23 @@ public static final VersionsClient create(VersionsStub stub) { protected VersionsClient(VersionsSettings settings) throws IOException { this.settings = settings; this.stub = ((VersionsStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected VersionsClient(VersionsStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final VersionsSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public VersionsStub getStub() { return stub; } @@ -166,10 +182,19 @@ public VersionsStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists the versions of a service. @@ -249,7 +274,7 @@ public final ListVersionsPagedResponse listVersions(ListVersionsRequest request) * .build(); * while (true) { * ListVersionsResponse response = versionsClient.listVersionsCallable().call(request); - * for (Version element : response.getResponsesList()) { + * for (Version element : response.getVersionsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/VersionsSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/VersionsSettings.java index 7e06dff7e1f3..3cf4141de9cf 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/VersionsSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/VersionsSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -141,11 +142,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return VersionsStubSettings.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 VersionsStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return VersionsStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return VersionsStubSettings.defaultTransportChannelProvider(); } @@ -155,11 +163,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return VersionsStubSettings.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); @@ -197,6 +211,11 @@ private static Builder createDefault() { return new Builder(VersionsStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(VersionsStubSettings.newHttpJsonBuilder()); + } + public VersionsStubSettings.Builder getStubSettingsBuilder() { return ((VersionsStubSettings.Builder) getStubSettings()); } diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ApplicationsStub.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ApplicationsStub.java index 714a4ed6ca4b..9164550076cf 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ApplicationsStub.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ApplicationsStub.java @@ -39,7 +39,11 @@ public abstract class ApplicationsStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable getApplicationCallable() { diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ApplicationsStubSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ApplicationsStubSettings.java index 09a787f25070..854cd87fd0d5 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ApplicationsStubSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ApplicationsStubSettings.java @@ -25,6 +25,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -144,13 +147,17 @@ public UnaryCallSettings repairApplicationS return repairApplicationOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ApplicationsStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcApplicationsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonApplicationsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -183,18 +190,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(ApplicationsStubSettings.class)) @@ -202,11 +216,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(ApplicationsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ApplicationsStubSettings.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); @@ -335,6 +368,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 .getApplicationSettings() diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/AuthorizedCertificatesStubSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/AuthorizedCertificatesStubSettings.java index 59190f6520b9..ff1a841b71ec 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/AuthorizedCertificatesStubSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/AuthorizedCertificatesStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -227,13 +230,17 @@ public ApiFuture getFuturePagedResponse return deleteAuthorizedCertificateSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public AuthorizedCertificatesStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcAuthorizedCertificatesStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonAuthorizedCertificatesStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -266,18 +273,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(AuthorizedCertificatesStubSettings.class)) @@ -285,11 +299,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(AuthorizedCertificatesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return AuthorizedCertificatesStubSettings.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); @@ -418,6 +451,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 .listAuthorizedCertificatesSettings() diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/AuthorizedDomainsStubSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/AuthorizedDomainsStubSettings.java index 24f0a5b978b2..31db72663957 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/AuthorizedDomainsStubSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/AuthorizedDomainsStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -177,13 +180,17 @@ public ApiFuture getFuturePagedResponse( return listAuthorizedDomainsSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public AuthorizedDomainsStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcAuthorizedDomainsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonAuthorizedDomainsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -216,18 +223,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(AuthorizedDomainsStubSettings.class)) @@ -235,11 +249,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(AuthorizedDomainsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return AuthorizedDomainsStubSettings.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); @@ -328,6 +361,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 .listAuthorizedDomainsSettings() diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/DomainMappingsStub.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/DomainMappingsStub.java index a69ff29ec123..5be7f2f74849 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/DomainMappingsStub.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/DomainMappingsStub.java @@ -44,7 +44,11 @@ public abstract class DomainMappingsStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/DomainMappingsStubSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/DomainMappingsStubSettings.java index d927ef3742de..b069005137ba 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/DomainMappingsStubSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/DomainMappingsStubSettings.java @@ -28,6 +28,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -232,13 +235,17 @@ public UnaryCallSettings deleteDomainMapp return deleteDomainMappingOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public DomainMappingsStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcDomainMappingsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonDomainMappingsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -271,18 +278,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(DomainMappingsStubSettings.class)) @@ -290,11 +304,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(DomainMappingsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DomainMappingsStubSettings.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); @@ -434,6 +467,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 .listDomainMappingsSettings() diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/FirewallStubSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/FirewallStubSettings.java index 6dfdc8e267bf..90e5ee7cc9aa 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/FirewallStubSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/FirewallStubSettings.java @@ -27,6 +27,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -204,13 +207,17 @@ public UnaryCallSettings deleteIngressRuleSetti return deleteIngressRuleSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public FirewallStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcFirewallStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonFirewallStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -243,29 +250,54 @@ 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(FirewallStubSettings.class)) .setTransportToken( 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(FirewallStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return FirewallStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -389,6 +421,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 .listIngressRulesSettings() diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonApplicationsCallableFactory.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonApplicationsCallableFactory.java new file mode 100644 index 000000000000..5679e8bb93bd --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonApplicationsCallableFactory.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.appengine.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 Applications service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonApplicationsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonApplicationsStub.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonApplicationsStub.java new file mode 100644 index 000000000000..0a58e58777f3 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonApplicationsStub.java @@ -0,0 +1,420 @@ +/* + * 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.appengine.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.appengine.v1.Application; +import com.google.appengine.v1.CreateApplicationRequest; +import com.google.appengine.v1.GetApplicationRequest; +import com.google.appengine.v1.OperationMetadataV1; +import com.google.appengine.v1.RepairApplicationRequest; +import com.google.appengine.v1.UpdateApplicationRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Applications service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonApplicationsStub extends ApplicationsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Application.getDescriptor()) + .add(OperationMetadataV1.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + getApplicationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Applications/GetApplication") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Application.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createApplicationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Applications/CreateApplication") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/apps", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("application", request.getApplication())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateApplicationRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateApplicationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Applications/UpdateApplication") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("application", request.getApplication())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateApplicationRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + repairApplicationMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Applications/RepairApplication") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*}:repair", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RepairApplicationRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable getApplicationCallable; + private final UnaryCallable createApplicationCallable; + private final OperationCallable + createApplicationOperationCallable; + private final UnaryCallable updateApplicationCallable; + private final OperationCallable + updateApplicationOperationCallable; + private final UnaryCallable repairApplicationCallable; + private final OperationCallable + repairApplicationOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonApplicationsStub create(ApplicationsStubSettings settings) + throws IOException { + return new HttpJsonApplicationsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonApplicationsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonApplicationsStub( + ApplicationsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonApplicationsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonApplicationsStub( + ApplicationsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonApplicationsStub, 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 HttpJsonApplicationsStub(ApplicationsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonApplicationsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonApplicationsStub, 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 HttpJsonApplicationsStub( + ApplicationsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings getApplicationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getApplicationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createApplicationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createApplicationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateApplicationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateApplicationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings repairApplicationTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(repairApplicationMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.getApplicationCallable = + callableFactory.createUnaryCallable( + getApplicationTransportSettings, settings.getApplicationSettings(), clientContext); + this.createApplicationCallable = + callableFactory.createUnaryCallable( + createApplicationTransportSettings, + settings.createApplicationSettings(), + clientContext); + this.createApplicationOperationCallable = + callableFactory.createOperationCallable( + createApplicationTransportSettings, + settings.createApplicationOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateApplicationCallable = + callableFactory.createUnaryCallable( + updateApplicationTransportSettings, + settings.updateApplicationSettings(), + clientContext); + this.updateApplicationOperationCallable = + callableFactory.createOperationCallable( + updateApplicationTransportSettings, + settings.updateApplicationOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.repairApplicationCallable = + callableFactory.createUnaryCallable( + repairApplicationTransportSettings, + settings.repairApplicationSettings(), + clientContext); + this.repairApplicationOperationCallable = + callableFactory.createOperationCallable( + repairApplicationTransportSettings, + settings.repairApplicationOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(getApplicationMethodDescriptor); + methodDescriptors.add(createApplicationMethodDescriptor); + methodDescriptors.add(updateApplicationMethodDescriptor); + methodDescriptors.add(repairApplicationMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable getApplicationCallable() { + return getApplicationCallable; + } + + @Override + public UnaryCallable createApplicationCallable() { + return createApplicationCallable; + } + + @Override + public OperationCallable + createApplicationOperationCallable() { + return createApplicationOperationCallable; + } + + @Override + public UnaryCallable updateApplicationCallable() { + return updateApplicationCallable; + } + + @Override + public OperationCallable + updateApplicationOperationCallable() { + return updateApplicationOperationCallable; + } + + @Override + public UnaryCallable repairApplicationCallable() { + return repairApplicationCallable; + } + + @Override + public OperationCallable + repairApplicationOperationCallable() { + return repairApplicationOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonAuthorizedCertificatesCallableFactory.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonAuthorizedCertificatesCallableFactory.java new file mode 100644 index 000000000000..091a93665afc --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonAuthorizedCertificatesCallableFactory.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.appengine.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 AuthorizedCertificates service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonAuthorizedCertificatesCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonAuthorizedCertificatesStub.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonAuthorizedCertificatesStub.java new file mode 100644 index 000000000000..f2f3b863dfd7 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonAuthorizedCertificatesStub.java @@ -0,0 +1,458 @@ +/* + * 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.appengine.v1.stub; + +import static com.google.appengine.v1.AuthorizedCertificatesClient.ListAuthorizedCertificatesPagedResponse; + +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.appengine.v1.AuthorizedCertificate; +import com.google.appengine.v1.CreateAuthorizedCertificateRequest; +import com.google.appengine.v1.DeleteAuthorizedCertificateRequest; +import com.google.appengine.v1.GetAuthorizedCertificateRequest; +import com.google.appengine.v1.ListAuthorizedCertificatesRequest; +import com.google.appengine.v1.ListAuthorizedCertificatesResponse; +import com.google.appengine.v1.UpdateAuthorizedCertificateRequest; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the AuthorizedCertificates service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonAuthorizedCertificatesStub extends AuthorizedCertificatesStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor< + ListAuthorizedCertificatesRequest, ListAuthorizedCertificatesResponse> + listAuthorizedCertificatesMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.appengine.v1.AuthorizedCertificates/ListAuthorizedCertificates") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=apps/*}/authorizedCertificates", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListAuthorizedCertificatesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getAuthorizedCertificateMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.appengine.v1.AuthorizedCertificates/GetAuthorizedCertificate") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/authorizedCertificates/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AuthorizedCertificate.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + CreateAuthorizedCertificateRequest, AuthorizedCertificate> + createAuthorizedCertificateMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.appengine.v1.AuthorizedCertificates/CreateAuthorizedCertificate") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=apps/*}/authorizedCertificates", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("certificate", request.getCertificate())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AuthorizedCertificate.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + UpdateAuthorizedCertificateRequest, AuthorizedCertificate> + updateAuthorizedCertificateMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.appengine.v1.AuthorizedCertificates/UpdateAuthorizedCertificate") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/authorizedCertificates/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("certificate", request.getCertificate())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AuthorizedCertificate.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteAuthorizedCertificateMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.appengine.v1.AuthorizedCertificates/DeleteAuthorizedCertificate") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/authorizedCertificates/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + listAuthorizedCertificatesCallable; + private final UnaryCallable< + ListAuthorizedCertificatesRequest, ListAuthorizedCertificatesPagedResponse> + listAuthorizedCertificatesPagedCallable; + private final UnaryCallable + getAuthorizedCertificateCallable; + private final UnaryCallable + createAuthorizedCertificateCallable; + private final UnaryCallable + updateAuthorizedCertificateCallable; + private final UnaryCallable + deleteAuthorizedCertificateCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonAuthorizedCertificatesStub create( + AuthorizedCertificatesStubSettings settings) throws IOException { + return new HttpJsonAuthorizedCertificatesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonAuthorizedCertificatesStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonAuthorizedCertificatesStub( + AuthorizedCertificatesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonAuthorizedCertificatesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonAuthorizedCertificatesStub( + AuthorizedCertificatesStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonAuthorizedCertificatesStub, 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 HttpJsonAuthorizedCertificatesStub( + AuthorizedCertificatesStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonAuthorizedCertificatesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonAuthorizedCertificatesStub, 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 HttpJsonAuthorizedCertificatesStub( + AuthorizedCertificatesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + listAuthorizedCertificatesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listAuthorizedCertificatesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getAuthorizedCertificateTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(getAuthorizedCertificateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createAuthorizedCertificateTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(createAuthorizedCertificateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateAuthorizedCertificateTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(updateAuthorizedCertificateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteAuthorizedCertificateTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteAuthorizedCertificateMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listAuthorizedCertificatesCallable = + callableFactory.createUnaryCallable( + listAuthorizedCertificatesTransportSettings, + settings.listAuthorizedCertificatesSettings(), + clientContext); + this.listAuthorizedCertificatesPagedCallable = + callableFactory.createPagedCallable( + listAuthorizedCertificatesTransportSettings, + settings.listAuthorizedCertificatesSettings(), + clientContext); + this.getAuthorizedCertificateCallable = + callableFactory.createUnaryCallable( + getAuthorizedCertificateTransportSettings, + settings.getAuthorizedCertificateSettings(), + clientContext); + this.createAuthorizedCertificateCallable = + callableFactory.createUnaryCallable( + createAuthorizedCertificateTransportSettings, + settings.createAuthorizedCertificateSettings(), + clientContext); + this.updateAuthorizedCertificateCallable = + callableFactory.createUnaryCallable( + updateAuthorizedCertificateTransportSettings, + settings.updateAuthorizedCertificateSettings(), + clientContext); + this.deleteAuthorizedCertificateCallable = + callableFactory.createUnaryCallable( + deleteAuthorizedCertificateTransportSettings, + settings.deleteAuthorizedCertificateSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listAuthorizedCertificatesMethodDescriptor); + methodDescriptors.add(getAuthorizedCertificateMethodDescriptor); + methodDescriptors.add(createAuthorizedCertificateMethodDescriptor); + methodDescriptors.add(updateAuthorizedCertificateMethodDescriptor); + methodDescriptors.add(deleteAuthorizedCertificateMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + listAuthorizedCertificatesCallable() { + return listAuthorizedCertificatesCallable; + } + + @Override + public UnaryCallable + listAuthorizedCertificatesPagedCallable() { + return listAuthorizedCertificatesPagedCallable; + } + + @Override + public UnaryCallable + getAuthorizedCertificateCallable() { + return getAuthorizedCertificateCallable; + } + + @Override + public UnaryCallable + createAuthorizedCertificateCallable() { + return createAuthorizedCertificateCallable; + } + + @Override + public UnaryCallable + updateAuthorizedCertificateCallable() { + return updateAuthorizedCertificateCallable; + } + + @Override + public UnaryCallable + deleteAuthorizedCertificateCallable() { + return deleteAuthorizedCertificateCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonAuthorizedDomainsCallableFactory.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonAuthorizedDomainsCallableFactory.java new file mode 100644 index 000000000000..bef6379cfab3 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonAuthorizedDomainsCallableFactory.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.appengine.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 AuthorizedDomains service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonAuthorizedDomainsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonAuthorizedDomainsStub.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonAuthorizedDomainsStub.java new file mode 100644 index 000000000000..b9f6a5ca30d7 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonAuthorizedDomainsStub.java @@ -0,0 +1,216 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.appengine.v1.stub; + +import static com.google.appengine.v1.AuthorizedDomainsClient.ListAuthorizedDomainsPagedResponse; + +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.appengine.v1.ListAuthorizedDomainsRequest; +import com.google.appengine.v1.ListAuthorizedDomainsResponse; +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 AuthorizedDomains service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonAuthorizedDomainsStub extends AuthorizedDomainsStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor< + ListAuthorizedDomainsRequest, ListAuthorizedDomainsResponse> + listAuthorizedDomainsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.appengine.v1.AuthorizedDomains/ListAuthorizedDomains") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=apps/*}/authorizedDomains", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListAuthorizedDomainsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + listAuthorizedDomainsCallable; + private final UnaryCallable + listAuthorizedDomainsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonAuthorizedDomainsStub create(AuthorizedDomainsStubSettings settings) + throws IOException { + return new HttpJsonAuthorizedDomainsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonAuthorizedDomainsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonAuthorizedDomainsStub( + AuthorizedDomainsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonAuthorizedDomainsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonAuthorizedDomainsStub( + AuthorizedDomainsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonAuthorizedDomainsStub, 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 HttpJsonAuthorizedDomainsStub( + AuthorizedDomainsStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonAuthorizedDomainsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonAuthorizedDomainsStub, 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 HttpJsonAuthorizedDomainsStub( + AuthorizedDomainsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + listAuthorizedDomainsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listAuthorizedDomainsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listAuthorizedDomainsCallable = + callableFactory.createUnaryCallable( + listAuthorizedDomainsTransportSettings, + settings.listAuthorizedDomainsSettings(), + clientContext); + this.listAuthorizedDomainsPagedCallable = + callableFactory.createPagedCallable( + listAuthorizedDomainsTransportSettings, + settings.listAuthorizedDomainsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listAuthorizedDomainsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + listAuthorizedDomainsCallable() { + return listAuthorizedDomainsCallable; + } + + @Override + public UnaryCallable + listAuthorizedDomainsPagedCallable() { + return listAuthorizedDomainsPagedCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonDomainMappingsCallableFactory.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonDomainMappingsCallableFactory.java new file mode 100644 index 000000000000..57d7c96182dd --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonDomainMappingsCallableFactory.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.appengine.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 DomainMappings service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonDomainMappingsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonDomainMappingsStub.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonDomainMappingsStub.java new file mode 100644 index 000000000000..11ca17304b49 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonDomainMappingsStub.java @@ -0,0 +1,497 @@ +/* + * 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.appengine.v1.stub; + +import static com.google.appengine.v1.DomainMappingsClient.ListDomainMappingsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.appengine.v1.CreateDomainMappingRequest; +import com.google.appengine.v1.DeleteDomainMappingRequest; +import com.google.appengine.v1.DomainMapping; +import com.google.appengine.v1.GetDomainMappingRequest; +import com.google.appengine.v1.ListDomainMappingsRequest; +import com.google.appengine.v1.ListDomainMappingsResponse; +import com.google.appengine.v1.OperationMetadataV1; +import com.google.appengine.v1.UpdateDomainMappingRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the DomainMappings service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonDomainMappingsStub extends DomainMappingsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(DomainMapping.getDescriptor()) + .add(OperationMetadataV1.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listDomainMappingsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.DomainMappings/ListDomainMappings") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=apps/*}/domainMappings", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListDomainMappingsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getDomainMappingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.DomainMappings/GetDomainMapping") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/domainMappings/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(DomainMapping.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createDomainMappingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.DomainMappings/CreateDomainMapping") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=apps/*}/domainMappings", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "overrideStrategy", request.getOverrideStrategy()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("domainMapping", request.getDomainMapping())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateDomainMappingRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateDomainMappingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.DomainMappings/UpdateDomainMapping") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/domainMappings/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("domainMapping", request.getDomainMapping())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateDomainMappingRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteDomainMappingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.DomainMappings/DeleteDomainMapping") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/domainMappings/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteDomainMappingRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable + listDomainMappingsCallable; + private final UnaryCallable + listDomainMappingsPagedCallable; + private final UnaryCallable getDomainMappingCallable; + private final UnaryCallable createDomainMappingCallable; + private final OperationCallable + createDomainMappingOperationCallable; + private final UnaryCallable updateDomainMappingCallable; + private final OperationCallable + updateDomainMappingOperationCallable; + private final UnaryCallable deleteDomainMappingCallable; + private final OperationCallable + deleteDomainMappingOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonDomainMappingsStub create(DomainMappingsStubSettings settings) + throws IOException { + return new HttpJsonDomainMappingsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonDomainMappingsStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonDomainMappingsStub( + DomainMappingsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonDomainMappingsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonDomainMappingsStub( + DomainMappingsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonDomainMappingsStub, 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 HttpJsonDomainMappingsStub( + DomainMappingsStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonDomainMappingsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonDomainMappingsStub, 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 HttpJsonDomainMappingsStub( + DomainMappingsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listDomainMappingsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listDomainMappingsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getDomainMappingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDomainMappingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createDomainMappingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createDomainMappingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateDomainMappingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateDomainMappingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteDomainMappingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteDomainMappingMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listDomainMappingsCallable = + callableFactory.createUnaryCallable( + listDomainMappingsTransportSettings, + settings.listDomainMappingsSettings(), + clientContext); + this.listDomainMappingsPagedCallable = + callableFactory.createPagedCallable( + listDomainMappingsTransportSettings, + settings.listDomainMappingsSettings(), + clientContext); + this.getDomainMappingCallable = + callableFactory.createUnaryCallable( + getDomainMappingTransportSettings, settings.getDomainMappingSettings(), clientContext); + this.createDomainMappingCallable = + callableFactory.createUnaryCallable( + createDomainMappingTransportSettings, + settings.createDomainMappingSettings(), + clientContext); + this.createDomainMappingOperationCallable = + callableFactory.createOperationCallable( + createDomainMappingTransportSettings, + settings.createDomainMappingOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateDomainMappingCallable = + callableFactory.createUnaryCallable( + updateDomainMappingTransportSettings, + settings.updateDomainMappingSettings(), + clientContext); + this.updateDomainMappingOperationCallable = + callableFactory.createOperationCallable( + updateDomainMappingTransportSettings, + settings.updateDomainMappingOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteDomainMappingCallable = + callableFactory.createUnaryCallable( + deleteDomainMappingTransportSettings, + settings.deleteDomainMappingSettings(), + clientContext); + this.deleteDomainMappingOperationCallable = + callableFactory.createOperationCallable( + deleteDomainMappingTransportSettings, + settings.deleteDomainMappingOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listDomainMappingsMethodDescriptor); + methodDescriptors.add(getDomainMappingMethodDescriptor); + methodDescriptors.add(createDomainMappingMethodDescriptor); + methodDescriptors.add(updateDomainMappingMethodDescriptor); + methodDescriptors.add(deleteDomainMappingMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + listDomainMappingsCallable() { + return listDomainMappingsCallable; + } + + @Override + public UnaryCallable + listDomainMappingsPagedCallable() { + return listDomainMappingsPagedCallable; + } + + @Override + public UnaryCallable getDomainMappingCallable() { + return getDomainMappingCallable; + } + + @Override + public UnaryCallable createDomainMappingCallable() { + return createDomainMappingCallable; + } + + @Override + public OperationCallable + createDomainMappingOperationCallable() { + return createDomainMappingOperationCallable; + } + + @Override + public UnaryCallable updateDomainMappingCallable() { + return updateDomainMappingCallable; + } + + @Override + public OperationCallable + updateDomainMappingOperationCallable() { + return updateDomainMappingOperationCallable; + } + + @Override + public UnaryCallable deleteDomainMappingCallable() { + return deleteDomainMappingCallable; + } + + @Override + public OperationCallable + deleteDomainMappingOperationCallable() { + return deleteDomainMappingOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonFirewallCallableFactory.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonFirewallCallableFactory.java new file mode 100644 index 000000000000..b40e2d63b320 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonFirewallCallableFactory.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.appengine.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 Firewall service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonFirewallCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonFirewallStub.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonFirewallStub.java new file mode 100644 index 000000000000..edbf82d303be --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonFirewallStub.java @@ -0,0 +1,480 @@ +/* + * 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.appengine.v1.stub; + +import static com.google.appengine.v1.FirewallClient.ListIngressRulesPagedResponse; + +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.appengine.v1.BatchUpdateIngressRulesRequest; +import com.google.appengine.v1.BatchUpdateIngressRulesResponse; +import com.google.appengine.v1.CreateIngressRuleRequest; +import com.google.appengine.v1.DeleteIngressRuleRequest; +import com.google.appengine.v1.GetIngressRuleRequest; +import com.google.appengine.v1.ListIngressRulesRequest; +import com.google.appengine.v1.ListIngressRulesResponse; +import com.google.appengine.v1.UpdateIngressRuleRequest; +import com.google.appengine.v1.firewall.FirewallRule; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Firewall service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonFirewallStub extends FirewallStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listIngressRulesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Firewall/ListIngressRules") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=apps/*}/firewall/ingressRules", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "matchingAddress", request.getMatchingAddress()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListIngressRulesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + BatchUpdateIngressRulesRequest, BatchUpdateIngressRulesResponse> + batchUpdateIngressRulesMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.appengine.v1.Firewall/BatchUpdateIngressRules") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/firewall/ingressRules}:batchUpdate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BatchUpdateIngressRulesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createIngressRuleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Firewall/CreateIngressRule") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=apps/*}/firewall/ingressRules", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> ProtoRestSerializer.create().toBody("rule", request.getRule())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(FirewallRule.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getIngressRuleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Firewall/GetIngressRule") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/firewall/ingressRules/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(FirewallRule.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateIngressRuleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Firewall/UpdateIngressRule") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/firewall/ingressRules/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> ProtoRestSerializer.create().toBody("rule", request.getRule())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(FirewallRule.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteIngressRuleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Firewall/DeleteIngressRule") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/firewall/ingressRules/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + listIngressRulesCallable; + private final UnaryCallable + listIngressRulesPagedCallable; + private final UnaryCallable + batchUpdateIngressRulesCallable; + private final UnaryCallable createIngressRuleCallable; + private final UnaryCallable getIngressRuleCallable; + private final UnaryCallable updateIngressRuleCallable; + private final UnaryCallable deleteIngressRuleCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonFirewallStub create(FirewallStubSettings settings) + throws IOException { + return new HttpJsonFirewallStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonFirewallStub create(ClientContext clientContext) throws IOException { + return new HttpJsonFirewallStub( + FirewallStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonFirewallStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonFirewallStub( + FirewallStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonFirewallStub, 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 HttpJsonFirewallStub(FirewallStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonFirewallCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonFirewallStub, 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 HttpJsonFirewallStub( + FirewallStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + listIngressRulesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listIngressRulesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + batchUpdateIngressRulesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(batchUpdateIngressRulesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createIngressRuleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createIngressRuleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getIngressRuleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIngressRuleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateIngressRuleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateIngressRuleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteIngressRuleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteIngressRuleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listIngressRulesCallable = + callableFactory.createUnaryCallable( + listIngressRulesTransportSettings, settings.listIngressRulesSettings(), clientContext); + this.listIngressRulesPagedCallable = + callableFactory.createPagedCallable( + listIngressRulesTransportSettings, settings.listIngressRulesSettings(), clientContext); + this.batchUpdateIngressRulesCallable = + callableFactory.createUnaryCallable( + batchUpdateIngressRulesTransportSettings, + settings.batchUpdateIngressRulesSettings(), + clientContext); + this.createIngressRuleCallable = + callableFactory.createUnaryCallable( + createIngressRuleTransportSettings, + settings.createIngressRuleSettings(), + clientContext); + this.getIngressRuleCallable = + callableFactory.createUnaryCallable( + getIngressRuleTransportSettings, settings.getIngressRuleSettings(), clientContext); + this.updateIngressRuleCallable = + callableFactory.createUnaryCallable( + updateIngressRuleTransportSettings, + settings.updateIngressRuleSettings(), + clientContext); + this.deleteIngressRuleCallable = + callableFactory.createUnaryCallable( + deleteIngressRuleTransportSettings, + settings.deleteIngressRuleSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listIngressRulesMethodDescriptor); + methodDescriptors.add(batchUpdateIngressRulesMethodDescriptor); + methodDescriptors.add(createIngressRuleMethodDescriptor); + methodDescriptors.add(getIngressRuleMethodDescriptor); + methodDescriptors.add(updateIngressRuleMethodDescriptor); + methodDescriptors.add(deleteIngressRuleMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + listIngressRulesCallable() { + return listIngressRulesCallable; + } + + @Override + public UnaryCallable + listIngressRulesPagedCallable() { + return listIngressRulesPagedCallable; + } + + @Override + public UnaryCallable + batchUpdateIngressRulesCallable() { + return batchUpdateIngressRulesCallable; + } + + @Override + public UnaryCallable createIngressRuleCallable() { + return createIngressRuleCallable; + } + + @Override + public UnaryCallable getIngressRuleCallable() { + return getIngressRuleCallable; + } + + @Override + public UnaryCallable updateIngressRuleCallable() { + return updateIngressRuleCallable; + } + + @Override + public UnaryCallable deleteIngressRuleCallable() { + return deleteIngressRuleCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonInstancesCallableFactory.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonInstancesCallableFactory.java new file mode 100644 index 000000000000..d635fe0a1b4a --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonInstancesCallableFactory.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.appengine.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 Instances service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonInstancesCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonInstancesStub.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonInstancesStub.java new file mode 100644 index 000000000000..19ec34aecfb7 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonInstancesStub.java @@ -0,0 +1,409 @@ +/* + * 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.appengine.v1.stub; + +import static com.google.appengine.v1.InstancesClient.ListInstancesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.appengine.v1.DebugInstanceRequest; +import com.google.appengine.v1.DeleteInstanceRequest; +import com.google.appengine.v1.GetInstanceRequest; +import com.google.appengine.v1.Instance; +import com.google.appengine.v1.ListInstancesRequest; +import com.google.appengine.v1.ListInstancesResponse; +import com.google.appengine.v1.OperationMetadataV1; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Instances service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonInstancesStub extends InstancesStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(OperationMetadataV1.getDescriptor()) + .add(Instance.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listInstancesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Instances/ListInstances") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=apps/*/services/*/versions/*}/instances", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListInstancesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Instances/GetInstance") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/services/*/versions/*/instances/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Instance.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Instances/DeleteInstance") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/services/*/versions/*/instances/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + debugInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Instances/DebugInstance") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/services/*/versions/*/instances/*}:debug", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DebugInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable listInstancesCallable; + private final UnaryCallable + listInstancesPagedCallable; + private final UnaryCallable getInstanceCallable; + private final UnaryCallable deleteInstanceCallable; + private final OperationCallable + deleteInstanceOperationCallable; + private final UnaryCallable debugInstanceCallable; + private final OperationCallable + debugInstanceOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonInstancesStub create(InstancesStubSettings settings) + throws IOException { + return new HttpJsonInstancesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonInstancesStub create(ClientContext clientContext) throws IOException { + return new HttpJsonInstancesStub( + InstancesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonInstancesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonInstancesStub( + InstancesStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonInstancesStub, 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 HttpJsonInstancesStub(InstancesStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonInstancesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonInstancesStub, 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 HttpJsonInstancesStub( + InstancesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listInstancesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listInstancesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings debugInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(debugInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listInstancesCallable = + callableFactory.createUnaryCallable( + listInstancesTransportSettings, settings.listInstancesSettings(), clientContext); + this.listInstancesPagedCallable = + callableFactory.createPagedCallable( + listInstancesTransportSettings, settings.listInstancesSettings(), clientContext); + this.getInstanceCallable = + callableFactory.createUnaryCallable( + getInstanceTransportSettings, settings.getInstanceSettings(), clientContext); + this.deleteInstanceCallable = + callableFactory.createUnaryCallable( + deleteInstanceTransportSettings, settings.deleteInstanceSettings(), clientContext); + this.deleteInstanceOperationCallable = + callableFactory.createOperationCallable( + deleteInstanceTransportSettings, + settings.deleteInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.debugInstanceCallable = + callableFactory.createUnaryCallable( + debugInstanceTransportSettings, settings.debugInstanceSettings(), clientContext); + this.debugInstanceOperationCallable = + callableFactory.createOperationCallable( + debugInstanceTransportSettings, + settings.debugInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listInstancesMethodDescriptor); + methodDescriptors.add(getInstanceMethodDescriptor); + methodDescriptors.add(deleteInstanceMethodDescriptor); + methodDescriptors.add(debugInstanceMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listInstancesCallable() { + return listInstancesCallable; + } + + @Override + public UnaryCallable + listInstancesPagedCallable() { + return listInstancesPagedCallable; + } + + @Override + public UnaryCallable getInstanceCallable() { + return getInstanceCallable; + } + + @Override + public UnaryCallable deleteInstanceCallable() { + return deleteInstanceCallable; + } + + @Override + public OperationCallable + deleteInstanceOperationCallable() { + return deleteInstanceOperationCallable; + } + + @Override + public UnaryCallable debugInstanceCallable() { + return debugInstanceCallable; + } + + @Override + public OperationCallable + debugInstanceOperationCallable() { + return debugInstanceOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonServicesCallableFactory.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonServicesCallableFactory.java new file mode 100644 index 000000000000..d1426063f2a0 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonServicesCallableFactory.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.appengine.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 Services service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonServicesCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonServicesStub.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonServicesStub.java new file mode 100644 index 000000000000..92d91683b41e --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonServicesStub.java @@ -0,0 +1,408 @@ +/* + * 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.appengine.v1.stub; + +import static com.google.appengine.v1.ServicesClient.ListServicesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.appengine.v1.DeleteServiceRequest; +import com.google.appengine.v1.GetServiceRequest; +import com.google.appengine.v1.ListServicesRequest; +import com.google.appengine.v1.ListServicesResponse; +import com.google.appengine.v1.OperationMetadataV1; +import com.google.appengine.v1.Service; +import com.google.appengine.v1.UpdateServiceRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Services service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonServicesStub extends ServicesStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(Service.getDescriptor()) + .add(OperationMetadataV1.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listServicesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Services/ListServices") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=apps/*}/services", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListServicesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getServiceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Services/GetService") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/services/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Service.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateServiceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Services/UpdateService") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/services/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "migrateTraffic", request.getMigrateTraffic()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("service", request.getService())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateServiceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteServiceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Services/DeleteService") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/services/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteServiceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable listServicesCallable; + private final UnaryCallable + listServicesPagedCallable; + private final UnaryCallable getServiceCallable; + private final UnaryCallable updateServiceCallable; + private final OperationCallable + updateServiceOperationCallable; + private final UnaryCallable deleteServiceCallable; + private final OperationCallable + deleteServiceOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonServicesStub create(ServicesStubSettings settings) + throws IOException { + return new HttpJsonServicesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonServicesStub create(ClientContext clientContext) throws IOException { + return new HttpJsonServicesStub( + ServicesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonServicesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonServicesStub( + ServicesStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonServicesStub, 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 HttpJsonServicesStub(ServicesStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonServicesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonServicesStub, 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 HttpJsonServicesStub( + ServicesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings listServicesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listServicesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getServiceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getServiceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateServiceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateServiceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteServiceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteServiceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listServicesCallable = + callableFactory.createUnaryCallable( + listServicesTransportSettings, settings.listServicesSettings(), clientContext); + this.listServicesPagedCallable = + callableFactory.createPagedCallable( + listServicesTransportSettings, settings.listServicesSettings(), clientContext); + this.getServiceCallable = + callableFactory.createUnaryCallable( + getServiceTransportSettings, settings.getServiceSettings(), clientContext); + this.updateServiceCallable = + callableFactory.createUnaryCallable( + updateServiceTransportSettings, settings.updateServiceSettings(), clientContext); + this.updateServiceOperationCallable = + callableFactory.createOperationCallable( + updateServiceTransportSettings, + settings.updateServiceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteServiceCallable = + callableFactory.createUnaryCallable( + deleteServiceTransportSettings, settings.deleteServiceSettings(), clientContext); + this.deleteServiceOperationCallable = + callableFactory.createOperationCallable( + deleteServiceTransportSettings, + settings.deleteServiceOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listServicesMethodDescriptor); + methodDescriptors.add(getServiceMethodDescriptor); + methodDescriptors.add(updateServiceMethodDescriptor); + methodDescriptors.add(deleteServiceMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listServicesCallable() { + return listServicesCallable; + } + + @Override + public UnaryCallable listServicesPagedCallable() { + return listServicesPagedCallable; + } + + @Override + public UnaryCallable getServiceCallable() { + return getServiceCallable; + } + + @Override + public UnaryCallable updateServiceCallable() { + return updateServiceCallable; + } + + @Override + public OperationCallable + updateServiceOperationCallable() { + return updateServiceOperationCallable; + } + + @Override + public UnaryCallable deleteServiceCallable() { + return deleteServiceCallable; + } + + @Override + public OperationCallable + deleteServiceOperationCallable() { + return deleteServiceOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonVersionsCallableFactory.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonVersionsCallableFactory.java new file mode 100644 index 000000000000..521cf7edce38 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonVersionsCallableFactory.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.appengine.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 Versions service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonVersionsCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonVersionsStub.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonVersionsStub.java new file mode 100644 index 000000000000..cca7aa763c17 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/HttpJsonVersionsStub.java @@ -0,0 +1,478 @@ +/* + * 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.appengine.v1.stub; + +import static com.google.appengine.v1.VersionsClient.ListVersionsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.appengine.v1.CreateVersionMetadataV1; +import com.google.appengine.v1.CreateVersionRequest; +import com.google.appengine.v1.DeleteVersionRequest; +import com.google.appengine.v1.GetVersionRequest; +import com.google.appengine.v1.ListVersionsRequest; +import com.google.appengine.v1.ListVersionsResponse; +import com.google.appengine.v1.OperationMetadataV1; +import com.google.appengine.v1.UpdateVersionRequest; +import com.google.appengine.v1.Version; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Versions service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonVersionsStub extends VersionsStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(CreateVersionMetadataV1.getDescriptor()) + .add(Version.getDescriptor()) + .add(OperationMetadataV1.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listVersionsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Versions/ListVersions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=apps/*/services/*}/versions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListVersionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getVersionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Versions/GetVersion") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/services/*/versions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Version.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createVersionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Versions/CreateVersion") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=apps/*/services/*}/versions", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("version", request.getVersion())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateVersionRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateVersionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Versions/UpdateVersion") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/services/*/versions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("version", request.getVersion())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateVersionRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteVersionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.appengine.v1.Versions/DeleteVersion") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=apps/*/services/*/versions/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteVersionRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable listVersionsCallable; + private final UnaryCallable + listVersionsPagedCallable; + private final UnaryCallable getVersionCallable; + private final UnaryCallable createVersionCallable; + private final OperationCallable + createVersionOperationCallable; + private final UnaryCallable updateVersionCallable; + private final OperationCallable + updateVersionOperationCallable; + private final UnaryCallable deleteVersionCallable; + private final OperationCallable + deleteVersionOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonVersionsStub create(VersionsStubSettings settings) + throws IOException { + return new HttpJsonVersionsStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonVersionsStub create(ClientContext clientContext) throws IOException { + return new HttpJsonVersionsStub( + VersionsStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonVersionsStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonVersionsStub( + VersionsStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonVersionsStub, 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 HttpJsonVersionsStub(VersionsStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonVersionsCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonVersionsStub, 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 HttpJsonVersionsStub( + VersionsStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings listVersionsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listVersionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getVersionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getVersionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createVersionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createVersionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateVersionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateVersionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteVersionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteVersionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listVersionsCallable = + callableFactory.createUnaryCallable( + listVersionsTransportSettings, settings.listVersionsSettings(), clientContext); + this.listVersionsPagedCallable = + callableFactory.createPagedCallable( + listVersionsTransportSettings, settings.listVersionsSettings(), clientContext); + this.getVersionCallable = + callableFactory.createUnaryCallable( + getVersionTransportSettings, settings.getVersionSettings(), clientContext); + this.createVersionCallable = + callableFactory.createUnaryCallable( + createVersionTransportSettings, settings.createVersionSettings(), clientContext); + this.createVersionOperationCallable = + callableFactory.createOperationCallable( + createVersionTransportSettings, + settings.createVersionOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateVersionCallable = + callableFactory.createUnaryCallable( + updateVersionTransportSettings, settings.updateVersionSettings(), clientContext); + this.updateVersionOperationCallable = + callableFactory.createOperationCallable( + updateVersionTransportSettings, + settings.updateVersionOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteVersionCallable = + callableFactory.createUnaryCallable( + deleteVersionTransportSettings, settings.deleteVersionSettings(), clientContext); + this.deleteVersionOperationCallable = + callableFactory.createOperationCallable( + deleteVersionTransportSettings, + settings.deleteVersionOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listVersionsMethodDescriptor); + methodDescriptors.add(getVersionMethodDescriptor); + methodDescriptors.add(createVersionMethodDescriptor); + methodDescriptors.add(updateVersionMethodDescriptor); + methodDescriptors.add(deleteVersionMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listVersionsCallable() { + return listVersionsCallable; + } + + @Override + public UnaryCallable listVersionsPagedCallable() { + return listVersionsPagedCallable; + } + + @Override + public UnaryCallable getVersionCallable() { + return getVersionCallable; + } + + @Override + public UnaryCallable createVersionCallable() { + return createVersionCallable; + } + + @Override + public OperationCallable + createVersionOperationCallable() { + return createVersionOperationCallable; + } + + @Override + public UnaryCallable updateVersionCallable() { + return updateVersionCallable; + } + + @Override + public OperationCallable + updateVersionOperationCallable() { + return updateVersionOperationCallable; + } + + @Override + public UnaryCallable deleteVersionCallable() { + return deleteVersionCallable; + } + + @Override + public OperationCallable + deleteVersionOperationCallable() { + return deleteVersionOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/InstancesStub.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/InstancesStub.java index 0941c5289860..66d577032cd5 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/InstancesStub.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/InstancesStub.java @@ -43,7 +43,11 @@ public abstract class InstancesStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/InstancesStubSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/InstancesStubSettings.java index 37f96893a39f..4d71901f373f 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/InstancesStubSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/InstancesStubSettings.java @@ -28,6 +28,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -202,13 +205,17 @@ public UnaryCallSettings debugInstanceSettings( return debugInstanceOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public InstancesStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcInstancesStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonInstancesStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -241,29 +248,54 @@ 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(InstancesStubSettings.class)) .setTransportToken( 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(InstancesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return InstancesStubSettings.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); @@ -380,6 +412,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 .listInstancesSettings() diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ServicesStub.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ServicesStub.java index c5f60ff46a65..e3cc35447000 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ServicesStub.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ServicesStub.java @@ -43,7 +43,11 @@ public abstract class ServicesStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable listServicesPagedCallable() { diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ServicesStubSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ServicesStubSettings.java index c56bfae1d477..2b230cd125bc 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ServicesStubSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/ServicesStubSettings.java @@ -28,6 +28,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -202,13 +205,17 @@ public UnaryCallSettings deleteServiceSettings( return deleteServiceOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public ServicesStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcServicesStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonServicesStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -241,29 +248,54 @@ 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(ServicesStubSettings.class)) .setTransportToken( 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(ServicesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ServicesStubSettings.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); @@ -379,6 +411,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 .listServicesSettings() diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/VersionsStub.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/VersionsStub.java index 3c18ea1b900f..eb2991707639 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/VersionsStub.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/VersionsStub.java @@ -45,7 +45,11 @@ public abstract class VersionsStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable listVersionsPagedCallable() { diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/VersionsStubSettings.java b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/VersionsStubSettings.java index ca8b9e422f69..7404285aba44 100644 --- a/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/VersionsStubSettings.java +++ b/java-appengine-admin/google-cloud-appengine-admin/src/main/java/com/google/appengine/v1/stub/VersionsStubSettings.java @@ -28,6 +28,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -218,13 +221,17 @@ public UnaryCallSettings deleteVersionSettings( return deleteVersionOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public VersionsStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcVersionsStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonVersionsStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -257,29 +264,54 @@ 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(VersionsStubSettings.class)) .setTransportToken( 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(VersionsStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return VersionsStubSettings.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); @@ -407,6 +439,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 .listVersionsSettings() diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/ApplicationsClientHttpJsonTest.java b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/ApplicationsClientHttpJsonTest.java new file mode 100644 index 000000000000..80c5569dc53d --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/ApplicationsClientHttpJsonTest.java @@ -0,0 +1,336 @@ +/* + * 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.appengine.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.appengine.v1.stub.HttpJsonApplicationsStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Duration; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ApplicationsClientHttpJsonTest { + private static MockHttpService mockService; + private static ApplicationsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonApplicationsStub.getMethodDescriptors(), + ApplicationsSettings.getDefaultEndpoint()); + ApplicationsSettings settings = + ApplicationsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ApplicationsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ApplicationsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void getApplicationTest() throws Exception { + Application expectedResponse = + Application.newBuilder() + .setName("name3373707") + .setId("id3355") + .addAllDispatchRules(new ArrayList()) + .setAuthDomain("authDomain1560526988") + .setLocationId("locationId1541836720") + .setCodeBucket("codeBucket-1407386057") + .setDefaultCookieExpiration(Duration.newBuilder().build()) + .setDefaultHostname("defaultHostname1698284948") + .setDefaultBucket("defaultBucket487561099") + .setServiceAccount("serviceAccount1079137720") + .setIap(Application.IdentityAwareProxy.newBuilder().build()) + .setGcrDomain("gcrDomain-595843206") + .setFeatureSettings(Application.FeatureSettings.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "apps/app-5480"; + + Application actualResponse = client.getApplication(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getApplicationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "apps/app-5480"; + client.getApplication(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createApplicationTest() throws Exception { + Application expectedResponse = + Application.newBuilder() + .setName("name3373707") + .setId("id3355") + .addAllDispatchRules(new ArrayList()) + .setAuthDomain("authDomain1560526988") + .setLocationId("locationId1541836720") + .setCodeBucket("codeBucket-1407386057") + .setDefaultCookieExpiration(Duration.newBuilder().build()) + .setDefaultHostname("defaultHostname1698284948") + .setDefaultBucket("defaultBucket487561099") + .setServiceAccount("serviceAccount1079137720") + .setIap(Application.IdentityAwareProxy.newBuilder().build()) + .setGcrDomain("gcrDomain-595843206") + .setFeatureSettings(Application.FeatureSettings.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createApplicationTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + CreateApplicationRequest request = + CreateApplicationRequest.newBuilder() + .setApplication(Application.newBuilder().build()) + .build(); + + Application actualResponse = client.createApplicationAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createApplicationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CreateApplicationRequest request = + CreateApplicationRequest.newBuilder() + .setApplication(Application.newBuilder().build()) + .build(); + client.createApplicationAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateApplicationTest() throws Exception { + Application expectedResponse = + Application.newBuilder() + .setName("name3373707") + .setId("id3355") + .addAllDispatchRules(new ArrayList()) + .setAuthDomain("authDomain1560526988") + .setLocationId("locationId1541836720") + .setCodeBucket("codeBucket-1407386057") + .setDefaultCookieExpiration(Duration.newBuilder().build()) + .setDefaultHostname("defaultHostname1698284948") + .setDefaultBucket("defaultBucket487561099") + .setServiceAccount("serviceAccount1079137720") + .setIap(Application.IdentityAwareProxy.newBuilder().build()) + .setGcrDomain("gcrDomain-595843206") + .setFeatureSettings(Application.FeatureSettings.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateApplicationTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + UpdateApplicationRequest request = + UpdateApplicationRequest.newBuilder() + .setName("apps/app-5480") + .setApplication(Application.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + Application actualResponse = client.updateApplicationAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateApplicationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdateApplicationRequest request = + UpdateApplicationRequest.newBuilder() + .setName("apps/app-5480") + .setApplication(Application.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.updateApplicationAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void repairApplicationTest() throws Exception { + Application expectedResponse = + Application.newBuilder() + .setName("name3373707") + .setId("id3355") + .addAllDispatchRules(new ArrayList()) + .setAuthDomain("authDomain1560526988") + .setLocationId("locationId1541836720") + .setCodeBucket("codeBucket-1407386057") + .setDefaultCookieExpiration(Duration.newBuilder().build()) + .setDefaultHostname("defaultHostname1698284948") + .setDefaultBucket("defaultBucket487561099") + .setServiceAccount("serviceAccount1079137720") + .setIap(Application.IdentityAwareProxy.newBuilder().build()) + .setGcrDomain("gcrDomain-595843206") + .setFeatureSettings(Application.FeatureSettings.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("repairApplicationTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RepairApplicationRequest request = + RepairApplicationRequest.newBuilder().setName("apps/app-5480").build(); + + Application actualResponse = client.repairApplicationAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void repairApplicationExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RepairApplicationRequest request = + RepairApplicationRequest.newBuilder().setName("apps/app-5480").build(); + client.repairApplicationAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/AuthorizedCertificatesClientHttpJsonTest.java b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/AuthorizedCertificatesClientHttpJsonTest.java new file mode 100644 index 000000000000..ac4fcec90e74 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/AuthorizedCertificatesClientHttpJsonTest.java @@ -0,0 +1,372 @@ +/* + * 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.appengine.v1; + +import static com.google.appengine.v1.AuthorizedCertificatesClient.ListAuthorizedCertificatesPagedResponse; + +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.appengine.v1.stub.HttpJsonAuthorizedCertificatesStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.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 AuthorizedCertificatesClientHttpJsonTest { + private static MockHttpService mockService; + private static AuthorizedCertificatesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonAuthorizedCertificatesStub.getMethodDescriptors(), + AuthorizedCertificatesSettings.getDefaultEndpoint()); + AuthorizedCertificatesSettings settings = + AuthorizedCertificatesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + AuthorizedCertificatesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = AuthorizedCertificatesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listAuthorizedCertificatesTest() throws Exception { + AuthorizedCertificate responsesElement = AuthorizedCertificate.newBuilder().build(); + ListAuthorizedCertificatesResponse expectedResponse = + ListAuthorizedCertificatesResponse.newBuilder() + .setNextPageToken("") + .addAllCertificates(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListAuthorizedCertificatesRequest request = + ListAuthorizedCertificatesRequest.newBuilder() + .setParent("apps/app-3559") + .setView(AuthorizedCertificateView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListAuthorizedCertificatesPagedResponse pagedListResponse = + client.listAuthorizedCertificates(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getCertificatesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listAuthorizedCertificatesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListAuthorizedCertificatesRequest request = + ListAuthorizedCertificatesRequest.newBuilder() + .setParent("apps/app-3559") + .setView(AuthorizedCertificateView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listAuthorizedCertificates(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getAuthorizedCertificateTest() throws Exception { + AuthorizedCertificate expectedResponse = + AuthorizedCertificate.newBuilder() + .setName("name3373707") + .setId("id3355") + .setDisplayName("displayName1714148973") + .addAllDomainNames(new ArrayList()) + .setExpireTime(Timestamp.newBuilder().build()) + .setCertificateRawData(CertificateRawData.newBuilder().build()) + .setManagedCertificate(ManagedCertificate.newBuilder().build()) + .addAllVisibleDomainMappings(new ArrayList()) + .setDomainMappingsCount(-307278192) + .build(); + mockService.addResponse(expectedResponse); + + GetAuthorizedCertificateRequest request = + GetAuthorizedCertificateRequest.newBuilder() + .setName("apps/app-9719/authorizedCertificates/authorizedCertificate-9719") + .setView(AuthorizedCertificateView.forNumber(0)) + .build(); + + AuthorizedCertificate actualResponse = client.getAuthorizedCertificate(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 getAuthorizedCertificateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetAuthorizedCertificateRequest request = + GetAuthorizedCertificateRequest.newBuilder() + .setName("apps/app-9719/authorizedCertificates/authorizedCertificate-9719") + .setView(AuthorizedCertificateView.forNumber(0)) + .build(); + client.getAuthorizedCertificate(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createAuthorizedCertificateTest() throws Exception { + AuthorizedCertificate expectedResponse = + AuthorizedCertificate.newBuilder() + .setName("name3373707") + .setId("id3355") + .setDisplayName("displayName1714148973") + .addAllDomainNames(new ArrayList()) + .setExpireTime(Timestamp.newBuilder().build()) + .setCertificateRawData(CertificateRawData.newBuilder().build()) + .setManagedCertificate(ManagedCertificate.newBuilder().build()) + .addAllVisibleDomainMappings(new ArrayList()) + .setDomainMappingsCount(-307278192) + .build(); + mockService.addResponse(expectedResponse); + + CreateAuthorizedCertificateRequest request = + CreateAuthorizedCertificateRequest.newBuilder() + .setParent("apps/app-3559") + .setCertificate(AuthorizedCertificate.newBuilder().build()) + .build(); + + AuthorizedCertificate actualResponse = client.createAuthorizedCertificate(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 createAuthorizedCertificateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CreateAuthorizedCertificateRequest request = + CreateAuthorizedCertificateRequest.newBuilder() + .setParent("apps/app-3559") + .setCertificate(AuthorizedCertificate.newBuilder().build()) + .build(); + client.createAuthorizedCertificate(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateAuthorizedCertificateTest() throws Exception { + AuthorizedCertificate expectedResponse = + AuthorizedCertificate.newBuilder() + .setName("name3373707") + .setId("id3355") + .setDisplayName("displayName1714148973") + .addAllDomainNames(new ArrayList()) + .setExpireTime(Timestamp.newBuilder().build()) + .setCertificateRawData(CertificateRawData.newBuilder().build()) + .setManagedCertificate(ManagedCertificate.newBuilder().build()) + .addAllVisibleDomainMappings(new ArrayList()) + .setDomainMappingsCount(-307278192) + .build(); + mockService.addResponse(expectedResponse); + + UpdateAuthorizedCertificateRequest request = + UpdateAuthorizedCertificateRequest.newBuilder() + .setName("apps/app-9719/authorizedCertificates/authorizedCertificate-9719") + .setCertificate(AuthorizedCertificate.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + AuthorizedCertificate actualResponse = client.updateAuthorizedCertificate(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 updateAuthorizedCertificateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdateAuthorizedCertificateRequest request = + UpdateAuthorizedCertificateRequest.newBuilder() + .setName("apps/app-9719/authorizedCertificates/authorizedCertificate-9719") + .setCertificate(AuthorizedCertificate.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.updateAuthorizedCertificate(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteAuthorizedCertificateTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DeleteAuthorizedCertificateRequest request = + DeleteAuthorizedCertificateRequest.newBuilder() + .setName("apps/app-9719/authorizedCertificates/authorizedCertificate-9719") + .build(); + + client.deleteAuthorizedCertificate(request); + + 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 deleteAuthorizedCertificateExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeleteAuthorizedCertificateRequest request = + DeleteAuthorizedCertificateRequest.newBuilder() + .setName("apps/app-9719/authorizedCertificates/authorizedCertificate-9719") + .build(); + client.deleteAuthorizedCertificate(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/AuthorizedDomainsClientHttpJsonTest.java b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/AuthorizedDomainsClientHttpJsonTest.java new file mode 100644 index 000000000000..8d8d9de74bad --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/AuthorizedDomainsClientHttpJsonTest.java @@ -0,0 +1,137 @@ +/* + * 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.appengine.v1; + +import static com.google.appengine.v1.AuthorizedDomainsClient.ListAuthorizedDomainsPagedResponse; + +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.appengine.v1.stub.HttpJsonAuthorizedDomainsStub; +import com.google.common.collect.Lists; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class AuthorizedDomainsClientHttpJsonTest { + private static MockHttpService mockService; + private static AuthorizedDomainsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonAuthorizedDomainsStub.getMethodDescriptors(), + AuthorizedDomainsSettings.getDefaultEndpoint()); + AuthorizedDomainsSettings settings = + AuthorizedDomainsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + AuthorizedDomainsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = AuthorizedDomainsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listAuthorizedDomainsTest() throws Exception { + AuthorizedDomain responsesElement = AuthorizedDomain.newBuilder().build(); + ListAuthorizedDomainsResponse expectedResponse = + ListAuthorizedDomainsResponse.newBuilder() + .setNextPageToken("") + .addAllDomains(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListAuthorizedDomainsRequest request = + ListAuthorizedDomainsRequest.newBuilder() + .setParent("apps/app-3559") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListAuthorizedDomainsPagedResponse pagedListResponse = client.listAuthorizedDomains(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDomainsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listAuthorizedDomainsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListAuthorizedDomainsRequest request = + ListAuthorizedDomainsRequest.newBuilder() + .setParent("apps/app-3559") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listAuthorizedDomains(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/DomainMappingsClientHttpJsonTest.java b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/DomainMappingsClientHttpJsonTest.java new file mode 100644 index 000000000000..393366a9bae1 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/DomainMappingsClientHttpJsonTest.java @@ -0,0 +1,371 @@ +/* + * 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.appengine.v1; + +import static com.google.appengine.v1.DomainMappingsClient.ListDomainMappingsPagedResponse; + +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.appengine.v1.stub.HttpJsonDomainMappingsStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class DomainMappingsClientHttpJsonTest { + private static MockHttpService mockService; + private static DomainMappingsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonDomainMappingsStub.getMethodDescriptors(), + DomainMappingsSettings.getDefaultEndpoint()); + DomainMappingsSettings settings = + DomainMappingsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + DomainMappingsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DomainMappingsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listDomainMappingsTest() throws Exception { + DomainMapping responsesElement = DomainMapping.newBuilder().build(); + ListDomainMappingsResponse expectedResponse = + ListDomainMappingsResponse.newBuilder() + .setNextPageToken("") + .addAllDomainMappings(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListDomainMappingsRequest request = + ListDomainMappingsRequest.newBuilder() + .setParent("apps/app-3559") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListDomainMappingsPagedResponse pagedListResponse = client.listDomainMappings(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDomainMappingsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDomainMappingsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListDomainMappingsRequest request = + ListDomainMappingsRequest.newBuilder() + .setParent("apps/app-3559") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listDomainMappings(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDomainMappingTest() throws Exception { + DomainMapping expectedResponse = + DomainMapping.newBuilder() + .setName("name3373707") + .setId("id3355") + .setSslSettings(SslSettings.newBuilder().build()) + .addAllResourceRecords(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + GetDomainMappingRequest request = + GetDomainMappingRequest.newBuilder() + .setName("apps/app-1227/domainMappings/domainMapping-1227") + .build(); + + DomainMapping actualResponse = client.getDomainMapping(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 getDomainMappingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetDomainMappingRequest request = + GetDomainMappingRequest.newBuilder() + .setName("apps/app-1227/domainMappings/domainMapping-1227") + .build(); + client.getDomainMapping(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDomainMappingTest() throws Exception { + DomainMapping expectedResponse = + DomainMapping.newBuilder() + .setName("name3373707") + .setId("id3355") + .setSslSettings(SslSettings.newBuilder().build()) + .addAllResourceRecords(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createDomainMappingTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + CreateDomainMappingRequest request = + CreateDomainMappingRequest.newBuilder() + .setParent("apps/app-3559") + .setDomainMapping(DomainMapping.newBuilder().build()) + .setOverrideStrategy(DomainOverrideStrategy.forNumber(0)) + .build(); + + DomainMapping actualResponse = client.createDomainMappingAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDomainMappingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CreateDomainMappingRequest request = + CreateDomainMappingRequest.newBuilder() + .setParent("apps/app-3559") + .setDomainMapping(DomainMapping.newBuilder().build()) + .setOverrideStrategy(DomainOverrideStrategy.forNumber(0)) + .build(); + client.createDomainMappingAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateDomainMappingTest() throws Exception { + DomainMapping expectedResponse = + DomainMapping.newBuilder() + .setName("name3373707") + .setId("id3355") + .setSslSettings(SslSettings.newBuilder().build()) + .addAllResourceRecords(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateDomainMappingTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + UpdateDomainMappingRequest request = + UpdateDomainMappingRequest.newBuilder() + .setName("apps/app-1227/domainMappings/domainMapping-1227") + .setDomainMapping(DomainMapping.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + DomainMapping actualResponse = client.updateDomainMappingAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateDomainMappingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdateDomainMappingRequest request = + UpdateDomainMappingRequest.newBuilder() + .setName("apps/app-1227/domainMappings/domainMapping-1227") + .setDomainMapping(DomainMapping.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.updateDomainMappingAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteDomainMappingTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDomainMappingTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DeleteDomainMappingRequest request = + DeleteDomainMappingRequest.newBuilder() + .setName("apps/app-1227/domainMappings/domainMapping-1227") + .build(); + + client.deleteDomainMappingAsync(request).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDomainMappingExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeleteDomainMappingRequest request = + DeleteDomainMappingRequest.newBuilder() + .setName("apps/app-1227/domainMappings/domainMapping-1227") + .build(); + client.deleteDomainMappingAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/FirewallClientHttpJsonTest.java b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/FirewallClientHttpJsonTest.java new file mode 100644 index 000000000000..1f682ea23a24 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/FirewallClientHttpJsonTest.java @@ -0,0 +1,402 @@ +/* + * 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.appengine.v1; + +import static com.google.appengine.v1.FirewallClient.ListIngressRulesPagedResponse; + +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.appengine.v1.firewall.FirewallRule; +import com.google.appengine.v1.stub.HttpJsonFirewallStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class FirewallClientHttpJsonTest { + private static MockHttpService mockService; + private static FirewallClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonFirewallStub.getMethodDescriptors(), FirewallSettings.getDefaultEndpoint()); + FirewallSettings settings = + FirewallSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + FirewallSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = FirewallClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listIngressRulesTest() throws Exception { + FirewallRule responsesElement = FirewallRule.newBuilder().build(); + ListIngressRulesResponse expectedResponse = + ListIngressRulesResponse.newBuilder() + .setNextPageToken("") + .addAllIngressRules(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListIngressRulesRequest request = + ListIngressRulesRequest.newBuilder() + .setParent("apps/app-3559") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setMatchingAddress("matchingAddress861962551") + .build(); + + ListIngressRulesPagedResponse pagedListResponse = client.listIngressRules(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getIngressRulesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listIngressRulesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListIngressRulesRequest request = + ListIngressRulesRequest.newBuilder() + .setParent("apps/app-3559") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setMatchingAddress("matchingAddress861962551") + .build(); + client.listIngressRules(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchUpdateIngressRulesTest() throws Exception { + BatchUpdateIngressRulesResponse expectedResponse = + BatchUpdateIngressRulesResponse.newBuilder() + .addAllIngressRules(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + BatchUpdateIngressRulesRequest request = + BatchUpdateIngressRulesRequest.newBuilder() + .setName("apps/app-4902/firewall/ingressRules") + .addAllIngressRules(new ArrayList()) + .build(); + + BatchUpdateIngressRulesResponse actualResponse = client.batchUpdateIngressRules(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 batchUpdateIngressRulesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BatchUpdateIngressRulesRequest request = + BatchUpdateIngressRulesRequest.newBuilder() + .setName("apps/app-4902/firewall/ingressRules") + .addAllIngressRules(new ArrayList()) + .build(); + client.batchUpdateIngressRules(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createIngressRuleTest() throws Exception { + FirewallRule expectedResponse = + FirewallRule.newBuilder() + .setPriority(-1165461084) + .setSourceRange("sourceRange-97207838") + .setDescription("description-1724546052") + .build(); + mockService.addResponse(expectedResponse); + + CreateIngressRuleRequest request = + CreateIngressRuleRequest.newBuilder() + .setParent("apps/app-3559") + .setRule(FirewallRule.newBuilder().build()) + .build(); + + FirewallRule actualResponse = client.createIngressRule(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 createIngressRuleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CreateIngressRuleRequest request = + CreateIngressRuleRequest.newBuilder() + .setParent("apps/app-3559") + .setRule(FirewallRule.newBuilder().build()) + .build(); + client.createIngressRule(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIngressRuleTest() throws Exception { + FirewallRule expectedResponse = + FirewallRule.newBuilder() + .setPriority(-1165461084) + .setSourceRange("sourceRange-97207838") + .setDescription("description-1724546052") + .build(); + mockService.addResponse(expectedResponse); + + GetIngressRuleRequest request = + GetIngressRuleRequest.newBuilder() + .setName("apps/app-389/firewall/ingressRules/ingressRule-389") + .build(); + + FirewallRule actualResponse = client.getIngressRule(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 getIngressRuleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetIngressRuleRequest request = + GetIngressRuleRequest.newBuilder() + .setName("apps/app-389/firewall/ingressRules/ingressRule-389") + .build(); + client.getIngressRule(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateIngressRuleTest() throws Exception { + FirewallRule expectedResponse = + FirewallRule.newBuilder() + .setPriority(-1165461084) + .setSourceRange("sourceRange-97207838") + .setDescription("description-1724546052") + .build(); + mockService.addResponse(expectedResponse); + + UpdateIngressRuleRequest request = + UpdateIngressRuleRequest.newBuilder() + .setName("apps/app-389/firewall/ingressRules/ingressRule-389") + .setRule(FirewallRule.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + FirewallRule actualResponse = client.updateIngressRule(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 updateIngressRuleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdateIngressRuleRequest request = + UpdateIngressRuleRequest.newBuilder() + .setName("apps/app-389/firewall/ingressRules/ingressRule-389") + .setRule(FirewallRule.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.updateIngressRule(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteIngressRuleTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + DeleteIngressRuleRequest request = + DeleteIngressRuleRequest.newBuilder() + .setName("apps/app-389/firewall/ingressRules/ingressRule-389") + .build(); + + client.deleteIngressRule(request); + + 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 deleteIngressRuleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeleteIngressRuleRequest request = + DeleteIngressRuleRequest.newBuilder() + .setName("apps/app-389/firewall/ingressRules/ingressRule-389") + .build(); + client.deleteIngressRule(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/InstancesClientHttpJsonTest.java b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/InstancesClientHttpJsonTest.java new file mode 100644 index 000000000000..d8468290bd0f --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/InstancesClientHttpJsonTest.java @@ -0,0 +1,333 @@ +/* + * 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.appengine.v1; + +import static com.google.appengine.v1.InstancesClient.ListInstancesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.appengine.v1.stub.HttpJsonInstancesStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class InstancesClientHttpJsonTest { + private static MockHttpService mockService; + private static InstancesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonInstancesStub.getMethodDescriptors(), InstancesSettings.getDefaultEndpoint()); + InstancesSettings settings = + InstancesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + InstancesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = InstancesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listInstancesTest() throws Exception { + Instance responsesElement = Instance.newBuilder().build(); + ListInstancesResponse expectedResponse = + ListInstancesResponse.newBuilder() + .setNextPageToken("") + .addAllInstances(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent("apps/app-8780/services/service-8780/versions/version-8780") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListInstancesPagedResponse pagedListResponse = client.listInstances(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInstancesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listInstancesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent("apps/app-8780/services/service-8780/versions/version-8780") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listInstances(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName("name3373707") + .setId("id3355") + .setAppEngineRelease("appEngineRelease-1601369404") + .setVmName("vmName-813643294") + .setVmZoneName("vmZoneName-245094354") + .setVmId("vmId3622450") + .setStartTime(Timestamp.newBuilder().build()) + .setRequests(-393257020) + .setErrors(-1294635157) + .setQps(112180) + .setAverageLatency(1814586588) + .setMemoryUsage(1034557667) + .setVmStatus("vmStatus-66804343") + .setVmDebugEnabled(true) + .setVmIp("vmIp3622462") + .build(); + mockService.addResponse(expectedResponse); + + GetInstanceRequest request = + GetInstanceRequest.newBuilder() + .setName( + "apps/app-9649/services/service-9649/versions/version-9649/instances/instance-9649") + .build(); + + Instance actualResponse = client.getInstance(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetInstanceRequest request = + GetInstanceRequest.newBuilder() + .setName( + "apps/app-9649/services/service-9649/versions/version-9649/instances/instance-9649") + .build(); + client.getInstance(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteInstanceTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DeleteInstanceRequest request = + DeleteInstanceRequest.newBuilder() + .setName( + "apps/app-9649/services/service-9649/versions/version-9649/instances/instance-9649") + .build(); + + client.deleteInstanceAsync(request).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeleteInstanceRequest request = + DeleteInstanceRequest.newBuilder() + .setName( + "apps/app-9649/services/service-9649/versions/version-9649/instances/instance-9649") + .build(); + client.deleteInstanceAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void debugInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName("name3373707") + .setId("id3355") + .setAppEngineRelease("appEngineRelease-1601369404") + .setVmName("vmName-813643294") + .setVmZoneName("vmZoneName-245094354") + .setVmId("vmId3622450") + .setStartTime(Timestamp.newBuilder().build()) + .setRequests(-393257020) + .setErrors(-1294635157) + .setQps(112180) + .setAverageLatency(1814586588) + .setMemoryUsage(1034557667) + .setVmStatus("vmStatus-66804343") + .setVmDebugEnabled(true) + .setVmIp("vmIp3622462") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("debugInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DebugInstanceRequest request = + DebugInstanceRequest.newBuilder() + .setName( + "apps/app-9649/services/service-9649/versions/version-9649/instances/instance-9649") + .setSshKey("sshKey-893236425") + .build(); + + Instance actualResponse = client.debugInstanceAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void debugInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DebugInstanceRequest request = + DebugInstanceRequest.newBuilder() + .setName( + "apps/app-9649/services/service-9649/versions/version-9649/instances/instance-9649") + .setSshKey("sshKey-893236425") + .build(); + client.debugInstanceAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/ServicesClientHttpJsonTest.java b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/ServicesClientHttpJsonTest.java new file mode 100644 index 000000000000..b670d1ed1154 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/ServicesClientHttpJsonTest.java @@ -0,0 +1,304 @@ +/* + * 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.appengine.v1; + +import static com.google.appengine.v1.ServicesClient.ListServicesPagedResponse; + +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.appengine.v1.stub.HttpJsonServicesStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ServicesClientHttpJsonTest { + private static MockHttpService mockService; + private static ServicesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonServicesStub.getMethodDescriptors(), ServicesSettings.getDefaultEndpoint()); + ServicesSettings settings = + ServicesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ServicesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ServicesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listServicesTest() throws Exception { + Service responsesElement = Service.newBuilder().build(); + ListServicesResponse expectedResponse = + ListServicesResponse.newBuilder() + .setNextPageToken("") + .addAllServices(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListServicesRequest request = + ListServicesRequest.newBuilder() + .setParent("apps/app-3559") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListServicesPagedResponse pagedListResponse = client.listServices(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getServicesList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listServicesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListServicesRequest request = + ListServicesRequest.newBuilder() + .setParent("apps/app-3559") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listServices(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getServiceTest() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName("name3373707") + .setId("id3355") + .setSplit(TrafficSplit.newBuilder().build()) + .putAllLabels(new HashMap()) + .setNetworkSettings(NetworkSettings.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GetServiceRequest request = + GetServiceRequest.newBuilder().setName("apps/app-9760/services/service-9760").build(); + + Service actualResponse = client.getService(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 getServiceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetServiceRequest request = + GetServiceRequest.newBuilder().setName("apps/app-9760/services/service-9760").build(); + client.getService(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateServiceTest() throws Exception { + Service expectedResponse = + Service.newBuilder() + .setName("name3373707") + .setId("id3355") + .setSplit(TrafficSplit.newBuilder().build()) + .putAllLabels(new HashMap()) + .setNetworkSettings(NetworkSettings.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateServiceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + UpdateServiceRequest request = + UpdateServiceRequest.newBuilder() + .setName("apps/app-9760/services/service-9760") + .setService(Service.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setMigrateTraffic(true) + .build(); + + Service actualResponse = client.updateServiceAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateServiceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdateServiceRequest request = + UpdateServiceRequest.newBuilder() + .setName("apps/app-9760/services/service-9760") + .setService(Service.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .setMigrateTraffic(true) + .build(); + client.updateServiceAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteServiceTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteServiceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DeleteServiceRequest request = + DeleteServiceRequest.newBuilder().setName("apps/app-9760/services/service-9760").build(); + + client.deleteServiceAsync(request).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteServiceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeleteServiceRequest request = + DeleteServiceRequest.newBuilder().setName("apps/app-9760/services/service-9760").build(); + client.deleteServiceAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/VersionsClientHttpJsonTest.java b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/VersionsClientHttpJsonTest.java new file mode 100644 index 000000000000..1ea7beabc0e6 --- /dev/null +++ b/java-appengine-admin/google-cloud-appengine-admin/src/test/java/com/google/appengine/v1/VersionsClientHttpJsonTest.java @@ -0,0 +1,474 @@ +/* + * 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.appengine.v1; + +import static com.google.appengine.v1.VersionsClient.ListVersionsPagedResponse; + +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.appengine.v1.stub.HttpJsonVersionsStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class VersionsClientHttpJsonTest { + private static MockHttpService mockService; + private static VersionsClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonVersionsStub.getMethodDescriptors(), VersionsSettings.getDefaultEndpoint()); + VersionsSettings settings = + VersionsSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + VersionsSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = VersionsClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listVersionsTest() throws Exception { + Version responsesElement = Version.newBuilder().build(); + ListVersionsResponse expectedResponse = + ListVersionsResponse.newBuilder() + .setNextPageToken("") + .addAllVersions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListVersionsRequest request = + ListVersionsRequest.newBuilder() + .setParent("apps/app-4783/services/service-4783") + .setView(VersionView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListVersionsPagedResponse pagedListResponse = client.listVersions(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVersionsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listVersionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListVersionsRequest request = + ListVersionsRequest.newBuilder() + .setParent("apps/app-4783/services/service-4783") + .setView(VersionView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listVersions(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVersionTest() throws Exception { + Version expectedResponse = + Version.newBuilder() + .setName("name3373707") + .setId("id3355") + .addAllInboundServices(new ArrayList()) + .setInstanceClass("instanceClass-1408583197") + .setNetwork(Network.newBuilder().build()) + .addAllZones(new ArrayList()) + .setResources(Resources.newBuilder().build()) + .setRuntime("runtime1550962648") + .setRuntimeChannel("runtimeChannel989413899") + .setThreadsafe(true) + .setVm(true) + .setAppEngineApis(true) + .putAllBetaSettings(new HashMap()) + .setEnv("env100589") + .setServingStatus(ServingStatus.forNumber(0)) + .setCreatedBy("createdBy598371679") + .setCreateTime(Timestamp.newBuilder().build()) + .setDiskUsageBytes(1139084459) + .setRuntimeApiVersion("runtimeApiVersion-925808810") + .setRuntimeMainExecutablePath("runtimeMainExecutablePath454707104") + .setServiceAccount("serviceAccount1079137720") + .addAllHandlers(new ArrayList()) + .addAllErrorHandlers(new ArrayList()) + .addAllLibraries(new ArrayList()) + .setApiConfig(ApiConfigHandler.newBuilder().build()) + .putAllEnvVariables(new HashMap()) + .putAllBuildEnvVariables(new HashMap()) + .setDefaultExpiration(Duration.newBuilder().build()) + .setHealthCheck(HealthCheck.newBuilder().build()) + .setReadinessCheck(ReadinessCheck.newBuilder().build()) + .setLivenessCheck(LivenessCheck.newBuilder().build()) + .setNobuildFilesRegex("nobuildFilesRegex1787347261") + .setDeployment(Deployment.newBuilder().build()) + .setVersionUrl("versionUrl-670506633") + .setEndpointsApiService(EndpointsApiService.newBuilder().build()) + .setEntrypoint(Entrypoint.newBuilder().build()) + .setVpcAccessConnector(VpcAccessConnector.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GetVersionRequest request = + GetVersionRequest.newBuilder() + .setName("apps/app-69/services/service-69/versions/version-69") + .setView(VersionView.forNumber(0)) + .build(); + + Version actualResponse = client.getVersion(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 getVersionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetVersionRequest request = + GetVersionRequest.newBuilder() + .setName("apps/app-69/services/service-69/versions/version-69") + .setView(VersionView.forNumber(0)) + .build(); + client.getVersion(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createVersionTest() throws Exception { + Version expectedResponse = + Version.newBuilder() + .setName("name3373707") + .setId("id3355") + .addAllInboundServices(new ArrayList()) + .setInstanceClass("instanceClass-1408583197") + .setNetwork(Network.newBuilder().build()) + .addAllZones(new ArrayList()) + .setResources(Resources.newBuilder().build()) + .setRuntime("runtime1550962648") + .setRuntimeChannel("runtimeChannel989413899") + .setThreadsafe(true) + .setVm(true) + .setAppEngineApis(true) + .putAllBetaSettings(new HashMap()) + .setEnv("env100589") + .setServingStatus(ServingStatus.forNumber(0)) + .setCreatedBy("createdBy598371679") + .setCreateTime(Timestamp.newBuilder().build()) + .setDiskUsageBytes(1139084459) + .setRuntimeApiVersion("runtimeApiVersion-925808810") + .setRuntimeMainExecutablePath("runtimeMainExecutablePath454707104") + .setServiceAccount("serviceAccount1079137720") + .addAllHandlers(new ArrayList()) + .addAllErrorHandlers(new ArrayList()) + .addAllLibraries(new ArrayList()) + .setApiConfig(ApiConfigHandler.newBuilder().build()) + .putAllEnvVariables(new HashMap()) + .putAllBuildEnvVariables(new HashMap()) + .setDefaultExpiration(Duration.newBuilder().build()) + .setHealthCheck(HealthCheck.newBuilder().build()) + .setReadinessCheck(ReadinessCheck.newBuilder().build()) + .setLivenessCheck(LivenessCheck.newBuilder().build()) + .setNobuildFilesRegex("nobuildFilesRegex1787347261") + .setDeployment(Deployment.newBuilder().build()) + .setVersionUrl("versionUrl-670506633") + .setEndpointsApiService(EndpointsApiService.newBuilder().build()) + .setEntrypoint(Entrypoint.newBuilder().build()) + .setVpcAccessConnector(VpcAccessConnector.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createVersionTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + CreateVersionRequest request = + CreateVersionRequest.newBuilder() + .setParent("apps/app-4783/services/service-4783") + .setVersion(Version.newBuilder().build()) + .build(); + + Version actualResponse = client.createVersionAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createVersionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CreateVersionRequest request = + CreateVersionRequest.newBuilder() + .setParent("apps/app-4783/services/service-4783") + .setVersion(Version.newBuilder().build()) + .build(); + client.createVersionAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateVersionTest() throws Exception { + Version expectedResponse = + Version.newBuilder() + .setName("name3373707") + .setId("id3355") + .addAllInboundServices(new ArrayList()) + .setInstanceClass("instanceClass-1408583197") + .setNetwork(Network.newBuilder().build()) + .addAllZones(new ArrayList()) + .setResources(Resources.newBuilder().build()) + .setRuntime("runtime1550962648") + .setRuntimeChannel("runtimeChannel989413899") + .setThreadsafe(true) + .setVm(true) + .setAppEngineApis(true) + .putAllBetaSettings(new HashMap()) + .setEnv("env100589") + .setServingStatus(ServingStatus.forNumber(0)) + .setCreatedBy("createdBy598371679") + .setCreateTime(Timestamp.newBuilder().build()) + .setDiskUsageBytes(1139084459) + .setRuntimeApiVersion("runtimeApiVersion-925808810") + .setRuntimeMainExecutablePath("runtimeMainExecutablePath454707104") + .setServiceAccount("serviceAccount1079137720") + .addAllHandlers(new ArrayList()) + .addAllErrorHandlers(new ArrayList()) + .addAllLibraries(new ArrayList()) + .setApiConfig(ApiConfigHandler.newBuilder().build()) + .putAllEnvVariables(new HashMap()) + .putAllBuildEnvVariables(new HashMap()) + .setDefaultExpiration(Duration.newBuilder().build()) + .setHealthCheck(HealthCheck.newBuilder().build()) + .setReadinessCheck(ReadinessCheck.newBuilder().build()) + .setLivenessCheck(LivenessCheck.newBuilder().build()) + .setNobuildFilesRegex("nobuildFilesRegex1787347261") + .setDeployment(Deployment.newBuilder().build()) + .setVersionUrl("versionUrl-670506633") + .setEndpointsApiService(EndpointsApiService.newBuilder().build()) + .setEntrypoint(Entrypoint.newBuilder().build()) + .setVpcAccessConnector(VpcAccessConnector.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateVersionTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + UpdateVersionRequest request = + UpdateVersionRequest.newBuilder() + .setName("apps/app-69/services/service-69/versions/version-69") + .setVersion(Version.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + + Version actualResponse = client.updateVersionAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateVersionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdateVersionRequest request = + UpdateVersionRequest.newBuilder() + .setName("apps/app-69/services/service-69/versions/version-69") + .setVersion(Version.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + client.updateVersionAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteVersionTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteVersionTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DeleteVersionRequest request = + DeleteVersionRequest.newBuilder() + .setName("apps/app-69/services/service-69/versions/version-69") + .build(); + + client.deleteVersionAsync(request).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteVersionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeleteVersionRequest request = + DeleteVersionRequest.newBuilder() + .setName("apps/app-69/services/service-69/versions/version-69") + .build(); + client.deleteVersionAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +}