-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow empty services and java keywords as a method names (#985)
This is specifically needed to enable `sqladmin` API, which has the following issues: 1) Using `import`, reserved java keyword, as a method name: https://github.com/googleapis/googleapis/blob/master/google/cloud/sql/v1/cloud_sql_instances.proto#L109 2) Has an empty service (no methods whatsoevver) defined: https://github.com/googleapis/googleapis/blob/master/google/cloud/sql/v1/cloud_sql_instance_names.proto#L31 I plan to add a full integration tests with sqladmin (which will also test pure REGAPIC case) once this is pushed (need to integrate these changes first for technical reasons).
- Loading branch information
1 parent
04a6665
commit e37893c
Showing
9 changed files
with
248 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
src/test/java/com/google/api/generator/gapic/composer/grpcrest/goldens/EchoEmpty.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
package com.google.showcase.grpcrest.v1beta1; | ||
|
||
import com.google.api.core.BetaApi; | ||
import com.google.api.gax.core.BackgroundResource; | ||
import com.google.showcase.grpcrest.v1beta1.stub.EchoEmpyStub; | ||
import com.google.showcase.grpcrest.v1beta1.stub.EchoEmpyStubSettings; | ||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
import javax.annotation.Generated; | ||
|
||
// AUTO-GENERATED DOCUMENTATION AND CLASS. | ||
/** | ||
* This class provides the ability to make remote calls to the backing service through method calls | ||
* that map to API methods. Sample code to get started: | ||
* | ||
* <pre>{@code | ||
* // This snippet has been automatically generated for illustrative purposes only. | ||
* // It may require modifications to work in your environment. | ||
* try (EchoEmpyClient echoEmpyClient = EchoEmpyClient.create()) {} | ||
* }</pre> | ||
* | ||
* <p>Note: close() needs to be called on the EchoEmpyClient object to clean up resources such as | ||
* threads. In the example above, try-with-resources is used, which automatically calls close(). | ||
* | ||
* <p>The surface of this class includes several types of Java methods for each of the API's | ||
* methods: | ||
* | ||
* <ol> | ||
* <li>A "flattened" method. With this type of method, the fields of the request type have been | ||
* converted into function parameters. It may be the case that not all fields are available as | ||
* parameters, and not every API method will have a flattened method entry point. | ||
* <li>A "request object" method. This type of method only takes one parameter, a request object, | ||
* which must be constructed before the call. Not every API method will have a request object | ||
* method. | ||
* <li>A "callable" method. This type of method takes no parameters and returns an immutable API | ||
* callable object, which can be used to initiate calls to the service. | ||
* </ol> | ||
* | ||
* <p>See the individual methods for example code. | ||
* | ||
* <p>Many parameters require resource names to be formatted in a particular way. To assist with | ||
* these names, this class includes a format method for each type of name, and additionally a parse | ||
* method to extract the individual identifiers contained within names that are returned. | ||
* | ||
* <p>This class can be customized by passing in a custom instance of EchoEmpySettings to create(). | ||
* For example: | ||
* | ||
* <p>To customize credentials: | ||
* | ||
* <pre>{@code | ||
* // This snippet has been automatically generated for illustrative purposes only. | ||
* // It may require modifications to work in your environment. | ||
* EchoEmpySettings echoEmpySettings = | ||
* EchoEmpySettings.newBuilder() | ||
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) | ||
* .build(); | ||
* EchoEmpyClient echoEmpyClient = EchoEmpyClient.create(echoEmpySettings); | ||
* }</pre> | ||
* | ||
* <p>To customize the endpoint: | ||
* | ||
* <pre>{@code | ||
* // This snippet has been automatically generated for illustrative purposes only. | ||
* // It may require modifications to work in your environment. | ||
* EchoEmpySettings echoEmpySettings = | ||
* EchoEmpySettings.newBuilder().setEndpoint(myEndpoint).build(); | ||
* EchoEmpyClient echoEmpyClient = EchoEmpyClient.create(echoEmpySettings); | ||
* }</pre> | ||
* | ||
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending an 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. | ||
* EchoEmpySettings echoEmpySettings = | ||
* EchoEmpySettings.newBuilder() | ||
* .setTransportChannelProvider( | ||
* EchoEmpySettings.defaultHttpJsonTransportProviderBuilder().build()) | ||
* .build(); | ||
* EchoEmpyClient echoEmpyClient = EchoEmpyClient.create(echoEmpySettings); | ||
* }</pre> | ||
* | ||
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets. | ||
*/ | ||
@BetaApi | ||
@Generated("by gapic-generator-java") | ||
public class EchoEmpyClient implements BackgroundResource { | ||
private final EchoEmpySettings settings; | ||
private final EchoEmpyStub stub; | ||
|
||
/** Constructs an instance of EchoEmpyClient with default settings. */ | ||
public static final EchoEmpyClient create() throws IOException { | ||
return create(EchoEmpySettings.newBuilder().build()); | ||
} | ||
|
||
/** | ||
* Constructs an instance of EchoEmpyClient, using the given settings. The channels are created | ||
* based on the settings passed in, or defaults for any settings that are not set. | ||
*/ | ||
public static final EchoEmpyClient create(EchoEmpySettings settings) throws IOException { | ||
return new EchoEmpyClient(settings); | ||
} | ||
|
||
/** | ||
* Constructs an instance of EchoEmpyClient, using the given stub for making calls. This is for | ||
* advanced usage - prefer using create(EchoEmpySettings). | ||
*/ | ||
@BetaApi("A restructuring of stub classes is planned, so this may break in the future") | ||
public static final EchoEmpyClient create(EchoEmpyStub stub) { | ||
return new EchoEmpyClient(stub); | ||
} | ||
|
||
/** | ||
* Constructs an instance of EchoEmpyClient, 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 EchoEmpyClient(EchoEmpySettings settings) throws IOException { | ||
this.settings = settings; | ||
this.stub = ((EchoEmpyStubSettings) settings.getStubSettings()).createStub(); | ||
} | ||
|
||
@BetaApi("A restructuring of stub classes is planned, so this may break in the future") | ||
protected EchoEmpyClient(EchoEmpyStub stub) { | ||
this.settings = null; | ||
this.stub = stub; | ||
} | ||
|
||
public final EchoEmpySettings getSettings() { | ||
return settings; | ||
} | ||
|
||
@BetaApi("A restructuring of stub classes is planned, so this may break in the future") | ||
public EchoEmpyStub getStub() { | ||
return stub; | ||
} | ||
|
||
@Override | ||
public final void close() { | ||
stub.close(); | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
stub.shutdown(); | ||
} | ||
|
||
@Override | ||
public boolean isShutdown() { | ||
return stub.isShutdown(); | ||
} | ||
|
||
@Override | ||
public boolean isTerminated() { | ||
return stub.isTerminated(); | ||
} | ||
|
||
@Override | ||
public void shutdownNow() { | ||
stub.shutdownNow(); | ||
} | ||
|
||
@Override | ||
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { | ||
return stub.awaitTermination(duration, unit); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters