Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

fix: update gapic-generator-java with mock service generation fixes #424

Merged
merged 12 commits into from Jun 30, 2022
Merged
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -19,20 +19,20 @@ If you are using Maven, add this to your pom.xml file:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-functions</artifactId>
<version>2.4.0</version>
<version>2.4.1</version>
</dependency>
```

If you are using Gradle without BOM, add this to your dependencies

```Groovy
implementation 'com.google.cloud:google-cloud-functions:2.4.0'
implementation 'com.google.cloud:google-cloud-functions:2.4.1'
```

If you are using SBT, add this to your dependencies

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-functions" % "2.4.0"
libraryDependencies += "com.google.cloud" % "google-cloud-functions" % "2.4.1"
```

## Authentication
Expand Down
20 changes: 20 additions & 0 deletions google-cloud-functions-bom/pom.xml
Expand Up @@ -63,11 +63,31 @@
<artifactId>grpc-google-cloud-functions-v1</artifactId>
<version>2.4.2-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-functions-v1:current} -->
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-cloud-functions-v2beta</artifactId>
<version>2.4.2-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-functions-v2beta:current} -->
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-cloud-functions-v2alpha</artifactId>
<version>2.4.2-SNAPSHOT</version><!-- {x-version-update:grpc-google-cloud-functions-v2alpha:current} -->
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-functions-v1</artifactId>
<version>2.4.2-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-functions-v1:current} -->
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-functions-v2beta</artifactId>
<version>2.4.2-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-functions-v2beta:current} -->
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-functions-v2alpha</artifactId>
<version>2.4.2-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-functions-v2alpha:current} -->
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
43 changes: 43 additions & 0 deletions google-cloud-functions/pom.xml
Expand Up @@ -41,7 +41,24 @@
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-iam-v1</artifactId>
</dependency>


<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-functions-v2alpha</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-functions-v2beta</artifactId>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-cloud-functions-v1</artifactId>
Expand All @@ -58,6 +75,10 @@
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-httpjson</artifactId>
</dependency>
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
Expand All @@ -79,13 +100,35 @@
<artifactId>grpc-google-cloud-functions-v1</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-cloud-functions-v2alpha</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-cloud-functions-v2beta</artifactId>
<scope>test</scope>
</dependency>
<!-- Need testing utility classes for generated gRPC clients tests -->
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-httpjson</artifactId>
<classifier>testlib</classifier>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
Expand Up @@ -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;
Expand All @@ -36,7 +37,6 @@
import com.google.iam.v1.TestIamPermissionsRequest;
import com.google.iam.v1.TestIamPermissionsResponse;
import com.google.longrunning.Operation;
import com.google.longrunning.OperationsClient;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.List;
Expand Down Expand Up @@ -111,13 +111,29 @@
* CloudFunctionsServiceClient.create(cloudFunctionsServiceSettings);
* }</pre>
*
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
* the wire:
*
* <pre>{@code
* // This snippet has been automatically generated for illustrative purposes only.
* // It may require modifications to work in your environment.
* CloudFunctionsServiceSettings cloudFunctionsServiceSettings =
* CloudFunctionsServiceSettings.newBuilder()
* .setTransportChannelProvider(
* CloudFunctionsServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
* .build();
* CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create(cloudFunctionsServiceSettings);
* }</pre>
*
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class CloudFunctionsServiceClient implements BackgroundResource {
private final CloudFunctionsServiceSettings settings;
private final CloudFunctionsServiceStub stub;
private final OperationsClient operationsClient;
private final OperationsClient httpJsonOperationsClient;
private final com.google.longrunning.OperationsClient operationsClient;

/** Constructs an instance of CloudFunctionsServiceClient with default settings. */
public static final CloudFunctionsServiceClient create() throws IOException {
Expand All @@ -137,7 +153,6 @@ public static final CloudFunctionsServiceClient create(CloudFunctionsServiceSett
* Constructs an instance of CloudFunctionsServiceClient, using the given stub for making calls.
* This is for advanced usage - prefer using create(CloudFunctionsServiceSettings).
*/
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public static final CloudFunctionsServiceClient create(CloudFunctionsServiceStub stub) {
return new CloudFunctionsServiceClient(stub);
}
Expand All @@ -150,21 +165,23 @@ public static final CloudFunctionsServiceClient create(CloudFunctionsServiceStub
protected CloudFunctionsServiceClient(CloudFunctionsServiceSettings settings) throws IOException {
this.settings = settings;
this.stub = ((CloudFunctionsServiceStubSettings) 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 CloudFunctionsServiceClient(CloudFunctionsServiceStub 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 CloudFunctionsServiceSettings getSettings() {
return settings;
}

@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public CloudFunctionsServiceStub getStub() {
return stub;
}
Expand All @@ -173,10 +190,19 @@ public CloudFunctionsServiceStub 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.
/**
* Returns a list of functions that belong to the requested project.
Expand Down Expand Up @@ -259,7 +285,7 @@ public final ListFunctionsPagedResponse listFunctions(ListFunctionsRequest reque
* while (true) {
* ListFunctionsResponse response =
* cloudFunctionsServiceClient.listFunctionsCallable().call(request);
* for (CloudFunction element : response.getResponsesList()) {
* for (CloudFunction element : response.getFunctionsList()) {
* // doThingsWith(element);
* }
* String nextPageToken = response.getNextPageToken();
Expand Down Expand Up @@ -930,7 +956,12 @@ public final UnaryCallable<CallFunctionRequest, CallFunctionResponse> callFuncti
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* GenerateUploadUrlRequest request =
* GenerateUploadUrlRequest.newBuilder().setParent("parent-995424086").build();
* GenerateUploadUrlRequest.newBuilder()
* .setParent("parent-995424086")
* .setKmsKeyName(
* CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
* .toString())
* .build();
* GenerateUploadUrlResponse response = cloudFunctionsServiceClient.generateUploadUrl(request);
* }
* }</pre>
Expand Down Expand Up @@ -981,7 +1012,12 @@ public final GenerateUploadUrlResponse generateUploadUrl(GenerateUploadUrlReques
* try (CloudFunctionsServiceClient cloudFunctionsServiceClient =
* CloudFunctionsServiceClient.create()) {
* GenerateUploadUrlRequest request =
* GenerateUploadUrlRequest.newBuilder().setParent("parent-995424086").build();
* GenerateUploadUrlRequest.newBuilder()
* .setParent("parent-995424086")
* .setKmsKeyName(
* CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
* .toString())
* .build();
* ApiFuture<GenerateUploadUrlResponse> future =
* cloudFunctionsServiceClient.generateUploadUrlCallable().futureCall(request);
* // Do something.
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -186,11 +187,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return CloudFunctionsServiceStubSettings.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 CloudFunctionsServiceStubSettings.defaultGrpcTransportProviderBuilder();
}

/** Returns a builder for the default REST ChannelProvider for this service. */
@BetaApi
public static InstantiatingHttpJsonChannelProvider.Builder
defaultHttpJsonTransportProviderBuilder() {
return CloudFunctionsServiceStubSettings.defaultHttpJsonTransportProviderBuilder();
}

public static TransportChannelProvider defaultTransportChannelProvider() {
return CloudFunctionsServiceStubSettings.defaultTransportChannelProvider();
}
Expand All @@ -200,11 +208,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return CloudFunctionsServiceStubSettings.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);
Expand Down Expand Up @@ -243,6 +257,11 @@ private static Builder createDefault() {
return new Builder(CloudFunctionsServiceStubSettings.newBuilder());
}

@BetaApi
private static Builder createHttpJsonDefault() {
return new Builder(CloudFunctionsServiceStubSettings.newHttpJsonBuilder());
}

public CloudFunctionsServiceStubSettings.Builder getStubSettingsBuilder() {
return ((CloudFunctionsServiceStubSettings.Builder) getStubSettings());
}
Expand Down
Expand Up @@ -15,7 +15,9 @@
*/

/**
* The interfaces provided are listed below, along with usage samples.
* A client to Cloud Functions API
*
* <p>The interfaces provided are listed below, along with usage samples.
*
* <p>======================= CloudFunctionsServiceClient =======================
*
Expand Down
Expand Up @@ -55,7 +55,11 @@
public abstract class CloudFunctionsServiceStub 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<ListFunctionsRequest, ListFunctionsPagedResponse>
Expand Down