|
| 1 | +package com.google.types.testing; |
| 2 | + |
| 3 | +import com.google.api.gax.core.BackgroundResource; |
| 4 | +import com.google.api.gax.rpc.UnaryCallable; |
| 5 | +import com.google.testgapic.v1beta1.Outer; |
| 6 | +import com.google.types.testing.stub.NestedMessageServiceStub; |
| 7 | +import com.google.types.testing.stub.NestedMessageServiceStubSettings; |
| 8 | +import java.io.IOException; |
| 9 | +import java.util.concurrent.TimeUnit; |
| 10 | +import javax.annotation.Generated; |
| 11 | + |
| 12 | +// AUTO-GENERATED DOCUMENTATION AND CLASS. |
| 13 | +/** |
| 14 | + * This class provides the ability to make remote calls to the backing service through method calls |
| 15 | + * that map to API methods. Sample code to get started: |
| 16 | + * |
| 17 | + * <pre>{@code |
| 18 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 19 | + * // It will require modifications to work: |
| 20 | + * // - It may require correct/in-range values for request initialization. |
| 21 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 22 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 23 | + * try (NestedMessageServiceClient nestedMessageServiceClient = |
| 24 | + * NestedMessageServiceClient.create()) { |
| 25 | + * Outer.Middle request = Outer.Middle.newBuilder().setX(120).build(); |
| 26 | + * Outer.Middle.Inner response = nestedMessageServiceClient.nestedMessageMethod(request); |
| 27 | + * } |
| 28 | + * }</pre> |
| 29 | + * |
| 30 | + * <p>Note: close() needs to be called on the NestedMessageServiceClient object to clean up |
| 31 | + * resources such as threads. In the example above, try-with-resources is used, which automatically |
| 32 | + * calls close(). |
| 33 | + * |
| 34 | + * <p>The surface of this class includes several types of Java methods for each of the API's |
| 35 | + * methods: |
| 36 | + * |
| 37 | + * <ol> |
| 38 | + * <li>A "flattened" method. With this type of method, the fields of the request type have been |
| 39 | + * converted into function parameters. It may be the case that not all fields are available as |
| 40 | + * parameters, and not every API method will have a flattened method entry point. |
| 41 | + * <li>A "request object" method. This type of method only takes one parameter, a request object, |
| 42 | + * which must be constructed before the call. Not every API method will have a request object |
| 43 | + * method. |
| 44 | + * <li>A "callable" method. This type of method takes no parameters and returns an immutable API |
| 45 | + * callable object, which can be used to initiate calls to the service. |
| 46 | + * </ol> |
| 47 | + * |
| 48 | + * <p>See the individual methods for example code. |
| 49 | + * |
| 50 | + * <p>Many parameters require resource names to be formatted in a particular way. To assist with |
| 51 | + * these names, this class includes a format method for each type of name, and additionally a parse |
| 52 | + * method to extract the individual identifiers contained within names that are returned. |
| 53 | + * |
| 54 | + * <p>This class can be customized by passing in a custom instance of NestedMessageServiceSettings |
| 55 | + * to create(). For example: |
| 56 | + * |
| 57 | + * <p>To customize credentials: |
| 58 | + * |
| 59 | + * <pre>{@code |
| 60 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 61 | + * // It will require modifications to work: |
| 62 | + * // - It may require correct/in-range values for request initialization. |
| 63 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 64 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 65 | + * NestedMessageServiceSettings nestedMessageServiceSettings = |
| 66 | + * NestedMessageServiceSettings.newBuilder() |
| 67 | + * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) |
| 68 | + * .build(); |
| 69 | + * NestedMessageServiceClient nestedMessageServiceClient = |
| 70 | + * NestedMessageServiceClient.create(nestedMessageServiceSettings); |
| 71 | + * }</pre> |
| 72 | + * |
| 73 | + * <p>To customize the endpoint: |
| 74 | + * |
| 75 | + * <pre>{@code |
| 76 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 77 | + * // It will require modifications to work: |
| 78 | + * // - It may require correct/in-range values for request initialization. |
| 79 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 80 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 81 | + * NestedMessageServiceSettings nestedMessageServiceSettings = |
| 82 | + * NestedMessageServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); |
| 83 | + * NestedMessageServiceClient nestedMessageServiceClient = |
| 84 | + * NestedMessageServiceClient.create(nestedMessageServiceSettings); |
| 85 | + * }</pre> |
| 86 | + * |
| 87 | + * <p>Please refer to the GitHub repository's samples for more quickstart code snippets. |
| 88 | + */ |
| 89 | +@Generated("by gapic-generator-java") |
| 90 | +public class NestedMessageServiceClient implements BackgroundResource { |
| 91 | + private final NestedMessageServiceSettings settings; |
| 92 | + private final NestedMessageServiceStub stub; |
| 93 | + |
| 94 | + /** Constructs an instance of NestedMessageServiceClient with default settings. */ |
| 95 | + public static final NestedMessageServiceClient create() throws IOException { |
| 96 | + return create(NestedMessageServiceSettings.newBuilder().build()); |
| 97 | + } |
| 98 | + |
| 99 | + /** |
| 100 | + * Constructs an instance of NestedMessageServiceClient, using the given settings. The channels |
| 101 | + * are created based on the settings passed in, or defaults for any settings that are not set. |
| 102 | + */ |
| 103 | + public static final NestedMessageServiceClient create(NestedMessageServiceSettings settings) |
| 104 | + throws IOException { |
| 105 | + return new NestedMessageServiceClient(settings); |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * Constructs an instance of NestedMessageServiceClient, using the given stub for making calls. |
| 110 | + * This is for advanced usage - prefer using create(NestedMessageServiceSettings). |
| 111 | + */ |
| 112 | + public static final NestedMessageServiceClient create(NestedMessageServiceStub stub) { |
| 113 | + return new NestedMessageServiceClient(stub); |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * Constructs an instance of NestedMessageServiceClient, using the given settings. This is |
| 118 | + * protected so that it is easy to make a subclass, but otherwise, the static factory methods |
| 119 | + * should be preferred. |
| 120 | + */ |
| 121 | + protected NestedMessageServiceClient(NestedMessageServiceSettings settings) throws IOException { |
| 122 | + this.settings = settings; |
| 123 | + this.stub = ((NestedMessageServiceStubSettings) settings.getStubSettings()).createStub(); |
| 124 | + } |
| 125 | + |
| 126 | + protected NestedMessageServiceClient(NestedMessageServiceStub stub) { |
| 127 | + this.settings = null; |
| 128 | + this.stub = stub; |
| 129 | + } |
| 130 | + |
| 131 | + public final NestedMessageServiceSettings getSettings() { |
| 132 | + return settings; |
| 133 | + } |
| 134 | + |
| 135 | + public NestedMessageServiceStub getStub() { |
| 136 | + return stub; |
| 137 | + } |
| 138 | + |
| 139 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 140 | + /** |
| 141 | + * Sample code: |
| 142 | + * |
| 143 | + * <pre>{@code |
| 144 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 145 | + * // It will require modifications to work: |
| 146 | + * // - It may require correct/in-range values for request initialization. |
| 147 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 148 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 149 | + * try (NestedMessageServiceClient nestedMessageServiceClient = |
| 150 | + * NestedMessageServiceClient.create()) { |
| 151 | + * Outer.Middle request = Outer.Middle.newBuilder().setX(120).build(); |
| 152 | + * Outer.Middle.Inner response = nestedMessageServiceClient.nestedMessageMethod(request); |
| 153 | + * } |
| 154 | + * }</pre> |
| 155 | + * |
| 156 | + * @param request The request object containing all of the parameters for the API call. |
| 157 | + * @throws com.google.api.gax.rpc.ApiException if the remote call fails |
| 158 | + */ |
| 159 | + public final Outer.Middle.Inner nestedMessageMethod(Outer.Middle request) { |
| 160 | + return nestedMessageMethodCallable().call(request); |
| 161 | + } |
| 162 | + |
| 163 | + // AUTO-GENERATED DOCUMENTATION AND METHOD. |
| 164 | + /** |
| 165 | + * Sample code: |
| 166 | + * |
| 167 | + * <pre>{@code |
| 168 | + * // This snippet has been automatically generated and should be regarded as a code template only. |
| 169 | + * // It will require modifications to work: |
| 170 | + * // - It may require correct/in-range values for request initialization. |
| 171 | + * // - It may require specifying regional endpoints when creating the service client as shown in |
| 172 | + * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library |
| 173 | + * try (NestedMessageServiceClient nestedMessageServiceClient = |
| 174 | + * NestedMessageServiceClient.create()) { |
| 175 | + * Outer.Middle request = Outer.Middle.newBuilder().setX(120).build(); |
| 176 | + * ApiFuture<Outer.Middle.Inner> future = |
| 177 | + * nestedMessageServiceClient.nestedMessageMethodCallable().futureCall(request); |
| 178 | + * // Do something. |
| 179 | + * Outer.Middle.Inner response = future.get(); |
| 180 | + * } |
| 181 | + * }</pre> |
| 182 | + */ |
| 183 | + public final UnaryCallable<Outer.Middle, Outer.Middle.Inner> nestedMessageMethodCallable() { |
| 184 | + return stub.nestedMessageMethodCallable(); |
| 185 | + } |
| 186 | + |
| 187 | + @Override |
| 188 | + public final void close() { |
| 189 | + stub.close(); |
| 190 | + } |
| 191 | + |
| 192 | + @Override |
| 193 | + public void shutdown() { |
| 194 | + stub.shutdown(); |
| 195 | + } |
| 196 | + |
| 197 | + @Override |
| 198 | + public boolean isShutdown() { |
| 199 | + return stub.isShutdown(); |
| 200 | + } |
| 201 | + |
| 202 | + @Override |
| 203 | + public boolean isTerminated() { |
| 204 | + return stub.isTerminated(); |
| 205 | + } |
| 206 | + |
| 207 | + @Override |
| 208 | + public void shutdownNow() { |
| 209 | + stub.shutdownNow(); |
| 210 | + } |
| 211 | + |
| 212 | + @Override |
| 213 | + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { |
| 214 | + return stub.awaitTermination(duration, unit); |
| 215 | + } |
| 216 | +} |
0 commit comments