Skip to content

Commit

Permalink
feat: Enable REST transport for most of Java and Go clients (#658)
Browse files Browse the repository at this point in the history
- [ ] 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
gcf-owl-bot[bot] authored and averikitsch committed Nov 4, 2022
1 parent 314ba24 commit c78a9a6
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 0 deletions.
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]
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]
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]
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]
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]
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]

0 comments on commit c78a9a6

Please sign in to comment.