Skip to content

Commit 35f4278

Browse files
feat: Enable REST transport for most of Java and Go clients (#658)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 456641589 Source-Link: googleapis/googleapis@8a251f5 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9
1 parent b93b0c3 commit 35f4278

File tree

6 files changed

+273
-0
lines changed

6 files changed

+273
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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.mediatranslation.v1beta1.samples;
18+
19+
// [START
20+
// mediatranslation_v1beta1_generated_speechtranslationserviceclient_create_setcredentialsprovider_sync]
21+
import com.google.api.gax.core.FixedCredentialsProvider;
22+
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceClient;
23+
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceSettings;
24+
import com.google.cloud.mediatranslation.v1beta1.myCredentials;
25+
26+
public class SyncCreateSetCredentialsProvider {
27+
28+
public static void main(String[] args) throws Exception {
29+
syncCreateSetCredentialsProvider();
30+
}
31+
32+
public static void syncCreateSetCredentialsProvider() throws Exception {
33+
// This snippet has been automatically generated for illustrative purposes only.
34+
// It may require modifications to work in your environment.
35+
SpeechTranslationServiceSettings speechTranslationServiceSettings =
36+
SpeechTranslationServiceSettings.newBuilder()
37+
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
38+
.build();
39+
SpeechTranslationServiceClient speechTranslationServiceClient =
40+
SpeechTranslationServiceClient.create(speechTranslationServiceSettings);
41+
}
42+
}
43+
// [END
44+
// mediatranslation_v1beta1_generated_speechtranslationserviceclient_create_setcredentialsprovider_sync]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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.mediatranslation.v1beta1.samples;
18+
19+
// [START
20+
// mediatranslation_v1beta1_generated_speechtranslationserviceclient_create_setcredentialsprovider1_sync]
21+
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceClient;
22+
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceSettings;
23+
24+
public class SyncCreateSetCredentialsProvider1 {
25+
26+
public static void main(String[] args) throws Exception {
27+
syncCreateSetCredentialsProvider1();
28+
}
29+
30+
public static void syncCreateSetCredentialsProvider1() throws Exception {
31+
// This snippet has been automatically generated for illustrative purposes only.
32+
// It may require modifications to work in your environment.
33+
SpeechTranslationServiceSettings speechTranslationServiceSettings =
34+
SpeechTranslationServiceSettings.newBuilder()
35+
.setTransportChannelProvider(
36+
SpeechTranslationServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
37+
.build();
38+
SpeechTranslationServiceClient speechTranslationServiceClient =
39+
SpeechTranslationServiceClient.create(speechTranslationServiceSettings);
40+
}
41+
}
42+
// [END
43+
// mediatranslation_v1beta1_generated_speechtranslationserviceclient_create_setcredentialsprovider1_sync]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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.mediatranslation.v1beta1.samples;
18+
19+
// [START mediatranslation_v1beta1_generated_speechtranslationserviceclient_create_setendpoint_sync]
20+
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceClient;
21+
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceSettings;
22+
import com.google.cloud.mediatranslation.v1beta1.myEndpoint;
23+
24+
public class SyncCreateSetEndpoint {
25+
26+
public static void main(String[] args) throws Exception {
27+
syncCreateSetEndpoint();
28+
}
29+
30+
public static void syncCreateSetEndpoint() throws Exception {
31+
// This snippet has been automatically generated for illustrative purposes only.
32+
// It may require modifications to work in your environment.
33+
SpeechTranslationServiceSettings speechTranslationServiceSettings =
34+
SpeechTranslationServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
35+
SpeechTranslationServiceClient speechTranslationServiceClient =
36+
SpeechTranslationServiceClient.create(speechTranslationServiceSettings);
37+
}
38+
}
39+
// [END mediatranslation_v1beta1_generated_speechtranslationserviceclient_create_setendpoint_sync]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.mediatranslation.v1beta1.samples;
18+
19+
// [START
20+
// mediatranslation_v1beta1_generated_speechtranslationserviceclient_streamingtranslatespeech_async]
21+
import com.google.api.gax.rpc.BidiStream;
22+
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceClient;
23+
import com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest;
24+
import com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse;
25+
26+
public class AsyncStreamingTranslateSpeech {
27+
28+
public static void main(String[] args) throws Exception {
29+
asyncStreamingTranslateSpeech();
30+
}
31+
32+
public static void asyncStreamingTranslateSpeech() throws Exception {
33+
// This snippet has been automatically generated for illustrative purposes only.
34+
// It may require modifications to work in your environment.
35+
try (SpeechTranslationServiceClient speechTranslationServiceClient =
36+
SpeechTranslationServiceClient.create()) {
37+
BidiStream<StreamingTranslateSpeechRequest, StreamingTranslateSpeechResponse> bidiStream =
38+
speechTranslationServiceClient.streamingTranslateSpeechCallable().call();
39+
StreamingTranslateSpeechRequest request =
40+
StreamingTranslateSpeechRequest.newBuilder().build();
41+
bidiStream.send(request);
42+
for (StreamingTranslateSpeechResponse response : bidiStream) {
43+
// Do something when a response is received.
44+
}
45+
}
46+
}
47+
}
48+
// [END
49+
// mediatranslation_v1beta1_generated_speechtranslationserviceclient_streamingtranslatespeech_async]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.mediatranslation.v1beta1.samples;
18+
19+
// [START
20+
// mediatranslation_v1beta1_generated_speechtranslationservicesettings_streamingtranslatespeech_sync]
21+
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceSettings;
22+
import java.time.Duration;
23+
24+
public class SyncStreamingTranslateSpeech {
25+
26+
public static void main(String[] args) throws Exception {
27+
syncStreamingTranslateSpeech();
28+
}
29+
30+
public static void syncStreamingTranslateSpeech() throws Exception {
31+
// This snippet has been automatically generated for illustrative purposes only.
32+
// It may require modifications to work in your environment.
33+
SpeechTranslationServiceSettings.Builder speechTranslationServiceSettingsBuilder =
34+
SpeechTranslationServiceSettings.newBuilder();
35+
speechTranslationServiceSettingsBuilder
36+
.streamingTranslateSpeechSettings()
37+
.setRetrySettings(
38+
speechTranslationServiceSettingsBuilder
39+
.streamingTranslateSpeechSettings()
40+
.getRetrySettings()
41+
.toBuilder()
42+
.setTotalTimeout(Duration.ofSeconds(30))
43+
.build());
44+
SpeechTranslationServiceSettings speechTranslationServiceSettings =
45+
speechTranslationServiceSettingsBuilder.build();
46+
}
47+
}
48+
// [END
49+
// mediatranslation_v1beta1_generated_speechtranslationservicesettings_streamingtranslatespeech_sync]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.mediatranslation.v1beta1.stub.samples;
18+
19+
// [START
20+
// mediatranslation_v1beta1_generated_speechtranslationservicestubsettings_streamingtranslatespeech_sync]
21+
import com.google.cloud.mediatranslation.v1beta1.stub.SpeechTranslationServiceStubSettings;
22+
import java.time.Duration;
23+
24+
public class SyncStreamingTranslateSpeech {
25+
26+
public static void main(String[] args) throws Exception {
27+
syncStreamingTranslateSpeech();
28+
}
29+
30+
public static void syncStreamingTranslateSpeech() throws Exception {
31+
// This snippet has been automatically generated for illustrative purposes only.
32+
// It may require modifications to work in your environment.
33+
SpeechTranslationServiceStubSettings.Builder speechTranslationServiceSettingsBuilder =
34+
SpeechTranslationServiceStubSettings.newBuilder();
35+
speechTranslationServiceSettingsBuilder
36+
.streamingTranslateSpeechSettings()
37+
.setRetrySettings(
38+
speechTranslationServiceSettingsBuilder
39+
.streamingTranslateSpeechSettings()
40+
.getRetrySettings()
41+
.toBuilder()
42+
.setTotalTimeout(Duration.ofSeconds(30))
43+
.build());
44+
SpeechTranslationServiceStubSettings speechTranslationServiceSettings =
45+
speechTranslationServiceSettingsBuilder.build();
46+
}
47+
}
48+
// [END
49+
// mediatranslation_v1beta1_generated_speechtranslationservicestubsettings_streamingtranslatespeech_sync]

0 commit comments

Comments
 (0)