-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: googleapis/googleapis-gen@4ca52a5 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9
- Loading branch information
1 parent
314ba24
commit c78a9a6
Showing
6 changed files
with
273 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...ation/v1beta1/speechtranslationserviceclient/create/SyncCreateSetCredentialsProvider.java
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,44 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.mediatranslation.v1beta1.samples; | ||
|
||
// [START | ||
// mediatranslation_v1beta1_generated_speechtranslationserviceclient_create_setcredentialsprovider_sync] | ||
import com.google.api.gax.core.FixedCredentialsProvider; | ||
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceClient; | ||
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceSettings; | ||
import com.google.cloud.mediatranslation.v1beta1.myCredentials; | ||
|
||
public class SyncCreateSetCredentialsProvider { | ||
|
||
public static void main(String[] args) throws Exception { | ||
syncCreateSetCredentialsProvider(); | ||
} | ||
|
||
public static void syncCreateSetCredentialsProvider() throws Exception { | ||
// This snippet has been automatically generated for illustrative purposes only. | ||
// It may require modifications to work in your environment. | ||
SpeechTranslationServiceSettings speechTranslationServiceSettings = | ||
SpeechTranslationServiceSettings.newBuilder() | ||
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) | ||
.build(); | ||
SpeechTranslationServiceClient speechTranslationServiceClient = | ||
SpeechTranslationServiceClient.create(speechTranslationServiceSettings); | ||
} | ||
} | ||
// [END | ||
// mediatranslation_v1beta1_generated_speechtranslationserviceclient_create_setcredentialsprovider_sync] |
43 changes: 43 additions & 0 deletions
43
...tion/v1beta1/speechtranslationserviceclient/create/SyncCreateSetCredentialsProvider1.java
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,43 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.mediatranslation.v1beta1.samples; | ||
|
||
// [START | ||
// mediatranslation_v1beta1_generated_speechtranslationserviceclient_create_setcredentialsprovider1_sync] | ||
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceClient; | ||
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceSettings; | ||
|
||
public class SyncCreateSetCredentialsProvider1 { | ||
|
||
public static void main(String[] args) throws Exception { | ||
syncCreateSetCredentialsProvider1(); | ||
} | ||
|
||
public static void syncCreateSetCredentialsProvider1() throws Exception { | ||
// This snippet has been automatically generated for illustrative purposes only. | ||
// It may require modifications to work in your environment. | ||
SpeechTranslationServiceSettings speechTranslationServiceSettings = | ||
SpeechTranslationServiceSettings.newBuilder() | ||
.setTransportChannelProvider( | ||
SpeechTranslationServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) | ||
.build(); | ||
SpeechTranslationServiceClient speechTranslationServiceClient = | ||
SpeechTranslationServiceClient.create(speechTranslationServiceSettings); | ||
} | ||
} | ||
// [END | ||
// mediatranslation_v1beta1_generated_speechtranslationserviceclient_create_setcredentialsprovider1_sync] |
39 changes: 39 additions & 0 deletions
39
...mediatranslation/v1beta1/speechtranslationserviceclient/create/SyncCreateSetEndpoint.java
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,39 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.mediatranslation.v1beta1.samples; | ||
|
||
// [START mediatranslation_v1beta1_generated_speechtranslationserviceclient_create_setendpoint_sync] | ||
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceClient; | ||
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceSettings; | ||
import com.google.cloud.mediatranslation.v1beta1.myEndpoint; | ||
|
||
public class SyncCreateSetEndpoint { | ||
|
||
public static void main(String[] args) throws Exception { | ||
syncCreateSetEndpoint(); | ||
} | ||
|
||
public static void syncCreateSetEndpoint() throws Exception { | ||
// This snippet has been automatically generated for illustrative purposes only. | ||
// It may require modifications to work in your environment. | ||
SpeechTranslationServiceSettings speechTranslationServiceSettings = | ||
SpeechTranslationServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); | ||
SpeechTranslationServiceClient speechTranslationServiceClient = | ||
SpeechTranslationServiceClient.create(speechTranslationServiceSettings); | ||
} | ||
} | ||
// [END mediatranslation_v1beta1_generated_speechtranslationserviceclient_create_setendpoint_sync] |
49 changes: 49 additions & 0 deletions
49
...peechtranslationserviceclient/streamingtranslatespeech/AsyncStreamingTranslateSpeech.java
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,49 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.mediatranslation.v1beta1.samples; | ||
|
||
// [START | ||
// mediatranslation_v1beta1_generated_speechtranslationserviceclient_streamingtranslatespeech_async] | ||
import com.google.api.gax.rpc.BidiStream; | ||
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceClient; | ||
import com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechRequest; | ||
import com.google.cloud.mediatranslation.v1beta1.StreamingTranslateSpeechResponse; | ||
|
||
public class AsyncStreamingTranslateSpeech { | ||
|
||
public static void main(String[] args) throws Exception { | ||
asyncStreamingTranslateSpeech(); | ||
} | ||
|
||
public static void asyncStreamingTranslateSpeech() throws Exception { | ||
// This snippet has been automatically generated for illustrative purposes only. | ||
// It may require modifications to work in your environment. | ||
try (SpeechTranslationServiceClient speechTranslationServiceClient = | ||
SpeechTranslationServiceClient.create()) { | ||
BidiStream<StreamingTranslateSpeechRequest, StreamingTranslateSpeechResponse> bidiStream = | ||
speechTranslationServiceClient.streamingTranslateSpeechCallable().call(); | ||
StreamingTranslateSpeechRequest request = | ||
StreamingTranslateSpeechRequest.newBuilder().build(); | ||
bidiStream.send(request); | ||
for (StreamingTranslateSpeechResponse response : bidiStream) { | ||
// Do something when a response is received. | ||
} | ||
} | ||
} | ||
} | ||
// [END | ||
// mediatranslation_v1beta1_generated_speechtranslationserviceclient_streamingtranslatespeech_async] |
49 changes: 49 additions & 0 deletions
49
...eechtranslationservicesettings/streamingtranslatespeech/SyncStreamingTranslateSpeech.java
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,49 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.mediatranslation.v1beta1.samples; | ||
|
||
// [START | ||
// mediatranslation_v1beta1_generated_speechtranslationservicesettings_streamingtranslatespeech_sync] | ||
import com.google.cloud.mediatranslation.v1beta1.SpeechTranslationServiceSettings; | ||
import java.time.Duration; | ||
|
||
public class SyncStreamingTranslateSpeech { | ||
|
||
public static void main(String[] args) throws Exception { | ||
syncStreamingTranslateSpeech(); | ||
} | ||
|
||
public static void syncStreamingTranslateSpeech() throws Exception { | ||
// This snippet has been automatically generated for illustrative purposes only. | ||
// It may require modifications to work in your environment. | ||
SpeechTranslationServiceSettings.Builder speechTranslationServiceSettingsBuilder = | ||
SpeechTranslationServiceSettings.newBuilder(); | ||
speechTranslationServiceSettingsBuilder | ||
.streamingTranslateSpeechSettings() | ||
.setRetrySettings( | ||
speechTranslationServiceSettingsBuilder | ||
.streamingTranslateSpeechSettings() | ||
.getRetrySettings() | ||
.toBuilder() | ||
.setTotalTimeout(Duration.ofSeconds(30)) | ||
.build()); | ||
SpeechTranslationServiceSettings speechTranslationServiceSettings = | ||
speechTranslationServiceSettingsBuilder.build(); | ||
} | ||
} | ||
// [END | ||
// mediatranslation_v1beta1_generated_speechtranslationservicesettings_streamingtranslatespeech_sync] |
49 changes: 49 additions & 0 deletions
49
...translationservicestubsettings/streamingtranslatespeech/SyncStreamingTranslateSpeech.java
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,49 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.mediatranslation.v1beta1.stub.samples; | ||
|
||
// [START | ||
// mediatranslation_v1beta1_generated_speechtranslationservicestubsettings_streamingtranslatespeech_sync] | ||
import com.google.cloud.mediatranslation.v1beta1.stub.SpeechTranslationServiceStubSettings; | ||
import java.time.Duration; | ||
|
||
public class SyncStreamingTranslateSpeech { | ||
|
||
public static void main(String[] args) throws Exception { | ||
syncStreamingTranslateSpeech(); | ||
} | ||
|
||
public static void syncStreamingTranslateSpeech() throws Exception { | ||
// This snippet has been automatically generated for illustrative purposes only. | ||
// It may require modifications to work in your environment. | ||
SpeechTranslationServiceStubSettings.Builder speechTranslationServiceSettingsBuilder = | ||
SpeechTranslationServiceStubSettings.newBuilder(); | ||
speechTranslationServiceSettingsBuilder | ||
.streamingTranslateSpeechSettings() | ||
.setRetrySettings( | ||
speechTranslationServiceSettingsBuilder | ||
.streamingTranslateSpeechSettings() | ||
.getRetrySettings() | ||
.toBuilder() | ||
.setTotalTimeout(Duration.ofSeconds(30)) | ||
.build()); | ||
SpeechTranslationServiceStubSettings speechTranslationServiceSettings = | ||
speechTranslationServiceSettingsBuilder.build(); | ||
} | ||
} | ||
// [END | ||
// mediatranslation_v1beta1_generated_speechtranslationservicestubsettings_streamingtranslatespeech_sync] |