Skip to content

Commit af85ace

Browse files
feat: [bigquerymigration] Add SQL translation service to Bazel generation (#9165)
* feat: Add SQL translation service to Bazel generation PiperOrigin-RevId: 512937316 Source-Link: googleapis/googleapis@178674c Source-Link: https://github.com/googleapis/googleapis-gen/commit/131f3271256e0a7a2ab96d42540ef05c9cacec7d Copy-Tag: eyJwIjoiamF2YS1iaWdxdWVyeW1pZ3JhdGlvbi8uT3dsQm90LnlhbWwiLCJoIjoiMTMxZjMyNzEyNTZlMGE3YTJhYjk2ZDQyNTQwZWYwNWM5Y2FjZWM3ZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent ef9c246 commit af85ace

File tree

37 files changed

+9498
-5
lines changed

37 files changed

+9498
-5
lines changed

java-bigquerymigration/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,26 @@ Java idiomatic client for [BigQuery Migration][product-docs].
1717

1818
If you are using Maven, add this to your pom.xml file:
1919

20-
<!--- {x-version-update-start:google-cloud-bigquerymigration:released} -->
2120

2221
```xml
2322
<dependency>
2423
<groupId>com.google.cloud</groupId>
2524
<artifactId>google-cloud-bigquerymigration</artifactId>
26-
<version>0.12.0</version>
25+
<version>0.14.0</version>
2726
</dependency>
2827
```
2928

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

3231
```Groovy
33-
implementation 'com.google.cloud:google-cloud-bigquerymigration:0.12.0'
32+
implementation 'com.google.cloud:google-cloud-bigquerymigration:0.14.0'
3433
```
3534

3635
If you are using SBT, add this to your dependencies:
3736

3837
```Scala
39-
libraryDependencies += "com.google.cloud" % "google-cloud-bigquerymigration" % "0.12.0"
38+
libraryDependencies += "com.google.cloud" % "google-cloud-bigquerymigration" % "0.14.0"
4039
```
41-
<!--- {x-version-update-end} -->
4240

4341
## Authentication
4442

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,351 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.bigquery.migration.v2alpha;
18+
19+
import com.google.api.core.BetaApi;
20+
import com.google.api.gax.core.BackgroundResource;
21+
import com.google.api.gax.rpc.UnaryCallable;
22+
import com.google.cloud.bigquery.migration.v2alpha.stub.SqlTranslationServiceStub;
23+
import com.google.cloud.bigquery.migration.v2alpha.stub.SqlTranslationServiceStubSettings;
24+
import java.io.IOException;
25+
import java.util.concurrent.TimeUnit;
26+
import javax.annotation.Generated;
27+
28+
// AUTO-GENERATED DOCUMENTATION AND CLASS.
29+
/**
30+
* Service Description: Provides other SQL dialects to GoogleSQL translation operations.
31+
*
32+
* <p>This class provides the ability to make remote calls to the backing service through method
33+
* calls that map to API methods. Sample code to get started:
34+
*
35+
* <pre>{@code
36+
* // This snippet has been automatically generated and should be regarded as a code template only.
37+
* // It will require modifications to work:
38+
* // - It may require correct/in-range values for request initialization.
39+
* // - It may require specifying regional endpoints when creating the service client as shown in
40+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
41+
* try (SqlTranslationServiceClient sqlTranslationServiceClient =
42+
* SqlTranslationServiceClient.create()) {
43+
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
44+
* TranslateQueryRequest.SqlTranslationSourceDialect sourceDialect =
45+
* TranslateQueryRequest.SqlTranslationSourceDialect.forNumber(0);
46+
* String query = "query107944136";
47+
* TranslateQueryResponse response =
48+
* sqlTranslationServiceClient.translateQuery(parent, sourceDialect, query);
49+
* }
50+
* }</pre>
51+
*
52+
* <p>Note: close() needs to be called on the SqlTranslationServiceClient object to clean up
53+
* resources such as threads. In the example above, try-with-resources is used, which automatically
54+
* calls close().
55+
*
56+
* <p>The surface of this class includes several types of Java methods for each of the API's
57+
* methods:
58+
*
59+
* <ol>
60+
* <li>A "flattened" method. With this type of method, the fields of the request type have been
61+
* converted into function parameters. It may be the case that not all fields are available as
62+
* parameters, and not every API method will have a flattened method entry point.
63+
* <li>A "request object" method. This type of method only takes one parameter, a request object,
64+
* which must be constructed before the call. Not every API method will have a request object
65+
* method.
66+
* <li>A "callable" method. This type of method takes no parameters and returns an immutable API
67+
* callable object, which can be used to initiate calls to the service.
68+
* </ol>
69+
*
70+
* <p>See the individual methods for example code.
71+
*
72+
* <p>Many parameters require resource names to be formatted in a particular way. To assist with
73+
* these names, this class includes a format method for each type of name, and additionally a parse
74+
* method to extract the individual identifiers contained within names that are returned.
75+
*
76+
* <p>This class can be customized by passing in a custom instance of SqlTranslationServiceSettings
77+
* to create(). For example:
78+
*
79+
* <p>To customize credentials:
80+
*
81+
* <pre>{@code
82+
* // This snippet has been automatically generated and should be regarded as a code template only.
83+
* // It will require modifications to work:
84+
* // - It may require correct/in-range values for request initialization.
85+
* // - It may require specifying regional endpoints when creating the service client as shown in
86+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
87+
* SqlTranslationServiceSettings sqlTranslationServiceSettings =
88+
* SqlTranslationServiceSettings.newBuilder()
89+
* .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
90+
* .build();
91+
* SqlTranslationServiceClient sqlTranslationServiceClient =
92+
* SqlTranslationServiceClient.create(sqlTranslationServiceSettings);
93+
* }</pre>
94+
*
95+
* <p>To customize the endpoint:
96+
*
97+
* <pre>{@code
98+
* // This snippet has been automatically generated and should be regarded as a code template only.
99+
* // It will require modifications to work:
100+
* // - It may require correct/in-range values for request initialization.
101+
* // - It may require specifying regional endpoints when creating the service client as shown in
102+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
103+
* SqlTranslationServiceSettings sqlTranslationServiceSettings =
104+
* SqlTranslationServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
105+
* SqlTranslationServiceClient sqlTranslationServiceClient =
106+
* SqlTranslationServiceClient.create(sqlTranslationServiceSettings);
107+
* }</pre>
108+
*
109+
* <p>To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over
110+
* the wire:
111+
*
112+
* <pre>{@code
113+
* // This snippet has been automatically generated and should be regarded as a code template only.
114+
* // It will require modifications to work:
115+
* // - It may require correct/in-range values for request initialization.
116+
* // - It may require specifying regional endpoints when creating the service client as shown in
117+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
118+
* SqlTranslationServiceSettings sqlTranslationServiceSettings =
119+
* SqlTranslationServiceSettings.newHttpJsonBuilder().build();
120+
* SqlTranslationServiceClient sqlTranslationServiceClient =
121+
* SqlTranslationServiceClient.create(sqlTranslationServiceSettings);
122+
* }</pre>
123+
*
124+
* <p>Please refer to the GitHub repository's samples for more quickstart code snippets.
125+
*/
126+
@BetaApi
127+
@Generated("by gapic-generator-java")
128+
public class SqlTranslationServiceClient implements BackgroundResource {
129+
private final SqlTranslationServiceSettings settings;
130+
private final SqlTranslationServiceStub stub;
131+
132+
/** Constructs an instance of SqlTranslationServiceClient with default settings. */
133+
public static final SqlTranslationServiceClient create() throws IOException {
134+
return create(SqlTranslationServiceSettings.newBuilder().build());
135+
}
136+
137+
/**
138+
* Constructs an instance of SqlTranslationServiceClient, using the given settings. The channels
139+
* are created based on the settings passed in, or defaults for any settings that are not set.
140+
*/
141+
public static final SqlTranslationServiceClient create(SqlTranslationServiceSettings settings)
142+
throws IOException {
143+
return new SqlTranslationServiceClient(settings);
144+
}
145+
146+
/**
147+
* Constructs an instance of SqlTranslationServiceClient, using the given stub for making calls.
148+
* This is for advanced usage - prefer using create(SqlTranslationServiceSettings).
149+
*/
150+
public static final SqlTranslationServiceClient create(SqlTranslationServiceStub stub) {
151+
return new SqlTranslationServiceClient(stub);
152+
}
153+
154+
/**
155+
* Constructs an instance of SqlTranslationServiceClient, using the given settings. This is
156+
* protected so that it is easy to make a subclass, but otherwise, the static factory methods
157+
* should be preferred.
158+
*/
159+
protected SqlTranslationServiceClient(SqlTranslationServiceSettings settings) throws IOException {
160+
this.settings = settings;
161+
this.stub = ((SqlTranslationServiceStubSettings) settings.getStubSettings()).createStub();
162+
}
163+
164+
protected SqlTranslationServiceClient(SqlTranslationServiceStub stub) {
165+
this.settings = null;
166+
this.stub = stub;
167+
}
168+
169+
public final SqlTranslationServiceSettings getSettings() {
170+
return settings;
171+
}
172+
173+
public SqlTranslationServiceStub getStub() {
174+
return stub;
175+
}
176+
177+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
178+
/**
179+
* Translates input queries from source dialects to GoogleSQL.
180+
*
181+
* <p>Sample code:
182+
*
183+
* <pre>{@code
184+
* // This snippet has been automatically generated and should be regarded as a code template only.
185+
* // It will require modifications to work:
186+
* // - It may require correct/in-range values for request initialization.
187+
* // - It may require specifying regional endpoints when creating the service client as shown in
188+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
189+
* try (SqlTranslationServiceClient sqlTranslationServiceClient =
190+
* SqlTranslationServiceClient.create()) {
191+
* LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
192+
* TranslateQueryRequest.SqlTranslationSourceDialect sourceDialect =
193+
* TranslateQueryRequest.SqlTranslationSourceDialect.forNumber(0);
194+
* String query = "query107944136";
195+
* TranslateQueryResponse response =
196+
* sqlTranslationServiceClient.translateQuery(parent, sourceDialect, query);
197+
* }
198+
* }</pre>
199+
*
200+
* @param parent Required. The name of the project to which this translation request belongs.
201+
* Example: `projects/foo/locations/bar`
202+
* @param sourceDialect Required. The source SQL dialect of `queries`.
203+
* @param query Required. The query to be translated.
204+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
205+
*/
206+
public final TranslateQueryResponse translateQuery(
207+
LocationName parent,
208+
TranslateQueryRequest.SqlTranslationSourceDialect sourceDialect,
209+
String query) {
210+
TranslateQueryRequest request =
211+
TranslateQueryRequest.newBuilder()
212+
.setParent(parent == null ? null : parent.toString())
213+
.setSourceDialect(sourceDialect)
214+
.setQuery(query)
215+
.build();
216+
return translateQuery(request);
217+
}
218+
219+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
220+
/**
221+
* Translates input queries from source dialects to GoogleSQL.
222+
*
223+
* <p>Sample code:
224+
*
225+
* <pre>{@code
226+
* // This snippet has been automatically generated and should be regarded as a code template only.
227+
* // It will require modifications to work:
228+
* // - It may require correct/in-range values for request initialization.
229+
* // - It may require specifying regional endpoints when creating the service client as shown in
230+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
231+
* try (SqlTranslationServiceClient sqlTranslationServiceClient =
232+
* SqlTranslationServiceClient.create()) {
233+
* String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
234+
* TranslateQueryRequest.SqlTranslationSourceDialect sourceDialect =
235+
* TranslateQueryRequest.SqlTranslationSourceDialect.forNumber(0);
236+
* String query = "query107944136";
237+
* TranslateQueryResponse response =
238+
* sqlTranslationServiceClient.translateQuery(parent, sourceDialect, query);
239+
* }
240+
* }</pre>
241+
*
242+
* @param parent Required. The name of the project to which this translation request belongs.
243+
* Example: `projects/foo/locations/bar`
244+
* @param sourceDialect Required. The source SQL dialect of `queries`.
245+
* @param query Required. The query to be translated.
246+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
247+
*/
248+
public final TranslateQueryResponse translateQuery(
249+
String parent,
250+
TranslateQueryRequest.SqlTranslationSourceDialect sourceDialect,
251+
String query) {
252+
TranslateQueryRequest request =
253+
TranslateQueryRequest.newBuilder()
254+
.setParent(parent)
255+
.setSourceDialect(sourceDialect)
256+
.setQuery(query)
257+
.build();
258+
return translateQuery(request);
259+
}
260+
261+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
262+
/**
263+
* Translates input queries from source dialects to GoogleSQL.
264+
*
265+
* <p>Sample code:
266+
*
267+
* <pre>{@code
268+
* // This snippet has been automatically generated and should be regarded as a code template only.
269+
* // It will require modifications to work:
270+
* // - It may require correct/in-range values for request initialization.
271+
* // - It may require specifying regional endpoints when creating the service client as shown in
272+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
273+
* try (SqlTranslationServiceClient sqlTranslationServiceClient =
274+
* SqlTranslationServiceClient.create()) {
275+
* TranslateQueryRequest request =
276+
* TranslateQueryRequest.newBuilder()
277+
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
278+
* .setQuery("query107944136")
279+
* .build();
280+
* TranslateQueryResponse response = sqlTranslationServiceClient.translateQuery(request);
281+
* }
282+
* }</pre>
283+
*
284+
* @param request The request object containing all of the parameters for the API call.
285+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
286+
*/
287+
public final TranslateQueryResponse translateQuery(TranslateQueryRequest request) {
288+
return translateQueryCallable().call(request);
289+
}
290+
291+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
292+
/**
293+
* Translates input queries from source dialects to GoogleSQL.
294+
*
295+
* <p>Sample code:
296+
*
297+
* <pre>{@code
298+
* // This snippet has been automatically generated and should be regarded as a code template only.
299+
* // It will require modifications to work:
300+
* // - It may require correct/in-range values for request initialization.
301+
* // - It may require specifying regional endpoints when creating the service client as shown in
302+
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
303+
* try (SqlTranslationServiceClient sqlTranslationServiceClient =
304+
* SqlTranslationServiceClient.create()) {
305+
* TranslateQueryRequest request =
306+
* TranslateQueryRequest.newBuilder()
307+
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
308+
* .setQuery("query107944136")
309+
* .build();
310+
* ApiFuture<TranslateQueryResponse> future =
311+
* sqlTranslationServiceClient.translateQueryCallable().futureCall(request);
312+
* // Do something.
313+
* TranslateQueryResponse response = future.get();
314+
* }
315+
* }</pre>
316+
*/
317+
public final UnaryCallable<TranslateQueryRequest, TranslateQueryResponse>
318+
translateQueryCallable() {
319+
return stub.translateQueryCallable();
320+
}
321+
322+
@Override
323+
public final void close() {
324+
stub.close();
325+
}
326+
327+
@Override
328+
public void shutdown() {
329+
stub.shutdown();
330+
}
331+
332+
@Override
333+
public boolean isShutdown() {
334+
return stub.isShutdown();
335+
}
336+
337+
@Override
338+
public boolean isTerminated() {
339+
return stub.isTerminated();
340+
}
341+
342+
@Override
343+
public void shutdownNow() {
344+
stub.shutdownNow();
345+
}
346+
347+
@Override
348+
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
349+
return stub.awaitTermination(duration, unit);
350+
}
351+
}

0 commit comments

Comments
 (0)