diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/AdaptationClient.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/AdaptationClient.java new file mode 100644 index 000000000..023f3f31e --- /dev/null +++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/AdaptationClient.java @@ -0,0 +1,1312 @@ +/* + * Copyright 2020 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.speech.v1p1beta1; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.speech.v1p1beta1.stub.AdaptationStub; +import com.google.cloud.speech.v1p1beta1.stub.AdaptationStubSettings; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Service Description: Service that implements Google Cloud Speech Adaptation API. + * + *
This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + * PhraseSet phraseSet = PhraseSet.newBuilder().build(); + * String phraseSetId = "phraseSetId959902180"; + * PhraseSet response = adaptationClient.createPhraseSet(parent, phraseSet, phraseSetId); + * } + * }+ * + *
Note: close() needs to be called on the AdaptationClient object to clean up resources such as + * threads. In the example above, try-with-resources is used, which automatically calls close(). + * + *
The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *
See the individual methods for example code. + * + *
Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *
This class can be customized by passing in a custom instance of AdaptationSettings to + * create(). For example: + * + *
To customize credentials: + * + *
{@code + * AdaptationSettings adaptationSettings = + * AdaptationSettings.newBuilder() + * .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + * .build(); + * AdaptationClient adaptationClient = AdaptationClient.create(adaptationSettings); + * }+ * + *
To customize the endpoint: + * + *
{@code + * AdaptationSettings adaptationSettings = + * AdaptationSettings.newBuilder().setEndpoint(myEndpoint).build(); + * AdaptationClient adaptationClient = AdaptationClient.create(adaptationSettings); + * }+ * + *
Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class AdaptationClient implements BackgroundResource { + private final AdaptationSettings settings; + private final AdaptationStub stub; + + /** Constructs an instance of AdaptationClient with default settings. */ + public static final AdaptationClient create() throws IOException { + return create(AdaptationSettings.newBuilder().build()); + } + + /** + * Constructs an instance of AdaptationClient, using the given settings. The channels are created + * based on the settings passed in, or defaults for any settings that are not set. + */ + public static final AdaptationClient create(AdaptationSettings settings) throws IOException { + return new AdaptationClient(settings); + } + + /** + * Constructs an instance of AdaptationClient, using the given stub for making calls. This is for + * advanced usage - prefer using create(AdaptationSettings). + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final AdaptationClient create(AdaptationStub stub) { + return new AdaptationClient(stub); + } + + /** + * Constructs an instance of AdaptationClient, using the given settings. This is protected so that + * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected AdaptationClient(AdaptationSettings settings) throws IOException { + this.settings = settings; + this.stub = ((AdaptationStubSettings) settings.getStubSettings()).createStub(); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected AdaptationClient(AdaptationStub stub) { + this.settings = null; + this.stub = stub; + } + + public final AdaptationSettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public AdaptationStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. + * The items in the PhraseSet are favored by the recognition model when you send a call that + * includes the PhraseSet. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + * PhraseSet phraseSet = PhraseSet.newBuilder().build(); + * String phraseSetId = "phraseSetId959902180"; + * PhraseSet response = adaptationClient.createPhraseSet(parent, phraseSet, phraseSetId); + * } + * }+ * + * @param parent Required. The parent resource where this phrase set will be created. Format: + * {api_version}/projects/{project}/locations/{location}/phraseSets + * @param phraseSet Required. The phrase set to create. + * @param phraseSetId The ID to use for the phrase set, which will become the final component of + * the phrase set's resource name. + *
This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final PhraseSet createPhraseSet( + LocationName parent, PhraseSet phraseSet, String phraseSetId) { + CreatePhraseSetRequest request = + CreatePhraseSetRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setPhraseSet(phraseSet) + .setPhraseSetId(phraseSetId) + .build(); + return createPhraseSet(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. + * The items in the PhraseSet are favored by the recognition model when you send a call that + * includes the PhraseSet. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * String parent = PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString(); + * PhraseSet phraseSet = PhraseSet.newBuilder().build(); + * String phraseSetId = "phraseSetId959902180"; + * PhraseSet response = adaptationClient.createPhraseSet(parent, phraseSet, phraseSetId); + * } + * }+ * + * @param parent Required. The parent resource where this phrase set will be created. Format: + * {api_version}/projects/{project}/locations/{location}/phraseSets + * @param phraseSet Required. The phrase set to create. + * @param phraseSetId The ID to use for the phrase set, which will become the final component of + * the phrase set's resource name. + *
This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final PhraseSet createPhraseSet(String parent, PhraseSet phraseSet, String phraseSetId) { + CreatePhraseSetRequest request = + CreatePhraseSetRequest.newBuilder() + .setParent(parent) + .setPhraseSet(phraseSet) + .setPhraseSetId(phraseSetId) + .build(); + return createPhraseSet(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. + * The items in the PhraseSet are favored by the recognition model when you send a call that + * includes the PhraseSet. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * CreatePhraseSetRequest request = + * CreatePhraseSetRequest.newBuilder() + * .setParent(PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString()) + * .setPhraseSetId("phraseSetId959902180") + * .setPhraseSet(PhraseSet.newBuilder().build()) + * .build(); + * PhraseSet response = adaptationClient.createPhraseSet(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final PhraseSet createPhraseSet(CreatePhraseSetRequest request) { + return createPhraseSetCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a set of phrase hints. Each item in the set can be a single word or a multi-word phrase. + * The items in the PhraseSet are favored by the recognition model when you send a call that + * includes the PhraseSet. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * CreatePhraseSetRequest request = + * CreatePhraseSetRequest.newBuilder() + * .setParent(PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString()) + * .setPhraseSetId("phraseSetId959902180") + * .setPhraseSet(PhraseSet.newBuilder().build()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = adaptationClient.createPhraseSetCallable().futureCall(request); + * // Do something. + * PhraseSet response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * PhraseSetName name = PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]"); + * PhraseSet response = adaptationClient.getPhraseSet(name); + * } + * }+ * + * @param name Required. The name of the phrase set to retrieve. Format: + * {api_version}/projects/{project}/locations/{location}/phraseSets/{phrase_set} + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final PhraseSet getPhraseSet(PhraseSetName name) { + GetPhraseSetRequest request = + GetPhraseSetRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getPhraseSet(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Get a phrase set. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * String name = PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString(); + * PhraseSet response = adaptationClient.getPhraseSet(name); + * } + * }+ * + * @param name Required. The name of the phrase set to retrieve. Format: + * {api_version}/projects/{project}/locations/{location}/phraseSets/{phrase_set} + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final PhraseSet getPhraseSet(String name) { + GetPhraseSetRequest request = GetPhraseSetRequest.newBuilder().setName(name).build(); + return getPhraseSet(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Get a phrase set. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * GetPhraseSetRequest request = + * GetPhraseSetRequest.newBuilder() + * .setName(PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString()) + * .build(); + * PhraseSet response = adaptationClient.getPhraseSet(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final PhraseSet getPhraseSet(GetPhraseSetRequest request) { + return getPhraseSetCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Get a phrase set. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * GetPhraseSetRequest request = + * GetPhraseSetRequest.newBuilder() + * .setName(PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = adaptationClient.getPhraseSetCallable().futureCall(request); + * // Do something. + * PhraseSet response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + * for (PhraseSet element : adaptationClient.listPhraseSet(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. The parent, which owns this collection of phrase set. Format: + * projects/{project}/locations/{location} + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListPhraseSetPagedResponse listPhraseSet(LocationName parent) { + ListPhraseSetRequest request = + ListPhraseSetRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listPhraseSet(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List phrase sets. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * String parent = PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString(); + * for (PhraseSet element : adaptationClient.listPhraseSet(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. The parent, which owns this collection of phrase set. Format: + * projects/{project}/locations/{location} + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListPhraseSetPagedResponse listPhraseSet(String parent) { + ListPhraseSetRequest request = ListPhraseSetRequest.newBuilder().setParent(parent).build(); + return listPhraseSet(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List phrase sets. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * ListPhraseSetRequest request = + * ListPhraseSetRequest.newBuilder() + * .setParent(PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * for (PhraseSet element : adaptationClient.listPhraseSet(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListPhraseSetPagedResponse listPhraseSet(ListPhraseSetRequest request) { + return listPhraseSetPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List phrase sets. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * ListPhraseSetRequest request = + * ListPhraseSetRequest.newBuilder() + * .setParent(PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = + * adaptationClient.listPhraseSetPagedCallable().futureCall(request); + * // Do something. + * for (PhraseSet element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * while (true) { + * ListPhraseSetResponse response = adaptationClient.listPhraseSetCallable().call(request); + * for (PhraseSet element : response.getResponsesList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }+ */ + public final UnaryCallable
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * UpdatePhraseSetRequest request = + * UpdatePhraseSetRequest.newBuilder() + * .setPhraseSet(PhraseSet.newBuilder().build()) + * .setUpdateMask(FieldMask.newBuilder().build()) + * .build(); + * PhraseSet response = adaptationClient.updatePhraseSet(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final PhraseSet updatePhraseSet(UpdatePhraseSetRequest request) { + return updatePhraseSetCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Update a phrase set. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * UpdatePhraseSetRequest request = + * UpdatePhraseSetRequest.newBuilder() + * .setPhraseSet(PhraseSet.newBuilder().build()) + * .setUpdateMask(FieldMask.newBuilder().build()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = adaptationClient.updatePhraseSetCallable().futureCall(request); + * // Do something. + * PhraseSet response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * PhraseSetName name = PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]"); + * adaptationClient.deletePhraseSet(name); + * } + * }+ * + * @param name Required. The name of the phrase set to delete. Format: + * {api_version}/projects/{project}/locations/{location}/phraseSets/{phrase_set} + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deletePhraseSet(PhraseSetName name) { + DeletePhraseSetRequest request = + DeletePhraseSetRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deletePhraseSet(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Delete a phrase set. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * String name = PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString(); + * adaptationClient.deletePhraseSet(name); + * } + * }+ * + * @param name Required. The name of the phrase set to delete. Format: + * {api_version}/projects/{project}/locations/{location}/phraseSets/{phrase_set} + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deletePhraseSet(String name) { + DeletePhraseSetRequest request = DeletePhraseSetRequest.newBuilder().setName(name).build(); + deletePhraseSet(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Delete a phrase set. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * DeletePhraseSetRequest request = + * DeletePhraseSetRequest.newBuilder() + * .setName(PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString()) + * .build(); + * adaptationClient.deletePhraseSet(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deletePhraseSet(DeletePhraseSetRequest request) { + deletePhraseSetCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Delete a phrase set. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * DeletePhraseSetRequest request = + * DeletePhraseSetRequest.newBuilder() + * .setName(PhraseSetName.of("[PROJECT]", "[LOCATION]", "[PHRASE_SET]").toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = adaptationClient.deletePhraseSetCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + * CustomClass customClass = CustomClass.newBuilder().build(); + * String customClassId = "customClassId1871032322"; + * CustomClass response = adaptationClient.createCustomClass(parent, customClass, customClassId); + * } + * }+ * + * @param parent Required. The parent resource where this custom class will be created. Format: + * {api_version}/projects/{project}/locations/{location}/customClasses + * @param customClass Required. The custom class to create. + * @param customClassId The ID to use for the custom class, which will become the final component + * of the custom class' resource name. + *
This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final CustomClass createCustomClass( + LocationName parent, CustomClass customClass, String customClassId) { + CreateCustomClassRequest request = + CreateCustomClassRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setCustomClass(customClass) + .setCustomClassId(customClassId) + .build(); + return createCustomClass(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a custom class. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * String parent = CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString(); + * CustomClass customClass = CustomClass.newBuilder().build(); + * String customClassId = "customClassId1871032322"; + * CustomClass response = adaptationClient.createCustomClass(parent, customClass, customClassId); + * } + * }+ * + * @param parent Required. The parent resource where this custom class will be created. Format: + * {api_version}/projects/{project}/locations/{location}/customClasses + * @param customClass Required. The custom class to create. + * @param customClassId The ID to use for the custom class, which will become the final component + * of the custom class' resource name. + *
This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final CustomClass createCustomClass( + String parent, CustomClass customClass, String customClassId) { + CreateCustomClassRequest request = + CreateCustomClassRequest.newBuilder() + .setParent(parent) + .setCustomClass(customClass) + .setCustomClassId(customClassId) + .build(); + return createCustomClass(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a custom class. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * CreateCustomClassRequest request = + * CreateCustomClassRequest.newBuilder() + * .setParent(CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString()) + * .setCustomClassId("customClassId1871032322") + * .setCustomClass(CustomClass.newBuilder().build()) + * .build(); + * CustomClass response = adaptationClient.createCustomClass(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final CustomClass createCustomClass(CreateCustomClassRequest request) { + return createCustomClassCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a custom class. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * CreateCustomClassRequest request = + * CreateCustomClassRequest.newBuilder() + * .setParent(CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString()) + * .setCustomClassId("customClassId1871032322") + * .setCustomClass(CustomClass.newBuilder().build()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = + * adaptationClient.createCustomClassCallable().futureCall(request); + * // Do something. + * CustomClass response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * CustomClassName name = CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]"); + * CustomClass response = adaptationClient.getCustomClass(name); + * } + * }+ * + * @param name Required. The name of the custom class to retrieve. Format: + * {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class} + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final CustomClass getCustomClass(CustomClassName name) { + GetCustomClassRequest request = + GetCustomClassRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getCustomClass(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Get a custom class. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * String name = CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString(); + * CustomClass response = adaptationClient.getCustomClass(name); + * } + * }+ * + * @param name Required. The name of the custom class to retrieve. Format: + * {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class} + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final CustomClass getCustomClass(String name) { + GetCustomClassRequest request = GetCustomClassRequest.newBuilder().setName(name).build(); + return getCustomClass(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Get a custom class. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * GetCustomClassRequest request = + * GetCustomClassRequest.newBuilder() + * .setName(CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString()) + * .build(); + * CustomClass response = adaptationClient.getCustomClass(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final CustomClass getCustomClass(GetCustomClassRequest request) { + return getCustomClassCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Get a custom class. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * GetCustomClassRequest request = + * GetCustomClassRequest.newBuilder() + * .setName(CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = adaptationClient.getCustomClassCallable().futureCall(request); + * // Do something. + * CustomClass response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + * for (CustomClass element : adaptationClient.listCustomClasses(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. The parent, which owns this collection of custom classes. Format: + * {api_version}/projects/{project}/locations/{location}/customClasses + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListCustomClassesPagedResponse listCustomClasses(LocationName parent) { + ListCustomClassesRequest request = + ListCustomClassesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listCustomClasses(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List custom classes. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * String parent = CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString(); + * for (CustomClass element : adaptationClient.listCustomClasses(parent).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param parent Required. The parent, which owns this collection of custom classes. Format: + * {api_version}/projects/{project}/locations/{location}/customClasses + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListCustomClassesPagedResponse listCustomClasses(String parent) { + ListCustomClassesRequest request = + ListCustomClassesRequest.newBuilder().setParent(parent).build(); + return listCustomClasses(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List custom classes. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * ListCustomClassesRequest request = + * ListCustomClassesRequest.newBuilder() + * .setParent(CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * for (CustomClass element : adaptationClient.listCustomClasses(request).iterateAll()) { + * // doThingsWith(element); + * } + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListCustomClassesPagedResponse listCustomClasses(ListCustomClassesRequest request) { + return listCustomClassesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List custom classes. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * ListCustomClassesRequest request = + * ListCustomClassesRequest.newBuilder() + * .setParent(CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString()) + * .setPageSize(883849137) + * .setPageToken("pageToken873572522") + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = + * adaptationClient.listCustomClassesPagedCallable().futureCall(request); + * // Do something. + * for (CustomClass element : future.get().iterateAll()) { + * // doThingsWith(element); + * } + * } + * }
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * while (true) { + * ListCustomClassesResponse response = + * adaptationClient.listCustomClassesCallable().call(request); + * for (CustomClass element : response.getResponsesList()) { + * // doThingsWith(element); + * } + * String nextPageToken = response.getNextPageToken(); + * if (!Strings.isNullOrEmpty(nextPageToken)) { + * request = request.toBuilder().setPageToken(nextPageToken).build(); + * } else { + * break; + * } + * } + * } + * }+ */ + public final UnaryCallable
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * UpdateCustomClassRequest request = + * UpdateCustomClassRequest.newBuilder() + * .setCustomClass(CustomClass.newBuilder().build()) + * .setUpdateMask(FieldMask.newBuilder().build()) + * .build(); + * CustomClass response = adaptationClient.updateCustomClass(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final CustomClass updateCustomClass(UpdateCustomClassRequest request) { + return updateCustomClassCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Update a custom class. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * UpdateCustomClassRequest request = + * UpdateCustomClassRequest.newBuilder() + * .setCustomClass(CustomClass.newBuilder().build()) + * .setUpdateMask(FieldMask.newBuilder().build()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = + * adaptationClient.updateCustomClassCallable().futureCall(request); + * // Do something. + * CustomClass response = future.get(); + * } + * }
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * CustomClassName name = CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]"); + * adaptationClient.deleteCustomClass(name); + * } + * }+ * + * @param name Required. The name of the custom class to delete. Format: + * {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class} + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteCustomClass(CustomClassName name) { + DeleteCustomClassRequest request = + DeleteCustomClassRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + deleteCustomClass(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Delete a custom class. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * String name = CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString(); + * adaptationClient.deleteCustomClass(name); + * } + * }+ * + * @param name Required. The name of the custom class to delete. Format: + * {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class} + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteCustomClass(String name) { + DeleteCustomClassRequest request = DeleteCustomClassRequest.newBuilder().setName(name).build(); + deleteCustomClass(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Delete a custom class. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * DeleteCustomClassRequest request = + * DeleteCustomClassRequest.newBuilder() + * .setName(CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString()) + * .build(); + * adaptationClient.deleteCustomClass(request); + * } + * }+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteCustomClass(DeleteCustomClassRequest request) { + deleteCustomClassCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Delete a custom class. + * + *
Sample code: + * + *
{@code + * try (AdaptationClient adaptationClient = AdaptationClient.create()) { + * DeleteCustomClassRequest request = + * DeleteCustomClassRequest.newBuilder() + * .setName(CustomClassName.of("[PROJECT]", "[LOCATION]", "[CUSTOM_CLASS]").toString()) + * .build(); + * ApiFuture+ */ + public final UnaryCallablefuture = adaptationClient.deleteCustomClassCallable().futureCall(request); + * // Do something. + * future.get(); + * } + * }
The default instance has everything set to sensible defaults: + * + *
The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *
For example, to set the total timeout of createPhraseSet to 30 seconds: + * + *
{@code + * AdaptationSettings.Builder adaptationSettingsBuilder = AdaptationSettings.newBuilder(); + * adaptationSettingsBuilder + * .createPhraseSetSettings() + * .setRetrySettings( + * adaptationSettingsBuilder + * .createPhraseSetSettings() + * .getRetrySettings() + * .toBuilder() + * .setTotalTimeout(Duration.ofSeconds(30)) + * .build()); + * AdaptationSettings adaptationSettings = adaptationSettingsBuilder.build(); + * }+ */ +@BetaApi +@Generated("by gapic-generator-java") +public class AdaptationSettings extends ClientSettings
Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction ======================= AdaptationClient =======================
+ *
+ * Service Description: Service that implements Google Cloud Speech Adaptation API.
+ *
+ * Sample for AdaptationClient:
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public abstract class AdaptationStub implements BackgroundResource {
+
+ public UnaryCallable The default instance has everything set to sensible defaults:
+ *
+ * The builder of this class is recursive, so contained classes are themselves builders. When
+ * build() is called, the tree of builders is called to create the complete settings object.
+ *
+ * For example, to set the total timeout of createPhraseSet to 30 seconds:
+ *
+ * Note: This method does not support applying settings to streaming methods.
+ */
+ public Builder applyToAllUnaryMethods(
+ ApiFunction This class is for advanced usage.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class GrpcAdaptationCallableFactory implements GrpcStubCallableFactory {
+
+ @Override
+ public This class is for advanced usage and reflects the underlying API directly.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class GrpcAdaptationStub extends AdaptationStub {
+ private static final MethodDescriptor{@code
+ * try (AdaptationClient adaptationClient = AdaptationClient.create()) {
+ * LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+ * PhraseSet phraseSet = PhraseSet.newBuilder().build();
+ * String phraseSetId = "phraseSetId959902180";
+ * PhraseSet response = adaptationClient.createPhraseSet(parent, phraseSet, phraseSetId);
+ * }
+ * }
*/
@Generated("by gapic-generator-java")
package com.google.cloud.speech.v1p1beta1;
diff --git a/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/AdaptationStub.java b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/AdaptationStub.java
new file mode 100644
index 000000000..4ee410425
--- /dev/null
+++ b/google-cloud-speech/src/main/java/com/google/cloud/speech/v1p1beta1/stub/AdaptationStub.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2020 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.speech.v1p1beta1.stub;
+
+import static com.google.cloud.speech.v1p1beta1.AdaptationClient.ListCustomClassesPagedResponse;
+import static com.google.cloud.speech.v1p1beta1.AdaptationClient.ListPhraseSetPagedResponse;
+
+import com.google.api.core.BetaApi;
+import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.rpc.UnaryCallable;
+import com.google.cloud.speech.v1p1beta1.CreateCustomClassRequest;
+import com.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest;
+import com.google.cloud.speech.v1p1beta1.CustomClass;
+import com.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest;
+import com.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest;
+import com.google.cloud.speech.v1p1beta1.GetCustomClassRequest;
+import com.google.cloud.speech.v1p1beta1.GetPhraseSetRequest;
+import com.google.cloud.speech.v1p1beta1.ListCustomClassesRequest;
+import com.google.cloud.speech.v1p1beta1.ListCustomClassesResponse;
+import com.google.cloud.speech.v1p1beta1.ListPhraseSetRequest;
+import com.google.cloud.speech.v1p1beta1.ListPhraseSetResponse;
+import com.google.cloud.speech.v1p1beta1.PhraseSet;
+import com.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest;
+import com.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest;
+import com.google.protobuf.Empty;
+import javax.annotation.Generated;
+
+// AUTO-GENERATED DOCUMENTATION AND CLASS.
+/**
+ * Base stub class for the Adaptation service API.
+ *
+ *
+ *
+ *
+ * {@code
+ * AdaptationStubSettings.Builder adaptationSettingsBuilder = AdaptationStubSettings.newBuilder();
+ * adaptationSettingsBuilder
+ * .createPhraseSetSettings()
+ * .setRetrySettings(
+ * adaptationSettingsBuilder
+ * .createPhraseSetSettings()
+ * .getRetrySettings()
+ * .toBuilder()
+ * .setTotalTimeout(Duration.ofSeconds(30))
+ * .build());
+ * AdaptationStubSettings adaptationSettings = adaptationSettingsBuilder.build();
+ * }
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class AdaptationStubSettings extends StubSettings