diff --git a/packages/google-cloud-node/package.json b/packages/google-cloud-node/package.json index 278d3203a389..6ae486b08784 100644 --- a/packages/google-cloud-node/package.json +++ b/packages/google-cloud-node/package.json @@ -38,7 +38,8 @@ "docs-test": "linkinator docs", "predocs-test": "npm run docs", "compile": "tsc -p . && cp system-test/*.js build/system-test/ && cp -r protos build/", - "prepare": "npm run compile", + "compile-protos": "compileProtos src", + "prepare": "npm run compile-protos && npm run compile", "pretest": "npm run compile", "prelint": "cd samples; npm link ../; npm install", "clean": "gts clean", diff --git a/packages/google-cloud-node/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto b/packages/google-cloud-node/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto index 7bb12866b63a..3eccfb661513 100644 --- a/packages/google-cloud-node/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto +++ b/packages/google-cloud-node/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -139,6 +139,16 @@ message StreamingRecognitionConfig { // `END_OF_SINGLE_UTTERANCE` event and cease recognition. It will return no // more than one `StreamingRecognitionResult` with the `is_final` flag set to // `true`. + // + // The `single_utterance` field can only be used with specified models, + // otherwise an error is thrown. The `model` field in [`RecognitionConfig`][] + // must be set to: + // + // * `command_and_search` + // * `phone_call` AND additional field `useEnhanced`=`true` + // * The `model` field is left undefined. In this case the API auto-selects + // a model based on any other parameters that you set in + // `RecognitionConfig`. bool single_utterance = 2; // If `true`, interim results (tentative hypotheses) may be @@ -218,7 +228,8 @@ message RecognitionConfig { // wideband is supported. `sample_rate_hertz` must be 16000. SPEEX_WITH_HEADER_BYTE = 7; - // MP3 audio. Support all standard MP3 bitrates (which range from 32-320 + // MP3 audio. MP3 encoding is a Beta feature and only available in + // v1p1beta1. Support all standard MP3 bitrates (which range from 32-320 // kbps). When using this encoding, `sample_rate_hertz` has to match the // sample rate of the file being used. MP3 = 8; @@ -635,8 +646,8 @@ message LongRunningRecognizeMetadata { // Time of the most recent processing update. google.protobuf.Timestamp last_update_time = 3; - // The URI of the audio file being transcribed. Empty if the audio was sent - // as byte content. + // Output only. The URI of the audio file being transcribed. Empty if the + // audio was sent as byte content. string uri = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; } diff --git a/packages/google-cloud-node/protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto b/packages/google-cloud-node/protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto new file mode 100644 index 000000000000..4e4377c9c38a --- /dev/null +++ b/packages/google-cloud-node/protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto @@ -0,0 +1,318 @@ +// Copyright 2021 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 +// +// http://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. + +syntax = "proto3"; + +package google.cloud.speech.v1p1beta1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/speech/v1p1beta1/resource.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1p1beta1;speech"; +option java_multiple_files = true; +option java_outer_classname = "SpeechAdaptationProto"; +option java_package = "com.google.cloud.speech.v1p1beta1"; +option objc_class_prefix = "GCS"; + +// Service that implements Google Cloud Speech Adaptation API. +service Adaptation { + option (google.api.default_host) = "speech.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // 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. + rpc CreatePhraseSet(CreatePhraseSetRequest) returns (PhraseSet) { + option (google.api.http) = { + post: "/v1p1beta1/{parent=projects/*/locations/*}/phraseSets" + body: "*" + }; + option (google.api.method_signature) = "parent,phrase_set,phrase_set_id"; + } + + // Get a phrase set. + rpc GetPhraseSet(GetPhraseSetRequest) returns (PhraseSet) { + option (google.api.http) = { + get: "/v1p1beta1/{name=projects/*/locations/*/phraseSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List phrase sets. + rpc ListPhraseSet(ListPhraseSetRequest) returns (ListPhraseSetResponse) { + option (google.api.http) = { + get: "/v1p1beta1/{parent=projects/*/locations/*}/phraseSets" + }; + option (google.api.method_signature) = "parent"; + } + + // Update a phrase set. + rpc UpdatePhraseSet(UpdatePhraseSetRequest) returns (PhraseSet) { + option (google.api.http) = { + patch: "/v1p1beta1/{phrase_set.name=projects/*/locations/*/phraseSets/*}" + body: "phrase_set" + }; + } + + // Delete a phrase set. + rpc DeletePhraseSet(DeletePhraseSetRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p1beta1/{name=projects/*/locations/*/phraseSets/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Create a custom class. + rpc CreateCustomClass(CreateCustomClassRequest) returns (CustomClass) { + option (google.api.http) = { + post: "/v1p1beta1/{parent=projects/*/locations/*}/customClasses" + body: "*" + }; + option (google.api.method_signature) = "parent,custom_class,custom_class_id"; + } + + // Get a custom class. + rpc GetCustomClass(GetCustomClassRequest) returns (CustomClass) { + option (google.api.http) = { + get: "/v1p1beta1/{name=projects/*/locations/*/customClasses/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List custom classes. + rpc ListCustomClasses(ListCustomClassesRequest) returns (ListCustomClassesResponse) { + option (google.api.http) = { + get: "/v1p1beta1/{parent=projects/*/locations/*}/customClasses" + }; + option (google.api.method_signature) = "parent"; + } + + // Update a custom class. + rpc UpdateCustomClass(UpdateCustomClassRequest) returns (CustomClass) { + option (google.api.http) = { + patch: "/v1p1beta1/{custom_class.name=projects/*/locations/*/customClasses/*}" + body: "custom_class" + }; + } + + // Delete a custom class. + rpc DeleteCustomClass(DeleteCustomClassRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1p1beta1/{name=projects/*/locations/*/customClasses/*}" + }; + option (google.api.method_signature) = "name"; + } +} + +// Message sent by the client for the `CreatePhraseSet` method. +message CreatePhraseSetRequest { + // Required. The parent resource where this phrase set will be created. + // Format: + // {api_version}/projects/{project}/locations/{location}/phraseSets + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/PhraseSet" + } + ]; + + // 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]-/. + string phrase_set_id = 2; + + // Required. The phrase set to create. + PhraseSet phrase_set = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Message sent by the client for the `UpdatePhraseSet` method. +message UpdatePhraseSetRequest { + // Required. The phrase set to update. + // + // The phrase set's `name` field is used to identify the set to be + // updated. Format: + // {api_version}/projects/{project}/locations/{location}/phraseSets/{phrase_set} + PhraseSet phrase_set = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Message sent by the client for the `GetPhraseSet` method. +message GetPhraseSetRequest { + // Required. The name of the phrase set to retrieve. + // Format: + // {api_version}/projects/{project}/locations/{location}/phraseSets/{phrase_set} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/PhraseSet" + } + ]; +} + +// Message sent by the client for the `ListPhraseSet` method. +message ListPhraseSetRequest { + // Required. The parent, which owns this collection of phrase set. + // Format: + // projects/{project}/locations/{location} + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/PhraseSet" + } + ]; + + // The maximum number of phrase sets to return. The service may return + // fewer than this value. If unspecified, at most 50 phrase sets will be + // returned. The maximum value is 1000; values above 1000 will be coerced to + // 1000. + int32 page_size = 2; + + // A page token, received from a previous `ListPhraseSet` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to `ListPhraseSet` must + // match the call that provided the page token. + string page_token = 3; +} + +// Message returned to the client by the `ListPhraseSet` method. +message ListPhraseSetResponse { + // The phrase set. + repeated PhraseSet phrase_sets = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// Message sent by the client for the `DeletePhraseSet` method. +message DeletePhraseSetRequest { + // Required. The name of the phrase set to delete. + // Format: + // {api_version}/projects/{project}/locations/{location}/phraseSets/{phrase_set} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/PhraseSet" + } + ]; +} + +// Message sent by the client for the `CreateCustomClass` method. +message CreateCustomClassRequest { + // Required. The parent resource where this custom class will be created. + // Format: + // {api_version}/projects/{project}/locations/{location}/customClasses + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/CustomClass" + } + ]; + + // 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]-/. + string custom_class_id = 2; + + // Required. The custom class to create. + CustomClass custom_class = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Message sent by the client for the `UpdateCustomClass` method. +message UpdateCustomClassRequest { + // Required. The custom class to update. + // + // The custom class's `name` field is used to identify the custom class to be + // updated. Format: + // {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class} + CustomClass custom_class = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Message sent by the client for the `GetCustomClass` method. +message GetCustomClassRequest { + // Required. The name of the custom class to retrieve. + // Format: + // {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/CustomClass" + } + ]; +} + +// Message sent by the client for the `ListCustomClasses` method. +message ListCustomClassesRequest { + // Required. The parent, which owns this collection of custom classes. + // Format: + // {api_version}/projects/{project}/locations/{location}/customClasses + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "speech.googleapis.com/CustomClass" + } + ]; + + // The maximum number of custom classes to return. The service may return + // fewer than this value. If unspecified, at most 50 custom classes will be + // returned. The maximum value is 1000; values above 1000 will be coerced to + // 1000. + int32 page_size = 2; + + // A page token, received from a previous `ListCustomClass` call. + // Provide this to retrieve the subsequent page. + // + // When paginating, all other parameters provided to `ListCustomClass` must + // match the call that provided the page token. + string page_token = 3; +} + +// Message returned to the client by the `ListCustomClasses` method. +message ListCustomClassesResponse { + // The custom classes. + repeated CustomClass custom_classes = 1; + + // A token, which can be sent as `page_token` to retrieve the next page. + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// Message sent by the client for the `DeleteCustomClass` method. +message DeleteCustomClassRequest { + // Required. The name of the custom class to delete. + // Format: + // {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class} + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "speech.googleapis.com/CustomClass" + } + ]; +} diff --git a/packages/google-cloud-node/protos/google/cloud/speech/v1p1beta1/resource.proto b/packages/google-cloud-node/protos/google/cloud/speech/v1p1beta1/resource.proto index 5bb379ff1504..74cee0647d3f 100644 --- a/packages/google-cloud-node/protos/google/cloud/speech/v1p1beta1/resource.proto +++ b/packages/google-cloud-node/protos/google/cloud/speech/v1p1beta1/resource.proto @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ syntax = "proto3"; package google.cloud.speech.v1p1beta1; -import "google/api/annotations.proto"; import "google/api/resource.proto"; +import "google/api/annotations.proto"; option cc_enable_arenas = true; option go_package = "google.golang.org/genproto/googleapis/cloud/speech/v1p1beta1;speech"; @@ -45,7 +45,7 @@ message CustomClass { string name = 1; // If this custom class is a resource, the custom_class_id is the resource id - // of the CustomClass. + // of the CustomClass. Case sensitive. string custom_class_id = 2; // A collection of class items. @@ -121,9 +121,12 @@ message SpeechAdaptation { // phrase set can use any custom class. repeated PhraseSet phrase_sets = 1; + // A collection of phrase set resource names to use. + repeated string phrase_set_references = 2; + // A collection of custom classes. To specify the classes inline, leave the // class' `name` blank and fill in the rest of its fields, giving it a unique // `custom_class_id`. Refer to the inline defined class in phrase hints by its // `custom_class_id`. - repeated CustomClass custom_classes = 2; + repeated CustomClass custom_classes = 3; } diff --git a/packages/google-cloud-node/protos/protos.d.ts b/packages/google-cloud-node/protos/protos.d.ts index 7bf0d64fcc70..0d5935fe76ae 100644 --- a/packages/google-cloud-node/protos/protos.d.ts +++ b/packages/google-cloud-node/protos/protos.d.ts @@ -4399,91 +4399,1483 @@ export namespace google { /** SpeechAdaptation phraseSets */ phraseSets?: (google.cloud.speech.v1p1beta1.IPhraseSet[]|null); + /** SpeechAdaptation phraseSetReferences */ + phraseSetReferences?: (string[]|null); + /** SpeechAdaptation customClasses */ customClasses?: (google.cloud.speech.v1p1beta1.ICustomClass[]|null); } - /** Represents a SpeechAdaptation. */ - class SpeechAdaptation implements ISpeechAdaptation { + /** Represents a SpeechAdaptation. */ + class SpeechAdaptation implements ISpeechAdaptation { + + /** + * Constructs a new SpeechAdaptation. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.ISpeechAdaptation); + + /** SpeechAdaptation phraseSets. */ + public phraseSets: google.cloud.speech.v1p1beta1.IPhraseSet[]; + + /** SpeechAdaptation phraseSetReferences. */ + public phraseSetReferences: string[]; + + /** SpeechAdaptation customClasses. */ + public customClasses: google.cloud.speech.v1p1beta1.ICustomClass[]; + + /** + * Creates a new SpeechAdaptation instance using the specified properties. + * @param [properties] Properties to set + * @returns SpeechAdaptation instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.ISpeechAdaptation): google.cloud.speech.v1p1beta1.SpeechAdaptation; + + /** + * Encodes the specified SpeechAdaptation message. Does not implicitly {@link google.cloud.speech.v1p1beta1.SpeechAdaptation.verify|verify} messages. + * @param message SpeechAdaptation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.ISpeechAdaptation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SpeechAdaptation message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.SpeechAdaptation.verify|verify} messages. + * @param message SpeechAdaptation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.ISpeechAdaptation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SpeechAdaptation message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SpeechAdaptation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1p1beta1.SpeechAdaptation; + + /** + * Decodes a SpeechAdaptation message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SpeechAdaptation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1p1beta1.SpeechAdaptation; + + /** + * Verifies a SpeechAdaptation message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SpeechAdaptation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SpeechAdaptation + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.SpeechAdaptation; + + /** + * Creates a plain object from a SpeechAdaptation message. Also converts values to other types if specified. + * @param message SpeechAdaptation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.SpeechAdaptation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SpeechAdaptation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Represents an Adaptation */ + class Adaptation extends $protobuf.rpc.Service { + + /** + * Constructs a new Adaptation service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Creates new Adaptation service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): Adaptation; + + /** + * Calls CreatePhraseSet. + * @param request CreatePhraseSetRequest message or plain object + * @param callback Node-style callback called with the error, if any, and PhraseSet + */ + public createPhraseSet(request: google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, callback: google.cloud.speech.v1p1beta1.Adaptation.CreatePhraseSetCallback): void; + + /** + * Calls CreatePhraseSet. + * @param request CreatePhraseSetRequest message or plain object + * @returns Promise + */ + public createPhraseSet(request: google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest): Promise; + + /** + * Calls GetPhraseSet. + * @param request GetPhraseSetRequest message or plain object + * @param callback Node-style callback called with the error, if any, and PhraseSet + */ + public getPhraseSet(request: google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, callback: google.cloud.speech.v1p1beta1.Adaptation.GetPhraseSetCallback): void; + + /** + * Calls GetPhraseSet. + * @param request GetPhraseSetRequest message or plain object + * @returns Promise + */ + public getPhraseSet(request: google.cloud.speech.v1p1beta1.IGetPhraseSetRequest): Promise; + + /** + * Calls ListPhraseSet. + * @param request ListPhraseSetRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListPhraseSetResponse + */ + public listPhraseSet(request: google.cloud.speech.v1p1beta1.IListPhraseSetRequest, callback: google.cloud.speech.v1p1beta1.Adaptation.ListPhraseSetCallback): void; + + /** + * Calls ListPhraseSet. + * @param request ListPhraseSetRequest message or plain object + * @returns Promise + */ + public listPhraseSet(request: google.cloud.speech.v1p1beta1.IListPhraseSetRequest): Promise; + + /** + * Calls UpdatePhraseSet. + * @param request UpdatePhraseSetRequest message or plain object + * @param callback Node-style callback called with the error, if any, and PhraseSet + */ + public updatePhraseSet(request: google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, callback: google.cloud.speech.v1p1beta1.Adaptation.UpdatePhraseSetCallback): void; + + /** + * Calls UpdatePhraseSet. + * @param request UpdatePhraseSetRequest message or plain object + * @returns Promise + */ + public updatePhraseSet(request: google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest): Promise; + + /** + * Calls DeletePhraseSet. + * @param request DeletePhraseSetRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deletePhraseSet(request: google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, callback: google.cloud.speech.v1p1beta1.Adaptation.DeletePhraseSetCallback): void; + + /** + * Calls DeletePhraseSet. + * @param request DeletePhraseSetRequest message or plain object + * @returns Promise + */ + public deletePhraseSet(request: google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest): Promise; + + /** + * Calls CreateCustomClass. + * @param request CreateCustomClassRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CustomClass + */ + public createCustomClass(request: google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, callback: google.cloud.speech.v1p1beta1.Adaptation.CreateCustomClassCallback): void; + + /** + * Calls CreateCustomClass. + * @param request CreateCustomClassRequest message or plain object + * @returns Promise + */ + public createCustomClass(request: google.cloud.speech.v1p1beta1.ICreateCustomClassRequest): Promise; + + /** + * Calls GetCustomClass. + * @param request GetCustomClassRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CustomClass + */ + public getCustomClass(request: google.cloud.speech.v1p1beta1.IGetCustomClassRequest, callback: google.cloud.speech.v1p1beta1.Adaptation.GetCustomClassCallback): void; + + /** + * Calls GetCustomClass. + * @param request GetCustomClassRequest message or plain object + * @returns Promise + */ + public getCustomClass(request: google.cloud.speech.v1p1beta1.IGetCustomClassRequest): Promise; + + /** + * Calls ListCustomClasses. + * @param request ListCustomClassesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListCustomClassesResponse + */ + public listCustomClasses(request: google.cloud.speech.v1p1beta1.IListCustomClassesRequest, callback: google.cloud.speech.v1p1beta1.Adaptation.ListCustomClassesCallback): void; + + /** + * Calls ListCustomClasses. + * @param request ListCustomClassesRequest message or plain object + * @returns Promise + */ + public listCustomClasses(request: google.cloud.speech.v1p1beta1.IListCustomClassesRequest): Promise; + + /** + * Calls UpdateCustomClass. + * @param request UpdateCustomClassRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CustomClass + */ + public updateCustomClass(request: google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, callback: google.cloud.speech.v1p1beta1.Adaptation.UpdateCustomClassCallback): void; + + /** + * Calls UpdateCustomClass. + * @param request UpdateCustomClassRequest message or plain object + * @returns Promise + */ + public updateCustomClass(request: google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest): Promise; + + /** + * Calls DeleteCustomClass. + * @param request DeleteCustomClassRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteCustomClass(request: google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, callback: google.cloud.speech.v1p1beta1.Adaptation.DeleteCustomClassCallback): void; + + /** + * Calls DeleteCustomClass. + * @param request DeleteCustomClassRequest message or plain object + * @returns Promise + */ + public deleteCustomClass(request: google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest): Promise; + } + + namespace Adaptation { + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#createPhraseSet}. + * @param error Error, if any + * @param [response] PhraseSet + */ + type CreatePhraseSetCallback = (error: (Error|null), response?: google.cloud.speech.v1p1beta1.PhraseSet) => void; + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#getPhraseSet}. + * @param error Error, if any + * @param [response] PhraseSet + */ + type GetPhraseSetCallback = (error: (Error|null), response?: google.cloud.speech.v1p1beta1.PhraseSet) => void; + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#listPhraseSet}. + * @param error Error, if any + * @param [response] ListPhraseSetResponse + */ + type ListPhraseSetCallback = (error: (Error|null), response?: google.cloud.speech.v1p1beta1.ListPhraseSetResponse) => void; + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#updatePhraseSet}. + * @param error Error, if any + * @param [response] PhraseSet + */ + type UpdatePhraseSetCallback = (error: (Error|null), response?: google.cloud.speech.v1p1beta1.PhraseSet) => void; + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#deletePhraseSet}. + * @param error Error, if any + * @param [response] Empty + */ + type DeletePhraseSetCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#createCustomClass}. + * @param error Error, if any + * @param [response] CustomClass + */ + type CreateCustomClassCallback = (error: (Error|null), response?: google.cloud.speech.v1p1beta1.CustomClass) => void; + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#getCustomClass}. + * @param error Error, if any + * @param [response] CustomClass + */ + type GetCustomClassCallback = (error: (Error|null), response?: google.cloud.speech.v1p1beta1.CustomClass) => void; + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#listCustomClasses}. + * @param error Error, if any + * @param [response] ListCustomClassesResponse + */ + type ListCustomClassesCallback = (error: (Error|null), response?: google.cloud.speech.v1p1beta1.ListCustomClassesResponse) => void; + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#updateCustomClass}. + * @param error Error, if any + * @param [response] CustomClass + */ + type UpdateCustomClassCallback = (error: (Error|null), response?: google.cloud.speech.v1p1beta1.CustomClass) => void; + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#deleteCustomClass}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteCustomClassCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + } + + /** Properties of a CreatePhraseSetRequest. */ + interface ICreatePhraseSetRequest { + + /** CreatePhraseSetRequest parent */ + parent?: (string|null); + + /** CreatePhraseSetRequest phraseSetId */ + phraseSetId?: (string|null); + + /** CreatePhraseSetRequest phraseSet */ + phraseSet?: (google.cloud.speech.v1p1beta1.IPhraseSet|null); + } + + /** Represents a CreatePhraseSetRequest. */ + class CreatePhraseSetRequest implements ICreatePhraseSetRequest { + + /** + * Constructs a new CreatePhraseSetRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest); + + /** CreatePhraseSetRequest parent. */ + public parent: string; + + /** CreatePhraseSetRequest phraseSetId. */ + public phraseSetId: string; + + /** CreatePhraseSetRequest phraseSet. */ + public phraseSet?: (google.cloud.speech.v1p1beta1.IPhraseSet|null); + + /** + * Creates a new CreatePhraseSetRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreatePhraseSetRequest instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest): google.cloud.speech.v1p1beta1.CreatePhraseSetRequest; + + /** + * Encodes the specified CreatePhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.CreatePhraseSetRequest.verify|verify} messages. + * @param message CreatePhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreatePhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.CreatePhraseSetRequest.verify|verify} messages. + * @param message CreatePhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreatePhraseSetRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreatePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1p1beta1.CreatePhraseSetRequest; + + /** + * Decodes a CreatePhraseSetRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreatePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1p1beta1.CreatePhraseSetRequest; + + /** + * Verifies a CreatePhraseSetRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CreatePhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreatePhraseSetRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.CreatePhraseSetRequest; + + /** + * Creates a plain object from a CreatePhraseSetRequest message. Also converts values to other types if specified. + * @param message CreatePhraseSetRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.CreatePhraseSetRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreatePhraseSetRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an UpdatePhraseSetRequest. */ + interface IUpdatePhraseSetRequest { + + /** UpdatePhraseSetRequest phraseSet */ + phraseSet?: (google.cloud.speech.v1p1beta1.IPhraseSet|null); + + /** UpdatePhraseSetRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdatePhraseSetRequest. */ + class UpdatePhraseSetRequest implements IUpdatePhraseSetRequest { + + /** + * Constructs a new UpdatePhraseSetRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest); + + /** UpdatePhraseSetRequest phraseSet. */ + public phraseSet?: (google.cloud.speech.v1p1beta1.IPhraseSet|null); + + /** UpdatePhraseSetRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdatePhraseSetRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdatePhraseSetRequest instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest): google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest; + + /** + * Encodes the specified UpdatePhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest.verify|verify} messages. + * @param message UpdatePhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdatePhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest.verify|verify} messages. + * @param message UpdatePhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdatePhraseSetRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdatePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest; + + /** + * Decodes an UpdatePhraseSetRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdatePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest; + + /** + * Verifies an UpdatePhraseSetRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UpdatePhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdatePhraseSetRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest; + + /** + * Creates a plain object from an UpdatePhraseSetRequest message. Also converts values to other types if specified. + * @param message UpdatePhraseSetRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdatePhraseSetRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a GetPhraseSetRequest. */ + interface IGetPhraseSetRequest { + + /** GetPhraseSetRequest name */ + name?: (string|null); + } + + /** Represents a GetPhraseSetRequest. */ + class GetPhraseSetRequest implements IGetPhraseSetRequest { + + /** + * Constructs a new GetPhraseSetRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.IGetPhraseSetRequest); + + /** GetPhraseSetRequest name. */ + public name: string; + + /** + * Creates a new GetPhraseSetRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetPhraseSetRequest instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.IGetPhraseSetRequest): google.cloud.speech.v1p1beta1.GetPhraseSetRequest; + + /** + * Encodes the specified GetPhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.GetPhraseSetRequest.verify|verify} messages. + * @param message GetPhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetPhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.GetPhraseSetRequest.verify|verify} messages. + * @param message GetPhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetPhraseSetRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetPhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1p1beta1.GetPhraseSetRequest; + + /** + * Decodes a GetPhraseSetRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetPhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1p1beta1.GetPhraseSetRequest; + + /** + * Verifies a GetPhraseSetRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GetPhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetPhraseSetRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.GetPhraseSetRequest; + + /** + * Creates a plain object from a GetPhraseSetRequest message. Also converts values to other types if specified. + * @param message GetPhraseSetRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.GetPhraseSetRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetPhraseSetRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListPhraseSetRequest. */ + interface IListPhraseSetRequest { + + /** ListPhraseSetRequest parent */ + parent?: (string|null); + + /** ListPhraseSetRequest pageSize */ + pageSize?: (number|null); + + /** ListPhraseSetRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListPhraseSetRequest. */ + class ListPhraseSetRequest implements IListPhraseSetRequest { + + /** + * Constructs a new ListPhraseSetRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.IListPhraseSetRequest); + + /** ListPhraseSetRequest parent. */ + public parent: string; + + /** ListPhraseSetRequest pageSize. */ + public pageSize: number; + + /** ListPhraseSetRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListPhraseSetRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListPhraseSetRequest instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.IListPhraseSetRequest): google.cloud.speech.v1p1beta1.ListPhraseSetRequest; + + /** + * Encodes the specified ListPhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListPhraseSetRequest.verify|verify} messages. + * @param message ListPhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.IListPhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListPhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListPhraseSetRequest.verify|verify} messages. + * @param message ListPhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.IListPhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListPhraseSetRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListPhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1p1beta1.ListPhraseSetRequest; + + /** + * Decodes a ListPhraseSetRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListPhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1p1beta1.ListPhraseSetRequest; + + /** + * Verifies a ListPhraseSetRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListPhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListPhraseSetRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.ListPhraseSetRequest; + + /** + * Creates a plain object from a ListPhraseSetRequest message. Also converts values to other types if specified. + * @param message ListPhraseSetRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.ListPhraseSetRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListPhraseSetRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListPhraseSetResponse. */ + interface IListPhraseSetResponse { + + /** ListPhraseSetResponse phraseSets */ + phraseSets?: (google.cloud.speech.v1p1beta1.IPhraseSet[]|null); + + /** ListPhraseSetResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListPhraseSetResponse. */ + class ListPhraseSetResponse implements IListPhraseSetResponse { + + /** + * Constructs a new ListPhraseSetResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.IListPhraseSetResponse); + + /** ListPhraseSetResponse phraseSets. */ + public phraseSets: google.cloud.speech.v1p1beta1.IPhraseSet[]; + + /** ListPhraseSetResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListPhraseSetResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListPhraseSetResponse instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.IListPhraseSetResponse): google.cloud.speech.v1p1beta1.ListPhraseSetResponse; + + /** + * Encodes the specified ListPhraseSetResponse message. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListPhraseSetResponse.verify|verify} messages. + * @param message ListPhraseSetResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.IListPhraseSetResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListPhraseSetResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListPhraseSetResponse.verify|verify} messages. + * @param message ListPhraseSetResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.IListPhraseSetResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListPhraseSetResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListPhraseSetResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1p1beta1.ListPhraseSetResponse; + + /** + * Decodes a ListPhraseSetResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListPhraseSetResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1p1beta1.ListPhraseSetResponse; + + /** + * Verifies a ListPhraseSetResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListPhraseSetResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListPhraseSetResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.ListPhraseSetResponse; + + /** + * Creates a plain object from a ListPhraseSetResponse message. Also converts values to other types if specified. + * @param message ListPhraseSetResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.ListPhraseSetResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListPhraseSetResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DeletePhraseSetRequest. */ + interface IDeletePhraseSetRequest { + + /** DeletePhraseSetRequest name */ + name?: (string|null); + } + + /** Represents a DeletePhraseSetRequest. */ + class DeletePhraseSetRequest implements IDeletePhraseSetRequest { + + /** + * Constructs a new DeletePhraseSetRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest); + + /** DeletePhraseSetRequest name. */ + public name: string; + + /** + * Creates a new DeletePhraseSetRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeletePhraseSetRequest instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest): google.cloud.speech.v1p1beta1.DeletePhraseSetRequest; + + /** + * Encodes the specified DeletePhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.DeletePhraseSetRequest.verify|verify} messages. + * @param message DeletePhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeletePhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.DeletePhraseSetRequest.verify|verify} messages. + * @param message DeletePhraseSetRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeletePhraseSetRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeletePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1p1beta1.DeletePhraseSetRequest; + + /** + * Decodes a DeletePhraseSetRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeletePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1p1beta1.DeletePhraseSetRequest; + + /** + * Verifies a DeletePhraseSetRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DeletePhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeletePhraseSetRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.DeletePhraseSetRequest; + + /** + * Creates a plain object from a DeletePhraseSetRequest message. Also converts values to other types if specified. + * @param message DeletePhraseSetRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.DeletePhraseSetRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeletePhraseSetRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a CreateCustomClassRequest. */ + interface ICreateCustomClassRequest { + + /** CreateCustomClassRequest parent */ + parent?: (string|null); + + /** CreateCustomClassRequest customClassId */ + customClassId?: (string|null); + + /** CreateCustomClassRequest customClass */ + customClass?: (google.cloud.speech.v1p1beta1.ICustomClass|null); + } + + /** Represents a CreateCustomClassRequest. */ + class CreateCustomClassRequest implements ICreateCustomClassRequest { + + /** + * Constructs a new CreateCustomClassRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.ICreateCustomClassRequest); + + /** CreateCustomClassRequest parent. */ + public parent: string; + + /** CreateCustomClassRequest customClassId. */ + public customClassId: string; + + /** CreateCustomClassRequest customClass. */ + public customClass?: (google.cloud.speech.v1p1beta1.ICustomClass|null); + + /** + * Creates a new CreateCustomClassRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateCustomClassRequest instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.ICreateCustomClassRequest): google.cloud.speech.v1p1beta1.CreateCustomClassRequest; + + /** + * Encodes the specified CreateCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.CreateCustomClassRequest.verify|verify} messages. + * @param message CreateCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.CreateCustomClassRequest.verify|verify} messages. + * @param message CreateCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateCustomClassRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1p1beta1.CreateCustomClassRequest; + + /** + * Decodes a CreateCustomClassRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1p1beta1.CreateCustomClassRequest; + + /** + * Verifies a CreateCustomClassRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CreateCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateCustomClassRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.CreateCustomClassRequest; + + /** + * Creates a plain object from a CreateCustomClassRequest message. Also converts values to other types if specified. + * @param message CreateCustomClassRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.CreateCustomClassRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateCustomClassRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an UpdateCustomClassRequest. */ + interface IUpdateCustomClassRequest { + + /** UpdateCustomClassRequest customClass */ + customClass?: (google.cloud.speech.v1p1beta1.ICustomClass|null); + + /** UpdateCustomClassRequest updateMask */ + updateMask?: (google.protobuf.IFieldMask|null); + } + + /** Represents an UpdateCustomClassRequest. */ + class UpdateCustomClassRequest implements IUpdateCustomClassRequest { + + /** + * Constructs a new UpdateCustomClassRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest); + + /** UpdateCustomClassRequest customClass. */ + public customClass?: (google.cloud.speech.v1p1beta1.ICustomClass|null); + + /** UpdateCustomClassRequest updateMask. */ + public updateMask?: (google.protobuf.IFieldMask|null); + + /** + * Creates a new UpdateCustomClassRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns UpdateCustomClassRequest instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest): google.cloud.speech.v1p1beta1.UpdateCustomClassRequest; + + /** + * Encodes the specified UpdateCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.UpdateCustomClassRequest.verify|verify} messages. + * @param message UpdateCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UpdateCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.UpdateCustomClassRequest.verify|verify} messages. + * @param message UpdateCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UpdateCustomClassRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UpdateCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1p1beta1.UpdateCustomClassRequest; + + /** + * Decodes an UpdateCustomClassRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UpdateCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1p1beta1.UpdateCustomClassRequest; + + /** + * Verifies an UpdateCustomClassRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UpdateCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UpdateCustomClassRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.UpdateCustomClassRequest; + + /** + * Creates a plain object from an UpdateCustomClassRequest message. Also converts values to other types if specified. + * @param message UpdateCustomClassRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.UpdateCustomClassRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UpdateCustomClassRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a GetCustomClassRequest. */ + interface IGetCustomClassRequest { + + /** GetCustomClassRequest name */ + name?: (string|null); + } + + /** Represents a GetCustomClassRequest. */ + class GetCustomClassRequest implements IGetCustomClassRequest { + + /** + * Constructs a new GetCustomClassRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.IGetCustomClassRequest); + + /** GetCustomClassRequest name. */ + public name: string; + + /** + * Creates a new GetCustomClassRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetCustomClassRequest instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.IGetCustomClassRequest): google.cloud.speech.v1p1beta1.GetCustomClassRequest; + + /** + * Encodes the specified GetCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.GetCustomClassRequest.verify|verify} messages. + * @param message GetCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.IGetCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.GetCustomClassRequest.verify|verify} messages. + * @param message GetCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.IGetCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetCustomClassRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1p1beta1.GetCustomClassRequest; + + /** + * Decodes a GetCustomClassRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1p1beta1.GetCustomClassRequest; + + /** + * Verifies a GetCustomClassRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GetCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetCustomClassRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.GetCustomClassRequest; + + /** + * Creates a plain object from a GetCustomClassRequest message. Also converts values to other types if specified. + * @param message GetCustomClassRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.GetCustomClassRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetCustomClassRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListCustomClassesRequest. */ + interface IListCustomClassesRequest { + + /** ListCustomClassesRequest parent */ + parent?: (string|null); + + /** ListCustomClassesRequest pageSize */ + pageSize?: (number|null); + + /** ListCustomClassesRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListCustomClassesRequest. */ + class ListCustomClassesRequest implements IListCustomClassesRequest { /** - * Constructs a new SpeechAdaptation. + * Constructs a new ListCustomClassesRequest. * @param [properties] Properties to set */ - constructor(properties?: google.cloud.speech.v1p1beta1.ISpeechAdaptation); + constructor(properties?: google.cloud.speech.v1p1beta1.IListCustomClassesRequest); - /** SpeechAdaptation phraseSets. */ - public phraseSets: google.cloud.speech.v1p1beta1.IPhraseSet[]; + /** ListCustomClassesRequest parent. */ + public parent: string; - /** SpeechAdaptation customClasses. */ + /** ListCustomClassesRequest pageSize. */ + public pageSize: number; + + /** ListCustomClassesRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListCustomClassesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListCustomClassesRequest instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.IListCustomClassesRequest): google.cloud.speech.v1p1beta1.ListCustomClassesRequest; + + /** + * Encodes the specified ListCustomClassesRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListCustomClassesRequest.verify|verify} messages. + * @param message ListCustomClassesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.IListCustomClassesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListCustomClassesRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListCustomClassesRequest.verify|verify} messages. + * @param message ListCustomClassesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.IListCustomClassesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListCustomClassesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListCustomClassesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1p1beta1.ListCustomClassesRequest; + + /** + * Decodes a ListCustomClassesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListCustomClassesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1p1beta1.ListCustomClassesRequest; + + /** + * Verifies a ListCustomClassesRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListCustomClassesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListCustomClassesRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.ListCustomClassesRequest; + + /** + * Creates a plain object from a ListCustomClassesRequest message. Also converts values to other types if specified. + * @param message ListCustomClassesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.ListCustomClassesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListCustomClassesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a ListCustomClassesResponse. */ + interface IListCustomClassesResponse { + + /** ListCustomClassesResponse customClasses */ + customClasses?: (google.cloud.speech.v1p1beta1.ICustomClass[]|null); + + /** ListCustomClassesResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListCustomClassesResponse. */ + class ListCustomClassesResponse implements IListCustomClassesResponse { + + /** + * Constructs a new ListCustomClassesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.IListCustomClassesResponse); + + /** ListCustomClassesResponse customClasses. */ public customClasses: google.cloud.speech.v1p1beta1.ICustomClass[]; + /** ListCustomClassesResponse nextPageToken. */ + public nextPageToken: string; + /** - * Creates a new SpeechAdaptation instance using the specified properties. + * Creates a new ListCustomClassesResponse instance using the specified properties. * @param [properties] Properties to set - * @returns SpeechAdaptation instance + * @returns ListCustomClassesResponse instance */ - public static create(properties?: google.cloud.speech.v1p1beta1.ISpeechAdaptation): google.cloud.speech.v1p1beta1.SpeechAdaptation; + public static create(properties?: google.cloud.speech.v1p1beta1.IListCustomClassesResponse): google.cloud.speech.v1p1beta1.ListCustomClassesResponse; /** - * Encodes the specified SpeechAdaptation message. Does not implicitly {@link google.cloud.speech.v1p1beta1.SpeechAdaptation.verify|verify} messages. - * @param message SpeechAdaptation message or plain object to encode + * Encodes the specified ListCustomClassesResponse message. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListCustomClassesResponse.verify|verify} messages. + * @param message ListCustomClassesResponse message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encode(message: google.cloud.speech.v1p1beta1.ISpeechAdaptation, writer?: $protobuf.Writer): $protobuf.Writer; + public static encode(message: google.cloud.speech.v1p1beta1.IListCustomClassesResponse, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Encodes the specified SpeechAdaptation message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.SpeechAdaptation.verify|verify} messages. - * @param message SpeechAdaptation message or plain object to encode + * Encodes the specified ListCustomClassesResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListCustomClassesResponse.verify|verify} messages. + * @param message ListCustomClassesResponse message or plain object to encode * @param [writer] Writer to encode to * @returns Writer */ - public static encodeDelimited(message: google.cloud.speech.v1p1beta1.ISpeechAdaptation, writer?: $protobuf.Writer): $protobuf.Writer; + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.IListCustomClassesResponse, writer?: $protobuf.Writer): $protobuf.Writer; /** - * Decodes a SpeechAdaptation message from the specified reader or buffer. + * Decodes a ListCustomClassesResponse message from the specified reader or buffer. * @param reader Reader or buffer to decode from * @param [length] Message length if known beforehand - * @returns SpeechAdaptation + * @returns ListCustomClassesResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1p1beta1.SpeechAdaptation; + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1p1beta1.ListCustomClassesResponse; /** - * Decodes a SpeechAdaptation message from the specified reader or buffer, length delimited. + * Decodes a ListCustomClassesResponse message from the specified reader or buffer, length delimited. * @param reader Reader or buffer to decode from - * @returns SpeechAdaptation + * @returns ListCustomClassesResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1p1beta1.SpeechAdaptation; + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1p1beta1.ListCustomClassesResponse; /** - * Verifies a SpeechAdaptation message. + * Verifies a ListCustomClassesResponse message. * @param message Plain object to verify * @returns `null` if valid, otherwise the reason why it is not */ public static verify(message: { [k: string]: any }): (string|null); /** - * Creates a SpeechAdaptation message from a plain object. Also converts values to their respective internal types. + * Creates a ListCustomClassesResponse message from a plain object. Also converts values to their respective internal types. * @param object Plain object - * @returns SpeechAdaptation + * @returns ListCustomClassesResponse */ - public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.SpeechAdaptation; + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.ListCustomClassesResponse; /** - * Creates a plain object from a SpeechAdaptation message. Also converts values to other types if specified. - * @param message SpeechAdaptation + * Creates a plain object from a ListCustomClassesResponse message. Also converts values to other types if specified. + * @param message ListCustomClassesResponse * @param [options] Conversion options * @returns Plain object */ - public static toObject(message: google.cloud.speech.v1p1beta1.SpeechAdaptation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + public static toObject(message: google.cloud.speech.v1p1beta1.ListCustomClassesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; /** - * Converts this SpeechAdaptation to JSON. + * Converts this ListCustomClassesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a DeleteCustomClassRequest. */ + interface IDeleteCustomClassRequest { + + /** DeleteCustomClassRequest name */ + name?: (string|null); + } + + /** Represents a DeleteCustomClassRequest. */ + class DeleteCustomClassRequest implements IDeleteCustomClassRequest { + + /** + * Constructs a new DeleteCustomClassRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest); + + /** DeleteCustomClassRequest name. */ + public name: string; + + /** + * Creates a new DeleteCustomClassRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteCustomClassRequest instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest): google.cloud.speech.v1p1beta1.DeleteCustomClassRequest; + + /** + * Encodes the specified DeleteCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.DeleteCustomClassRequest.verify|verify} messages. + * @param message DeleteCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.DeleteCustomClassRequest.verify|verify} messages. + * @param message DeleteCustomClassRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteCustomClassRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.speech.v1p1beta1.DeleteCustomClassRequest; + + /** + * Decodes a DeleteCustomClassRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.speech.v1p1beta1.DeleteCustomClassRequest; + + /** + * Verifies a DeleteCustomClassRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DeleteCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteCustomClassRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.DeleteCustomClassRequest; + + /** + * Creates a plain object from a DeleteCustomClassRequest message. Also converts values to other types if specified. + * @param message DeleteCustomClassRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.DeleteCustomClassRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteCustomClassRequest to JSON. * @returns JSON object */ public toJSON(): { [k: string]: any }; @@ -4841,8 +6233,7 @@ export namespace google { REQUIRED = 2, OUTPUT_ONLY = 3, INPUT_ONLY = 4, - IMMUTABLE = 5, - UNORDERED_LIST = 6 + IMMUTABLE = 5 } /** Properties of a ResourceDescriptor. */ @@ -4865,9 +6256,6 @@ export namespace google { /** ResourceDescriptor singular */ singular?: (string|null); - - /** ResourceDescriptor style */ - style?: (google.api.ResourceDescriptor.Style[]|null); } /** Represents a ResourceDescriptor. */ @@ -4897,9 +6285,6 @@ export namespace google { /** ResourceDescriptor singular. */ public singular: string; - /** ResourceDescriptor style. */ - public style: google.api.ResourceDescriptor.Style[]; - /** * Creates a new ResourceDescriptor instance using the specified properties. * @param [properties] Properties to set @@ -4979,12 +6364,6 @@ export namespace google { ORIGINALLY_SINGLE_PATTERN = 1, FUTURE_MULTI_PATTERN = 2 } - - /** Style enum. */ - enum Style { - STYLE_UNSPECIFIED = 0, - DECLARATIVE_FRIENDLY = 1 - } } /** Properties of a ResourceReference. */ @@ -8587,6 +9966,96 @@ export namespace google { */ public toJSON(): { [k: string]: any }; } + + /** Properties of a FieldMask. */ + interface IFieldMask { + + /** FieldMask paths */ + paths?: (string[]|null); + } + + /** Represents a FieldMask. */ + class FieldMask implements IFieldMask { + + /** + * Constructs a new FieldMask. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldMask); + + /** FieldMask paths. */ + public paths: string[]; + + /** + * Creates a new FieldMask instance using the specified properties. + * @param [properties] Properties to set + * @returns FieldMask instance + */ + public static create(properties?: google.protobuf.IFieldMask): google.protobuf.FieldMask; + + /** + * Encodes the specified FieldMask message. Does not implicitly {@link google.protobuf.FieldMask.verify|verify} messages. + * @param message FieldMask message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFieldMask, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FieldMask message, length delimited. Does not implicitly {@link google.protobuf.FieldMask.verify|verify} messages. + * @param message FieldMask message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFieldMask, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FieldMask message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FieldMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FieldMask; + + /** + * Decodes a FieldMask message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FieldMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FieldMask; + + /** + * Verifies a FieldMask message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FieldMask message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldMask + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldMask; + + /** + * Creates a plain object from a FieldMask message. Also converts values to other types if specified. + * @param message FieldMask + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldMask, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldMask to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } } /** Namespace longrunning. */ diff --git a/packages/google-cloud-node/protos/protos.js b/packages/google-cloud-node/protos/protos.js index 74400392b392..3a83b2930507 100644 --- a/packages/google-cloud-node/protos/protos.js +++ b/packages/google-cloud-node/protos/protos.js @@ -11043,6 +11043,7 @@ * @memberof google.cloud.speech.v1p1beta1 * @interface ISpeechAdaptation * @property {Array.|null} [phraseSets] SpeechAdaptation phraseSets + * @property {Array.|null} [phraseSetReferences] SpeechAdaptation phraseSetReferences * @property {Array.|null} [customClasses] SpeechAdaptation customClasses */ @@ -11056,6 +11057,7 @@ */ function SpeechAdaptation(properties) { this.phraseSets = []; + this.phraseSetReferences = []; this.customClasses = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) @@ -11071,6 +11073,14 @@ */ SpeechAdaptation.prototype.phraseSets = $util.emptyArray; + /** + * SpeechAdaptation phraseSetReferences. + * @member {Array.} phraseSetReferences + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation + * @instance + */ + SpeechAdaptation.prototype.phraseSetReferences = $util.emptyArray; + /** * SpeechAdaptation customClasses. * @member {Array.} customClasses @@ -11106,9 +11116,12 @@ if (message.phraseSets != null && message.phraseSets.length) for (var i = 0; i < message.phraseSets.length; ++i) $root.google.cloud.speech.v1p1beta1.PhraseSet.encode(message.phraseSets[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.phraseSetReferences != null && message.phraseSetReferences.length) + for (var i = 0; i < message.phraseSetReferences.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.phraseSetReferences[i]); if (message.customClasses != null && message.customClasses.length) for (var i = 0; i < message.customClasses.length; ++i) - $root.google.cloud.speech.v1p1beta1.CustomClass.encode(message.customClasses[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + $root.google.cloud.speech.v1p1beta1.CustomClass.encode(message.customClasses[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); return writer; }; @@ -11149,6 +11162,11 @@ message.phraseSets.push($root.google.cloud.speech.v1p1beta1.PhraseSet.decode(reader, reader.uint32())); break; case 2: + if (!(message.phraseSetReferences && message.phraseSetReferences.length)) + message.phraseSetReferences = []; + message.phraseSetReferences.push(reader.string()); + break; + case 3: if (!(message.customClasses && message.customClasses.length)) message.customClasses = []; message.customClasses.push($root.google.cloud.speech.v1p1beta1.CustomClass.decode(reader, reader.uint32())); @@ -11162,130 +11180,3103 @@ }; /** - * Decodes a SpeechAdaptation message from the specified reader or buffer, length delimited. + * Decodes a SpeechAdaptation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.SpeechAdaptation} SpeechAdaptation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeechAdaptation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SpeechAdaptation message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SpeechAdaptation.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.phraseSets != null && message.hasOwnProperty("phraseSets")) { + if (!Array.isArray(message.phraseSets)) + return "phraseSets: array expected"; + for (var i = 0; i < message.phraseSets.length; ++i) { + var error = $root.google.cloud.speech.v1p1beta1.PhraseSet.verify(message.phraseSets[i]); + if (error) + return "phraseSets." + error; + } + } + if (message.phraseSetReferences != null && message.hasOwnProperty("phraseSetReferences")) { + if (!Array.isArray(message.phraseSetReferences)) + return "phraseSetReferences: array expected"; + for (var i = 0; i < message.phraseSetReferences.length; ++i) + if (!$util.isString(message.phraseSetReferences[i])) + return "phraseSetReferences: string[] expected"; + } + if (message.customClasses != null && message.hasOwnProperty("customClasses")) { + if (!Array.isArray(message.customClasses)) + return "customClasses: array expected"; + for (var i = 0; i < message.customClasses.length; ++i) { + var error = $root.google.cloud.speech.v1p1beta1.CustomClass.verify(message.customClasses[i]); + if (error) + return "customClasses." + error; + } + } + return null; + }; + + /** + * Creates a SpeechAdaptation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.SpeechAdaptation} SpeechAdaptation + */ + SpeechAdaptation.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.SpeechAdaptation) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.SpeechAdaptation(); + if (object.phraseSets) { + if (!Array.isArray(object.phraseSets)) + throw TypeError(".google.cloud.speech.v1p1beta1.SpeechAdaptation.phraseSets: array expected"); + message.phraseSets = []; + for (var i = 0; i < object.phraseSets.length; ++i) { + if (typeof object.phraseSets[i] !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.SpeechAdaptation.phraseSets: object expected"); + message.phraseSets[i] = $root.google.cloud.speech.v1p1beta1.PhraseSet.fromObject(object.phraseSets[i]); + } + } + if (object.phraseSetReferences) { + if (!Array.isArray(object.phraseSetReferences)) + throw TypeError(".google.cloud.speech.v1p1beta1.SpeechAdaptation.phraseSetReferences: array expected"); + message.phraseSetReferences = []; + for (var i = 0; i < object.phraseSetReferences.length; ++i) + message.phraseSetReferences[i] = String(object.phraseSetReferences[i]); + } + if (object.customClasses) { + if (!Array.isArray(object.customClasses)) + throw TypeError(".google.cloud.speech.v1p1beta1.SpeechAdaptation.customClasses: array expected"); + message.customClasses = []; + for (var i = 0; i < object.customClasses.length; ++i) { + if (typeof object.customClasses[i] !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.SpeechAdaptation.customClasses: object expected"); + message.customClasses[i] = $root.google.cloud.speech.v1p1beta1.CustomClass.fromObject(object.customClasses[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a SpeechAdaptation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation + * @static + * @param {google.cloud.speech.v1p1beta1.SpeechAdaptation} message SpeechAdaptation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SpeechAdaptation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.phraseSets = []; + object.phraseSetReferences = []; + object.customClasses = []; + } + if (message.phraseSets && message.phraseSets.length) { + object.phraseSets = []; + for (var j = 0; j < message.phraseSets.length; ++j) + object.phraseSets[j] = $root.google.cloud.speech.v1p1beta1.PhraseSet.toObject(message.phraseSets[j], options); + } + if (message.phraseSetReferences && message.phraseSetReferences.length) { + object.phraseSetReferences = []; + for (var j = 0; j < message.phraseSetReferences.length; ++j) + object.phraseSetReferences[j] = message.phraseSetReferences[j]; + } + if (message.customClasses && message.customClasses.length) { + object.customClasses = []; + for (var j = 0; j < message.customClasses.length; ++j) + object.customClasses[j] = $root.google.cloud.speech.v1p1beta1.CustomClass.toObject(message.customClasses[j], options); + } + return object; + }; + + /** + * Converts this SpeechAdaptation to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation + * @instance + * @returns {Object.} JSON object + */ + SpeechAdaptation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return SpeechAdaptation; + })(); + + v1p1beta1.Adaptation = (function() { + + /** + * Constructs a new Adaptation service. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents an Adaptation + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function Adaptation(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (Adaptation.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Adaptation; + + /** + * Creates new Adaptation service using the specified rpc implementation. + * @function create + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {Adaptation} RPC service. Useful where requests and/or responses are streamed. + */ + Adaptation.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#createPhraseSet}. + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @typedef CreatePhraseSetCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v1p1beta1.PhraseSet} [response] PhraseSet + */ + + /** + * Calls CreatePhraseSet. + * @function createPhraseSet + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest} request CreatePhraseSetRequest message or plain object + * @param {google.cloud.speech.v1p1beta1.Adaptation.CreatePhraseSetCallback} callback Node-style callback called with the error, if any, and PhraseSet + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Adaptation.prototype.createPhraseSet = function createPhraseSet(request, callback) { + return this.rpcCall(createPhraseSet, $root.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest, $root.google.cloud.speech.v1p1beta1.PhraseSet, request, callback); + }, "name", { value: "CreatePhraseSet" }); + + /** + * Calls CreatePhraseSet. + * @function createPhraseSet + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest} request CreatePhraseSetRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#getPhraseSet}. + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @typedef GetPhraseSetCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v1p1beta1.PhraseSet} [response] PhraseSet + */ + + /** + * Calls GetPhraseSet. + * @function getPhraseSet + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IGetPhraseSetRequest} request GetPhraseSetRequest message or plain object + * @param {google.cloud.speech.v1p1beta1.Adaptation.GetPhraseSetCallback} callback Node-style callback called with the error, if any, and PhraseSet + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Adaptation.prototype.getPhraseSet = function getPhraseSet(request, callback) { + return this.rpcCall(getPhraseSet, $root.google.cloud.speech.v1p1beta1.GetPhraseSetRequest, $root.google.cloud.speech.v1p1beta1.PhraseSet, request, callback); + }, "name", { value: "GetPhraseSet" }); + + /** + * Calls GetPhraseSet. + * @function getPhraseSet + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IGetPhraseSetRequest} request GetPhraseSetRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#listPhraseSet}. + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @typedef ListPhraseSetCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v1p1beta1.ListPhraseSetResponse} [response] ListPhraseSetResponse + */ + + /** + * Calls ListPhraseSet. + * @function listPhraseSet + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IListPhraseSetRequest} request ListPhraseSetRequest message or plain object + * @param {google.cloud.speech.v1p1beta1.Adaptation.ListPhraseSetCallback} callback Node-style callback called with the error, if any, and ListPhraseSetResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Adaptation.prototype.listPhraseSet = function listPhraseSet(request, callback) { + return this.rpcCall(listPhraseSet, $root.google.cloud.speech.v1p1beta1.ListPhraseSetRequest, $root.google.cloud.speech.v1p1beta1.ListPhraseSetResponse, request, callback); + }, "name", { value: "ListPhraseSet" }); + + /** + * Calls ListPhraseSet. + * @function listPhraseSet + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IListPhraseSetRequest} request ListPhraseSetRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#updatePhraseSet}. + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @typedef UpdatePhraseSetCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v1p1beta1.PhraseSet} [response] PhraseSet + */ + + /** + * Calls UpdatePhraseSet. + * @function updatePhraseSet + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest} request UpdatePhraseSetRequest message or plain object + * @param {google.cloud.speech.v1p1beta1.Adaptation.UpdatePhraseSetCallback} callback Node-style callback called with the error, if any, and PhraseSet + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Adaptation.prototype.updatePhraseSet = function updatePhraseSet(request, callback) { + return this.rpcCall(updatePhraseSet, $root.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest, $root.google.cloud.speech.v1p1beta1.PhraseSet, request, callback); + }, "name", { value: "UpdatePhraseSet" }); + + /** + * Calls UpdatePhraseSet. + * @function updatePhraseSet + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest} request UpdatePhraseSetRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#deletePhraseSet}. + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @typedef DeletePhraseSetCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeletePhraseSet. + * @function deletePhraseSet + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest} request DeletePhraseSetRequest message or plain object + * @param {google.cloud.speech.v1p1beta1.Adaptation.DeletePhraseSetCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Adaptation.prototype.deletePhraseSet = function deletePhraseSet(request, callback) { + return this.rpcCall(deletePhraseSet, $root.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeletePhraseSet" }); + + /** + * Calls DeletePhraseSet. + * @function deletePhraseSet + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest} request DeletePhraseSetRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#createCustomClass}. + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @typedef CreateCustomClassCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v1p1beta1.CustomClass} [response] CustomClass + */ + + /** + * Calls CreateCustomClass. + * @function createCustomClass + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.ICreateCustomClassRequest} request CreateCustomClassRequest message or plain object + * @param {google.cloud.speech.v1p1beta1.Adaptation.CreateCustomClassCallback} callback Node-style callback called with the error, if any, and CustomClass + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Adaptation.prototype.createCustomClass = function createCustomClass(request, callback) { + return this.rpcCall(createCustomClass, $root.google.cloud.speech.v1p1beta1.CreateCustomClassRequest, $root.google.cloud.speech.v1p1beta1.CustomClass, request, callback); + }, "name", { value: "CreateCustomClass" }); + + /** + * Calls CreateCustomClass. + * @function createCustomClass + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.ICreateCustomClassRequest} request CreateCustomClassRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#getCustomClass}. + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @typedef GetCustomClassCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v1p1beta1.CustomClass} [response] CustomClass + */ + + /** + * Calls GetCustomClass. + * @function getCustomClass + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IGetCustomClassRequest} request GetCustomClassRequest message or plain object + * @param {google.cloud.speech.v1p1beta1.Adaptation.GetCustomClassCallback} callback Node-style callback called with the error, if any, and CustomClass + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Adaptation.prototype.getCustomClass = function getCustomClass(request, callback) { + return this.rpcCall(getCustomClass, $root.google.cloud.speech.v1p1beta1.GetCustomClassRequest, $root.google.cloud.speech.v1p1beta1.CustomClass, request, callback); + }, "name", { value: "GetCustomClass" }); + + /** + * Calls GetCustomClass. + * @function getCustomClass + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IGetCustomClassRequest} request GetCustomClassRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#listCustomClasses}. + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @typedef ListCustomClassesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v1p1beta1.ListCustomClassesResponse} [response] ListCustomClassesResponse + */ + + /** + * Calls ListCustomClasses. + * @function listCustomClasses + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IListCustomClassesRequest} request ListCustomClassesRequest message or plain object + * @param {google.cloud.speech.v1p1beta1.Adaptation.ListCustomClassesCallback} callback Node-style callback called with the error, if any, and ListCustomClassesResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Adaptation.prototype.listCustomClasses = function listCustomClasses(request, callback) { + return this.rpcCall(listCustomClasses, $root.google.cloud.speech.v1p1beta1.ListCustomClassesRequest, $root.google.cloud.speech.v1p1beta1.ListCustomClassesResponse, request, callback); + }, "name", { value: "ListCustomClasses" }); + + /** + * Calls ListCustomClasses. + * @function listCustomClasses + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IListCustomClassesRequest} request ListCustomClassesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#updateCustomClass}. + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @typedef UpdateCustomClassCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.speech.v1p1beta1.CustomClass} [response] CustomClass + */ + + /** + * Calls UpdateCustomClass. + * @function updateCustomClass + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest} request UpdateCustomClassRequest message or plain object + * @param {google.cloud.speech.v1p1beta1.Adaptation.UpdateCustomClassCallback} callback Node-style callback called with the error, if any, and CustomClass + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Adaptation.prototype.updateCustomClass = function updateCustomClass(request, callback) { + return this.rpcCall(updateCustomClass, $root.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest, $root.google.cloud.speech.v1p1beta1.CustomClass, request, callback); + }, "name", { value: "UpdateCustomClass" }); + + /** + * Calls UpdateCustomClass. + * @function updateCustomClass + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest} request UpdateCustomClassRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.cloud.speech.v1p1beta1.Adaptation#deleteCustomClass}. + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @typedef DeleteCustomClassCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteCustomClass. + * @function deleteCustomClass + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest} request DeleteCustomClassRequest message or plain object + * @param {google.cloud.speech.v1p1beta1.Adaptation.DeleteCustomClassCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Adaptation.prototype.deleteCustomClass = function deleteCustomClass(request, callback) { + return this.rpcCall(deleteCustomClass, $root.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteCustomClass" }); + + /** + * Calls DeleteCustomClass. + * @function deleteCustomClass + * @memberof google.cloud.speech.v1p1beta1.Adaptation + * @instance + * @param {google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest} request DeleteCustomClassRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return Adaptation; + })(); + + v1p1beta1.CreatePhraseSetRequest = (function() { + + /** + * Properties of a CreatePhraseSetRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @interface ICreatePhraseSetRequest + * @property {string|null} [parent] CreatePhraseSetRequest parent + * @property {string|null} [phraseSetId] CreatePhraseSetRequest phraseSetId + * @property {google.cloud.speech.v1p1beta1.IPhraseSet|null} [phraseSet] CreatePhraseSetRequest phraseSet + */ + + /** + * Constructs a new CreatePhraseSetRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents a CreatePhraseSetRequest. + * @implements ICreatePhraseSetRequest + * @constructor + * @param {google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest=} [properties] Properties to set + */ + function CreatePhraseSetRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreatePhraseSetRequest parent. + * @member {string} parent + * @memberof google.cloud.speech.v1p1beta1.CreatePhraseSetRequest + * @instance + */ + CreatePhraseSetRequest.prototype.parent = ""; + + /** + * CreatePhraseSetRequest phraseSetId. + * @member {string} phraseSetId + * @memberof google.cloud.speech.v1p1beta1.CreatePhraseSetRequest + * @instance + */ + CreatePhraseSetRequest.prototype.phraseSetId = ""; + + /** + * CreatePhraseSetRequest phraseSet. + * @member {google.cloud.speech.v1p1beta1.IPhraseSet|null|undefined} phraseSet + * @memberof google.cloud.speech.v1p1beta1.CreatePhraseSetRequest + * @instance + */ + CreatePhraseSetRequest.prototype.phraseSet = null; + + /** + * Creates a new CreatePhraseSetRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.CreatePhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.CreatePhraseSetRequest} CreatePhraseSetRequest instance + */ + CreatePhraseSetRequest.create = function create(properties) { + return new CreatePhraseSetRequest(properties); + }; + + /** + * Encodes the specified CreatePhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.CreatePhraseSetRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.CreatePhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest} message CreatePhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreatePhraseSetRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.phraseSetId != null && Object.hasOwnProperty.call(message, "phraseSetId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.phraseSetId); + if (message.phraseSet != null && Object.hasOwnProperty.call(message, "phraseSet")) + $root.google.cloud.speech.v1p1beta1.PhraseSet.encode(message.phraseSet, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CreatePhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.CreatePhraseSetRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.CreatePhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest} message CreatePhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreatePhraseSetRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreatePhraseSetRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.CreatePhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1p1beta1.CreatePhraseSetRequest} CreatePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreatePhraseSetRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.phraseSetId = reader.string(); + break; + case 3: + message.phraseSet = $root.google.cloud.speech.v1p1beta1.PhraseSet.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreatePhraseSetRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.CreatePhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.CreatePhraseSetRequest} CreatePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreatePhraseSetRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreatePhraseSetRequest message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.CreatePhraseSetRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreatePhraseSetRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.phraseSetId != null && message.hasOwnProperty("phraseSetId")) + if (!$util.isString(message.phraseSetId)) + return "phraseSetId: string expected"; + if (message.phraseSet != null && message.hasOwnProperty("phraseSet")) { + var error = $root.google.cloud.speech.v1p1beta1.PhraseSet.verify(message.phraseSet); + if (error) + return "phraseSet." + error; + } + return null; + }; + + /** + * Creates a CreatePhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.CreatePhraseSetRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.CreatePhraseSetRequest} CreatePhraseSetRequest + */ + CreatePhraseSetRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.phraseSetId != null) + message.phraseSetId = String(object.phraseSetId); + if (object.phraseSet != null) { + if (typeof object.phraseSet !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.CreatePhraseSetRequest.phraseSet: object expected"); + message.phraseSet = $root.google.cloud.speech.v1p1beta1.PhraseSet.fromObject(object.phraseSet); + } + return message; + }; + + /** + * Creates a plain object from a CreatePhraseSetRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.CreatePhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.CreatePhraseSetRequest} message CreatePhraseSetRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreatePhraseSetRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.phraseSetId = ""; + object.phraseSet = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.phraseSetId != null && message.hasOwnProperty("phraseSetId")) + object.phraseSetId = message.phraseSetId; + if (message.phraseSet != null && message.hasOwnProperty("phraseSet")) + object.phraseSet = $root.google.cloud.speech.v1p1beta1.PhraseSet.toObject(message.phraseSet, options); + return object; + }; + + /** + * Converts this CreatePhraseSetRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.CreatePhraseSetRequest + * @instance + * @returns {Object.} JSON object + */ + CreatePhraseSetRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CreatePhraseSetRequest; + })(); + + v1p1beta1.UpdatePhraseSetRequest = (function() { + + /** + * Properties of an UpdatePhraseSetRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @interface IUpdatePhraseSetRequest + * @property {google.cloud.speech.v1p1beta1.IPhraseSet|null} [phraseSet] UpdatePhraseSetRequest phraseSet + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdatePhraseSetRequest updateMask + */ + + /** + * Constructs a new UpdatePhraseSetRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents an UpdatePhraseSetRequest. + * @implements IUpdatePhraseSetRequest + * @constructor + * @param {google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest=} [properties] Properties to set + */ + function UpdatePhraseSetRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UpdatePhraseSetRequest phraseSet. + * @member {google.cloud.speech.v1p1beta1.IPhraseSet|null|undefined} phraseSet + * @memberof google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest + * @instance + */ + UpdatePhraseSetRequest.prototype.phraseSet = null; + + /** + * UpdatePhraseSetRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest + * @instance + */ + UpdatePhraseSetRequest.prototype.updateMask = null; + + /** + * Creates a new UpdatePhraseSetRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest} UpdatePhraseSetRequest instance + */ + UpdatePhraseSetRequest.create = function create(properties) { + return new UpdatePhraseSetRequest(properties); + }; + + /** + * Encodes the specified UpdatePhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest} message UpdatePhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdatePhraseSetRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.phraseSet != null && Object.hasOwnProperty.call(message, "phraseSet")) + $root.google.cloud.speech.v1p1beta1.PhraseSet.encode(message.phraseSet, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdatePhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest} message UpdatePhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdatePhraseSetRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdatePhraseSetRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest} UpdatePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdatePhraseSetRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.phraseSet = $root.google.cloud.speech.v1p1beta1.PhraseSet.decode(reader, reader.uint32()); + break; + case 2: + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdatePhraseSetRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest} UpdatePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdatePhraseSetRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdatePhraseSetRequest message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdatePhraseSetRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.phraseSet != null && message.hasOwnProperty("phraseSet")) { + var error = $root.google.cloud.speech.v1p1beta1.PhraseSet.verify(message.phraseSet); + if (error) + return "phraseSet." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdatePhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest} UpdatePhraseSetRequest + */ + UpdatePhraseSetRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest(); + if (object.phraseSet != null) { + if (typeof object.phraseSet !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest.phraseSet: object expected"); + message.phraseSet = $root.google.cloud.speech.v1p1beta1.PhraseSet.fromObject(object.phraseSet); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdatePhraseSetRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest} message UpdatePhraseSetRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdatePhraseSetRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.phraseSet = null; + object.updateMask = null; + } + if (message.phraseSet != null && message.hasOwnProperty("phraseSet")) + object.phraseSet = $root.google.cloud.speech.v1p1beta1.PhraseSet.toObject(message.phraseSet, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdatePhraseSetRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest + * @instance + * @returns {Object.} JSON object + */ + UpdatePhraseSetRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return UpdatePhraseSetRequest; + })(); + + v1p1beta1.GetPhraseSetRequest = (function() { + + /** + * Properties of a GetPhraseSetRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @interface IGetPhraseSetRequest + * @property {string|null} [name] GetPhraseSetRequest name + */ + + /** + * Constructs a new GetPhraseSetRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents a GetPhraseSetRequest. + * @implements IGetPhraseSetRequest + * @constructor + * @param {google.cloud.speech.v1p1beta1.IGetPhraseSetRequest=} [properties] Properties to set + */ + function GetPhraseSetRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetPhraseSetRequest name. + * @member {string} name + * @memberof google.cloud.speech.v1p1beta1.GetPhraseSetRequest + * @instance + */ + GetPhraseSetRequest.prototype.name = ""; + + /** + * Creates a new GetPhraseSetRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.GetPhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IGetPhraseSetRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.GetPhraseSetRequest} GetPhraseSetRequest instance + */ + GetPhraseSetRequest.create = function create(properties) { + return new GetPhraseSetRequest(properties); + }; + + /** + * Encodes the specified GetPhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.GetPhraseSetRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.GetPhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IGetPhraseSetRequest} message GetPhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetPhraseSetRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified GetPhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.GetPhraseSetRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.GetPhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IGetPhraseSetRequest} message GetPhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetPhraseSetRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetPhraseSetRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.GetPhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1p1beta1.GetPhraseSetRequest} GetPhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetPhraseSetRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1p1beta1.GetPhraseSetRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetPhraseSetRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.GetPhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.GetPhraseSetRequest} GetPhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetPhraseSetRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetPhraseSetRequest message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.GetPhraseSetRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetPhraseSetRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a GetPhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.GetPhraseSetRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.GetPhraseSetRequest} GetPhraseSetRequest + */ + GetPhraseSetRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.GetPhraseSetRequest) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.GetPhraseSetRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetPhraseSetRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.GetPhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.GetPhraseSetRequest} message GetPhraseSetRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetPhraseSetRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetPhraseSetRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.GetPhraseSetRequest + * @instance + * @returns {Object.} JSON object + */ + GetPhraseSetRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetPhraseSetRequest; + })(); + + v1p1beta1.ListPhraseSetRequest = (function() { + + /** + * Properties of a ListPhraseSetRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @interface IListPhraseSetRequest + * @property {string|null} [parent] ListPhraseSetRequest parent + * @property {number|null} [pageSize] ListPhraseSetRequest pageSize + * @property {string|null} [pageToken] ListPhraseSetRequest pageToken + */ + + /** + * Constructs a new ListPhraseSetRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents a ListPhraseSetRequest. + * @implements IListPhraseSetRequest + * @constructor + * @param {google.cloud.speech.v1p1beta1.IListPhraseSetRequest=} [properties] Properties to set + */ + function ListPhraseSetRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListPhraseSetRequest parent. + * @member {string} parent + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetRequest + * @instance + */ + ListPhraseSetRequest.prototype.parent = ""; + + /** + * ListPhraseSetRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetRequest + * @instance + */ + ListPhraseSetRequest.prototype.pageSize = 0; + + /** + * ListPhraseSetRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetRequest + * @instance + */ + ListPhraseSetRequest.prototype.pageToken = ""; + + /** + * Creates a new ListPhraseSetRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IListPhraseSetRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.ListPhraseSetRequest} ListPhraseSetRequest instance + */ + ListPhraseSetRequest.create = function create(properties) { + return new ListPhraseSetRequest(properties); + }; + + /** + * Encodes the specified ListPhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListPhraseSetRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IListPhraseSetRequest} message ListPhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListPhraseSetRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + return writer; + }; + + /** + * Encodes the specified ListPhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListPhraseSetRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IListPhraseSetRequest} message ListPhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListPhraseSetRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListPhraseSetRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1p1beta1.ListPhraseSetRequest} ListPhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListPhraseSetRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1p1beta1.ListPhraseSetRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageSize = reader.int32(); + break; + case 3: + message.pageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListPhraseSetRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.ListPhraseSetRequest} ListPhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListPhraseSetRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListPhraseSetRequest message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListPhraseSetRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + return null; + }; + + /** + * Creates a ListPhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.ListPhraseSetRequest} ListPhraseSetRequest + */ + ListPhraseSetRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.ListPhraseSetRequest) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.ListPhraseSetRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListPhraseSetRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.ListPhraseSetRequest} message ListPhraseSetRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListPhraseSetRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + return object; + }; + + /** + * Converts this ListPhraseSetRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetRequest + * @instance + * @returns {Object.} JSON object + */ + ListPhraseSetRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListPhraseSetRequest; + })(); + + v1p1beta1.ListPhraseSetResponse = (function() { + + /** + * Properties of a ListPhraseSetResponse. + * @memberof google.cloud.speech.v1p1beta1 + * @interface IListPhraseSetResponse + * @property {Array.|null} [phraseSets] ListPhraseSetResponse phraseSets + * @property {string|null} [nextPageToken] ListPhraseSetResponse nextPageToken + */ + + /** + * Constructs a new ListPhraseSetResponse. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents a ListPhraseSetResponse. + * @implements IListPhraseSetResponse + * @constructor + * @param {google.cloud.speech.v1p1beta1.IListPhraseSetResponse=} [properties] Properties to set + */ + function ListPhraseSetResponse(properties) { + this.phraseSets = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListPhraseSetResponse phraseSets. + * @member {Array.} phraseSets + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetResponse + * @instance + */ + ListPhraseSetResponse.prototype.phraseSets = $util.emptyArray; + + /** + * ListPhraseSetResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetResponse + * @instance + */ + ListPhraseSetResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListPhraseSetResponse instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetResponse + * @static + * @param {google.cloud.speech.v1p1beta1.IListPhraseSetResponse=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.ListPhraseSetResponse} ListPhraseSetResponse instance + */ + ListPhraseSetResponse.create = function create(properties) { + return new ListPhraseSetResponse(properties); + }; + + /** + * Encodes the specified ListPhraseSetResponse message. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListPhraseSetResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetResponse + * @static + * @param {google.cloud.speech.v1p1beta1.IListPhraseSetResponse} message ListPhraseSetResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListPhraseSetResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.phraseSets != null && message.phraseSets.length) + for (var i = 0; i < message.phraseSets.length; ++i) + $root.google.cloud.speech.v1p1beta1.PhraseSet.encode(message.phraseSets[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified ListPhraseSetResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListPhraseSetResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetResponse + * @static + * @param {google.cloud.speech.v1p1beta1.IListPhraseSetResponse} message ListPhraseSetResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListPhraseSetResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListPhraseSetResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1p1beta1.ListPhraseSetResponse} ListPhraseSetResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListPhraseSetResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1p1beta1.ListPhraseSetResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.phraseSets && message.phraseSets.length)) + message.phraseSets = []; + message.phraseSets.push($root.google.cloud.speech.v1p1beta1.PhraseSet.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListPhraseSetResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.ListPhraseSetResponse} ListPhraseSetResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListPhraseSetResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListPhraseSetResponse message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListPhraseSetResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.phraseSets != null && message.hasOwnProperty("phraseSets")) { + if (!Array.isArray(message.phraseSets)) + return "phraseSets: array expected"; + for (var i = 0; i < message.phraseSets.length; ++i) { + var error = $root.google.cloud.speech.v1p1beta1.PhraseSet.verify(message.phraseSets[i]); + if (error) + return "phraseSets." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListPhraseSetResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.ListPhraseSetResponse} ListPhraseSetResponse + */ + ListPhraseSetResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.ListPhraseSetResponse) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.ListPhraseSetResponse(); + if (object.phraseSets) { + if (!Array.isArray(object.phraseSets)) + throw TypeError(".google.cloud.speech.v1p1beta1.ListPhraseSetResponse.phraseSets: array expected"); + message.phraseSets = []; + for (var i = 0; i < object.phraseSets.length; ++i) { + if (typeof object.phraseSets[i] !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.ListPhraseSetResponse.phraseSets: object expected"); + message.phraseSets[i] = $root.google.cloud.speech.v1p1beta1.PhraseSet.fromObject(object.phraseSets[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListPhraseSetResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetResponse + * @static + * @param {google.cloud.speech.v1p1beta1.ListPhraseSetResponse} message ListPhraseSetResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListPhraseSetResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.phraseSets = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.phraseSets && message.phraseSets.length) { + object.phraseSets = []; + for (var j = 0; j < message.phraseSets.length; ++j) + object.phraseSets[j] = $root.google.cloud.speech.v1p1beta1.PhraseSet.toObject(message.phraseSets[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListPhraseSetResponse to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.ListPhraseSetResponse + * @instance + * @returns {Object.} JSON object + */ + ListPhraseSetResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListPhraseSetResponse; + })(); + + v1p1beta1.DeletePhraseSetRequest = (function() { + + /** + * Properties of a DeletePhraseSetRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @interface IDeletePhraseSetRequest + * @property {string|null} [name] DeletePhraseSetRequest name + */ + + /** + * Constructs a new DeletePhraseSetRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents a DeletePhraseSetRequest. + * @implements IDeletePhraseSetRequest + * @constructor + * @param {google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest=} [properties] Properties to set + */ + function DeletePhraseSetRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeletePhraseSetRequest name. + * @member {string} name + * @memberof google.cloud.speech.v1p1beta1.DeletePhraseSetRequest + * @instance + */ + DeletePhraseSetRequest.prototype.name = ""; + + /** + * Creates a new DeletePhraseSetRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.DeletePhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.DeletePhraseSetRequest} DeletePhraseSetRequest instance + */ + DeletePhraseSetRequest.create = function create(properties) { + return new DeletePhraseSetRequest(properties); + }; + + /** + * Encodes the specified DeletePhraseSetRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.DeletePhraseSetRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.DeletePhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest} message DeletePhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeletePhraseSetRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified DeletePhraseSetRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.DeletePhraseSetRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.DeletePhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest} message DeletePhraseSetRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeletePhraseSetRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeletePhraseSetRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.DeletePhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1p1beta1.DeletePhraseSetRequest} DeletePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeletePhraseSetRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeletePhraseSetRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.DeletePhraseSetRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.DeletePhraseSetRequest} DeletePhraseSetRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeletePhraseSetRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeletePhraseSetRequest message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.DeletePhraseSetRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeletePhraseSetRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a DeletePhraseSetRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.DeletePhraseSetRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.DeletePhraseSetRequest} DeletePhraseSetRequest + */ + DeletePhraseSetRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeletePhraseSetRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.DeletePhraseSetRequest + * @static + * @param {google.cloud.speech.v1p1beta1.DeletePhraseSetRequest} message DeletePhraseSetRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeletePhraseSetRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this DeletePhraseSetRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.DeletePhraseSetRequest + * @instance + * @returns {Object.} JSON object + */ + DeletePhraseSetRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return DeletePhraseSetRequest; + })(); + + v1p1beta1.CreateCustomClassRequest = (function() { + + /** + * Properties of a CreateCustomClassRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @interface ICreateCustomClassRequest + * @property {string|null} [parent] CreateCustomClassRequest parent + * @property {string|null} [customClassId] CreateCustomClassRequest customClassId + * @property {google.cloud.speech.v1p1beta1.ICustomClass|null} [customClass] CreateCustomClassRequest customClass + */ + + /** + * Constructs a new CreateCustomClassRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents a CreateCustomClassRequest. + * @implements ICreateCustomClassRequest + * @constructor + * @param {google.cloud.speech.v1p1beta1.ICreateCustomClassRequest=} [properties] Properties to set + */ + function CreateCustomClassRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateCustomClassRequest parent. + * @member {string} parent + * @memberof google.cloud.speech.v1p1beta1.CreateCustomClassRequest + * @instance + */ + CreateCustomClassRequest.prototype.parent = ""; + + /** + * CreateCustomClassRequest customClassId. + * @member {string} customClassId + * @memberof google.cloud.speech.v1p1beta1.CreateCustomClassRequest + * @instance + */ + CreateCustomClassRequest.prototype.customClassId = ""; + + /** + * CreateCustomClassRequest customClass. + * @member {google.cloud.speech.v1p1beta1.ICustomClass|null|undefined} customClass + * @memberof google.cloud.speech.v1p1beta1.CreateCustomClassRequest + * @instance + */ + CreateCustomClassRequest.prototype.customClass = null; + + /** + * Creates a new CreateCustomClassRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.CreateCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.ICreateCustomClassRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.CreateCustomClassRequest} CreateCustomClassRequest instance + */ + CreateCustomClassRequest.create = function create(properties) { + return new CreateCustomClassRequest(properties); + }; + + /** + * Encodes the specified CreateCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.CreateCustomClassRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.CreateCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.ICreateCustomClassRequest} message CreateCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateCustomClassRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.customClassId != null && Object.hasOwnProperty.call(message, "customClassId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.customClassId); + if (message.customClass != null && Object.hasOwnProperty.call(message, "customClass")) + $root.google.cloud.speech.v1p1beta1.CustomClass.encode(message.customClass, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CreateCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.CreateCustomClassRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.CreateCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.ICreateCustomClassRequest} message CreateCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateCustomClassRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateCustomClassRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.CreateCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1p1beta1.CreateCustomClassRequest} CreateCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateCustomClassRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1p1beta1.CreateCustomClassRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.customClassId = reader.string(); + break; + case 3: + message.customClass = $root.google.cloud.speech.v1p1beta1.CustomClass.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateCustomClassRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.CreateCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.CreateCustomClassRequest} CreateCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateCustomClassRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateCustomClassRequest message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.CreateCustomClassRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateCustomClassRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.customClassId != null && message.hasOwnProperty("customClassId")) + if (!$util.isString(message.customClassId)) + return "customClassId: string expected"; + if (message.customClass != null && message.hasOwnProperty("customClass")) { + var error = $root.google.cloud.speech.v1p1beta1.CustomClass.verify(message.customClass); + if (error) + return "customClass." + error; + } + return null; + }; + + /** + * Creates a CreateCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.CreateCustomClassRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.CreateCustomClassRequest} CreateCustomClassRequest + */ + CreateCustomClassRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.CreateCustomClassRequest) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.CreateCustomClassRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.customClassId != null) + message.customClassId = String(object.customClassId); + if (object.customClass != null) { + if (typeof object.customClass !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.CreateCustomClassRequest.customClass: object expected"); + message.customClass = $root.google.cloud.speech.v1p1beta1.CustomClass.fromObject(object.customClass); + } + return message; + }; + + /** + * Creates a plain object from a CreateCustomClassRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.CreateCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.CreateCustomClassRequest} message CreateCustomClassRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateCustomClassRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.customClassId = ""; + object.customClass = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.customClassId != null && message.hasOwnProperty("customClassId")) + object.customClassId = message.customClassId; + if (message.customClass != null && message.hasOwnProperty("customClass")) + object.customClass = $root.google.cloud.speech.v1p1beta1.CustomClass.toObject(message.customClass, options); + return object; + }; + + /** + * Converts this CreateCustomClassRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.CreateCustomClassRequest + * @instance + * @returns {Object.} JSON object + */ + CreateCustomClassRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return CreateCustomClassRequest; + })(); + + v1p1beta1.UpdateCustomClassRequest = (function() { + + /** + * Properties of an UpdateCustomClassRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @interface IUpdateCustomClassRequest + * @property {google.cloud.speech.v1p1beta1.ICustomClass|null} [customClass] UpdateCustomClassRequest customClass + * @property {google.protobuf.IFieldMask|null} [updateMask] UpdateCustomClassRequest updateMask + */ + + /** + * Constructs a new UpdateCustomClassRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents an UpdateCustomClassRequest. + * @implements IUpdateCustomClassRequest + * @constructor + * @param {google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest=} [properties] Properties to set + */ + function UpdateCustomClassRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UpdateCustomClassRequest customClass. + * @member {google.cloud.speech.v1p1beta1.ICustomClass|null|undefined} customClass + * @memberof google.cloud.speech.v1p1beta1.UpdateCustomClassRequest + * @instance + */ + UpdateCustomClassRequest.prototype.customClass = null; + + /** + * UpdateCustomClassRequest updateMask. + * @member {google.protobuf.IFieldMask|null|undefined} updateMask + * @memberof google.cloud.speech.v1p1beta1.UpdateCustomClassRequest + * @instance + */ + UpdateCustomClassRequest.prototype.updateMask = null; + + /** + * Creates a new UpdateCustomClassRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.UpdateCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.UpdateCustomClassRequest} UpdateCustomClassRequest instance + */ + UpdateCustomClassRequest.create = function create(properties) { + return new UpdateCustomClassRequest(properties); + }; + + /** + * Encodes the specified UpdateCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.UpdateCustomClassRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.UpdateCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest} message UpdateCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCustomClassRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.customClass != null && Object.hasOwnProperty.call(message, "customClass")) + $root.google.cloud.speech.v1p1beta1.CustomClass.encode(message.customClass, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.updateMask != null && Object.hasOwnProperty.call(message, "updateMask")) + $root.google.protobuf.FieldMask.encode(message.updateMask, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified UpdateCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.UpdateCustomClassRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.UpdateCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest} message UpdateCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UpdateCustomClassRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UpdateCustomClassRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.UpdateCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1p1beta1.UpdateCustomClassRequest} UpdateCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCustomClassRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.customClass = $root.google.cloud.speech.v1p1beta1.CustomClass.decode(reader, reader.uint32()); + break; + case 2: + message.updateMask = $root.google.protobuf.FieldMask.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UpdateCustomClassRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.UpdateCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.UpdateCustomClassRequest} UpdateCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UpdateCustomClassRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UpdateCustomClassRequest message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.UpdateCustomClassRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UpdateCustomClassRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.customClass != null && message.hasOwnProperty("customClass")) { + var error = $root.google.cloud.speech.v1p1beta1.CustomClass.verify(message.customClass); + if (error) + return "customClass." + error; + } + if (message.updateMask != null && message.hasOwnProperty("updateMask")) { + var error = $root.google.protobuf.FieldMask.verify(message.updateMask); + if (error) + return "updateMask." + error; + } + return null; + }; + + /** + * Creates an UpdateCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.UpdateCustomClassRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.UpdateCustomClassRequest} UpdateCustomClassRequest + */ + UpdateCustomClassRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest(); + if (object.customClass != null) { + if (typeof object.customClass !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.UpdateCustomClassRequest.customClass: object expected"); + message.customClass = $root.google.cloud.speech.v1p1beta1.CustomClass.fromObject(object.customClass); + } + if (object.updateMask != null) { + if (typeof object.updateMask !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.UpdateCustomClassRequest.updateMask: object expected"); + message.updateMask = $root.google.protobuf.FieldMask.fromObject(object.updateMask); + } + return message; + }; + + /** + * Creates a plain object from an UpdateCustomClassRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.UpdateCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.UpdateCustomClassRequest} message UpdateCustomClassRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UpdateCustomClassRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.customClass = null; + object.updateMask = null; + } + if (message.customClass != null && message.hasOwnProperty("customClass")) + object.customClass = $root.google.cloud.speech.v1p1beta1.CustomClass.toObject(message.customClass, options); + if (message.updateMask != null && message.hasOwnProperty("updateMask")) + object.updateMask = $root.google.protobuf.FieldMask.toObject(message.updateMask, options); + return object; + }; + + /** + * Converts this UpdateCustomClassRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.UpdateCustomClassRequest + * @instance + * @returns {Object.} JSON object + */ + UpdateCustomClassRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return UpdateCustomClassRequest; + })(); + + v1p1beta1.GetCustomClassRequest = (function() { + + /** + * Properties of a GetCustomClassRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @interface IGetCustomClassRequest + * @property {string|null} [name] GetCustomClassRequest name + */ + + /** + * Constructs a new GetCustomClassRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents a GetCustomClassRequest. + * @implements IGetCustomClassRequest + * @constructor + * @param {google.cloud.speech.v1p1beta1.IGetCustomClassRequest=} [properties] Properties to set + */ + function GetCustomClassRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetCustomClassRequest name. + * @member {string} name + * @memberof google.cloud.speech.v1p1beta1.GetCustomClassRequest + * @instance + */ + GetCustomClassRequest.prototype.name = ""; + + /** + * Creates a new GetCustomClassRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.GetCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IGetCustomClassRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.GetCustomClassRequest} GetCustomClassRequest instance + */ + GetCustomClassRequest.create = function create(properties) { + return new GetCustomClassRequest(properties); + }; + + /** + * Encodes the specified GetCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.GetCustomClassRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.GetCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IGetCustomClassRequest} message GetCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCustomClassRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified GetCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.GetCustomClassRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.GetCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IGetCustomClassRequest} message GetCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetCustomClassRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetCustomClassRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.GetCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1p1beta1.GetCustomClassRequest} GetCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCustomClassRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1p1beta1.GetCustomClassRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetCustomClassRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.GetCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.GetCustomClassRequest} GetCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetCustomClassRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetCustomClassRequest message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.GetCustomClassRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetCustomClassRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a GetCustomClassRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.GetCustomClassRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.GetCustomClassRequest} GetCustomClassRequest + */ + GetCustomClassRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.GetCustomClassRequest) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.GetCustomClassRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetCustomClassRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.GetCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.GetCustomClassRequest} message GetCustomClassRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetCustomClassRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetCustomClassRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.GetCustomClassRequest + * @instance + * @returns {Object.} JSON object + */ + GetCustomClassRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return GetCustomClassRequest; + })(); + + v1p1beta1.ListCustomClassesRequest = (function() { + + /** + * Properties of a ListCustomClassesRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @interface IListCustomClassesRequest + * @property {string|null} [parent] ListCustomClassesRequest parent + * @property {number|null} [pageSize] ListCustomClassesRequest pageSize + * @property {string|null} [pageToken] ListCustomClassesRequest pageToken + */ + + /** + * Constructs a new ListCustomClassesRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents a ListCustomClassesRequest. + * @implements IListCustomClassesRequest + * @constructor + * @param {google.cloud.speech.v1p1beta1.IListCustomClassesRequest=} [properties] Properties to set + */ + function ListCustomClassesRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListCustomClassesRequest parent. + * @member {string} parent + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesRequest + * @instance + */ + ListCustomClassesRequest.prototype.parent = ""; + + /** + * ListCustomClassesRequest pageSize. + * @member {number} pageSize + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesRequest + * @instance + */ + ListCustomClassesRequest.prototype.pageSize = 0; + + /** + * ListCustomClassesRequest pageToken. + * @member {string} pageToken + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesRequest + * @instance + */ + ListCustomClassesRequest.prototype.pageToken = ""; + + /** + * Creates a new ListCustomClassesRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IListCustomClassesRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.ListCustomClassesRequest} ListCustomClassesRequest instance + */ + ListCustomClassesRequest.create = function create(properties) { + return new ListCustomClassesRequest(properties); + }; + + /** + * Encodes the specified ListCustomClassesRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListCustomClassesRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IListCustomClassesRequest} message ListCustomClassesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCustomClassesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + return writer; + }; + + /** + * Encodes the specified ListCustomClassesRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListCustomClassesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IListCustomClassesRequest} message ListCustomClassesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCustomClassesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListCustomClassesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1p1beta1.ListCustomClassesRequest} ListCustomClassesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCustomClassesRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1p1beta1.ListCustomClassesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.parent = reader.string(); + break; + case 2: + message.pageSize = reader.int32(); + break; + case 3: + message.pageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListCustomClassesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.ListCustomClassesRequest} ListCustomClassesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCustomClassesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListCustomClassesRequest message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListCustomClassesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + return null; + }; + + /** + * Creates a ListCustomClassesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.ListCustomClassesRequest} ListCustomClassesRequest + */ + ListCustomClassesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.ListCustomClassesRequest) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.ListCustomClassesRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListCustomClassesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesRequest + * @static + * @param {google.cloud.speech.v1p1beta1.ListCustomClassesRequest} message ListCustomClassesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCustomClassesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + return object; + }; + + /** + * Converts this ListCustomClassesRequest to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesRequest + * @instance + * @returns {Object.} JSON object + */ + ListCustomClassesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListCustomClassesRequest; + })(); + + v1p1beta1.ListCustomClassesResponse = (function() { + + /** + * Properties of a ListCustomClassesResponse. + * @memberof google.cloud.speech.v1p1beta1 + * @interface IListCustomClassesResponse + * @property {Array.|null} [customClasses] ListCustomClassesResponse customClasses + * @property {string|null} [nextPageToken] ListCustomClassesResponse nextPageToken + */ + + /** + * Constructs a new ListCustomClassesResponse. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents a ListCustomClassesResponse. + * @implements IListCustomClassesResponse + * @constructor + * @param {google.cloud.speech.v1p1beta1.IListCustomClassesResponse=} [properties] Properties to set + */ + function ListCustomClassesResponse(properties) { + this.customClasses = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListCustomClassesResponse customClasses. + * @member {Array.} customClasses + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesResponse + * @instance + */ + ListCustomClassesResponse.prototype.customClasses = $util.emptyArray; + + /** + * ListCustomClassesResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesResponse + * @instance + */ + ListCustomClassesResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListCustomClassesResponse instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesResponse + * @static + * @param {google.cloud.speech.v1p1beta1.IListCustomClassesResponse=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.ListCustomClassesResponse} ListCustomClassesResponse instance + */ + ListCustomClassesResponse.create = function create(properties) { + return new ListCustomClassesResponse(properties); + }; + + /** + * Encodes the specified ListCustomClassesResponse message. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListCustomClassesResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesResponse + * @static + * @param {google.cloud.speech.v1p1beta1.IListCustomClassesResponse} message ListCustomClassesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCustomClassesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.customClasses != null && message.customClasses.length) + for (var i = 0; i < message.customClasses.length; ++i) + $root.google.cloud.speech.v1p1beta1.CustomClass.encode(message.customClasses[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified ListCustomClassesResponse message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.ListCustomClassesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesResponse + * @static + * @param {google.cloud.speech.v1p1beta1.IListCustomClassesResponse} message ListCustomClassesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListCustomClassesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListCustomClassesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1p1beta1.ListCustomClassesResponse} ListCustomClassesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCustomClassesResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1p1beta1.ListCustomClassesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.customClasses && message.customClasses.length)) + message.customClasses = []; + message.customClasses.push($root.google.cloud.speech.v1p1beta1.CustomClass.decode(reader, reader.uint32())); + break; + case 2: + message.nextPageToken = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListCustomClassesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.ListCustomClassesResponse} ListCustomClassesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListCustomClassesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListCustomClassesResponse message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListCustomClassesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.customClasses != null && message.hasOwnProperty("customClasses")) { + if (!Array.isArray(message.customClasses)) + return "customClasses: array expected"; + for (var i = 0; i < message.customClasses.length; ++i) { + var error = $root.google.cloud.speech.v1p1beta1.CustomClass.verify(message.customClasses[i]); + if (error) + return "customClasses." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListCustomClassesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.ListCustomClassesResponse} ListCustomClassesResponse + */ + ListCustomClassesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.ListCustomClassesResponse) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.ListCustomClassesResponse(); + if (object.customClasses) { + if (!Array.isArray(object.customClasses)) + throw TypeError(".google.cloud.speech.v1p1beta1.ListCustomClassesResponse.customClasses: array expected"); + message.customClasses = []; + for (var i = 0; i < object.customClasses.length; ++i) { + if (typeof object.customClasses[i] !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.ListCustomClassesResponse.customClasses: object expected"); + message.customClasses[i] = $root.google.cloud.speech.v1p1beta1.CustomClass.fromObject(object.customClasses[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListCustomClassesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesResponse + * @static + * @param {google.cloud.speech.v1p1beta1.ListCustomClassesResponse} message ListCustomClassesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListCustomClassesResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.customClasses = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.customClasses && message.customClasses.length) { + object.customClasses = []; + for (var j = 0; j < message.customClasses.length; ++j) + object.customClasses[j] = $root.google.cloud.speech.v1p1beta1.CustomClass.toObject(message.customClasses[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListCustomClassesResponse to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.ListCustomClassesResponse + * @instance + * @returns {Object.} JSON object + */ + ListCustomClassesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ListCustomClassesResponse; + })(); + + v1p1beta1.DeleteCustomClassRequest = (function() { + + /** + * Properties of a DeleteCustomClassRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @interface IDeleteCustomClassRequest + * @property {string|null} [name] DeleteCustomClassRequest name + */ + + /** + * Constructs a new DeleteCustomClassRequest. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents a DeleteCustomClassRequest. + * @implements IDeleteCustomClassRequest + * @constructor + * @param {google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest=} [properties] Properties to set + */ + function DeleteCustomClassRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteCustomClassRequest name. + * @member {string} name + * @memberof google.cloud.speech.v1p1beta1.DeleteCustomClassRequest + * @instance + */ + DeleteCustomClassRequest.prototype.name = ""; + + /** + * Creates a new DeleteCustomClassRequest instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.DeleteCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.DeleteCustomClassRequest} DeleteCustomClassRequest instance + */ + DeleteCustomClassRequest.create = function create(properties) { + return new DeleteCustomClassRequest(properties); + }; + + /** + * Encodes the specified DeleteCustomClassRequest message. Does not implicitly {@link google.cloud.speech.v1p1beta1.DeleteCustomClassRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.DeleteCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest} message DeleteCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteCustomClassRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified DeleteCustomClassRequest message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.DeleteCustomClassRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.DeleteCustomClassRequest + * @static + * @param {google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest} message DeleteCustomClassRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteCustomClassRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteCustomClassRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.DeleteCustomClassRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1p1beta1.DeleteCustomClassRequest} DeleteCustomClassRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteCustomClassRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteCustomClassRequest message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation + * @memberof google.cloud.speech.v1p1beta1.DeleteCustomClassRequest * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.cloud.speech.v1p1beta1.SpeechAdaptation} SpeechAdaptation + * @returns {google.cloud.speech.v1p1beta1.DeleteCustomClassRequest} DeleteCustomClassRequest * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - SpeechAdaptation.decodeDelimited = function decodeDelimited(reader) { + DeleteCustomClassRequest.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a SpeechAdaptation message. + * Verifies a DeleteCustomClassRequest message. * @function verify - * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation + * @memberof google.cloud.speech.v1p1beta1.DeleteCustomClassRequest * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - SpeechAdaptation.verify = function verify(message) { + DeleteCustomClassRequest.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.phraseSets != null && message.hasOwnProperty("phraseSets")) { - if (!Array.isArray(message.phraseSets)) - return "phraseSets: array expected"; - for (var i = 0; i < message.phraseSets.length; ++i) { - var error = $root.google.cloud.speech.v1p1beta1.PhraseSet.verify(message.phraseSets[i]); - if (error) - return "phraseSets." + error; - } - } - if (message.customClasses != null && message.hasOwnProperty("customClasses")) { - if (!Array.isArray(message.customClasses)) - return "customClasses: array expected"; - for (var i = 0; i < message.customClasses.length; ++i) { - var error = $root.google.cloud.speech.v1p1beta1.CustomClass.verify(message.customClasses[i]); - if (error) - return "customClasses." + error; - } - } + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; return null; }; /** - * Creates a SpeechAdaptation message from a plain object. Also converts values to their respective internal types. + * Creates a DeleteCustomClassRequest message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation + * @memberof google.cloud.speech.v1p1beta1.DeleteCustomClassRequest * @static * @param {Object.} object Plain object - * @returns {google.cloud.speech.v1p1beta1.SpeechAdaptation} SpeechAdaptation + * @returns {google.cloud.speech.v1p1beta1.DeleteCustomClassRequest} DeleteCustomClassRequest */ - SpeechAdaptation.fromObject = function fromObject(object) { - if (object instanceof $root.google.cloud.speech.v1p1beta1.SpeechAdaptation) + DeleteCustomClassRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest) return object; - var message = new $root.google.cloud.speech.v1p1beta1.SpeechAdaptation(); - if (object.phraseSets) { - if (!Array.isArray(object.phraseSets)) - throw TypeError(".google.cloud.speech.v1p1beta1.SpeechAdaptation.phraseSets: array expected"); - message.phraseSets = []; - for (var i = 0; i < object.phraseSets.length; ++i) { - if (typeof object.phraseSets[i] !== "object") - throw TypeError(".google.cloud.speech.v1p1beta1.SpeechAdaptation.phraseSets: object expected"); - message.phraseSets[i] = $root.google.cloud.speech.v1p1beta1.PhraseSet.fromObject(object.phraseSets[i]); - } - } - if (object.customClasses) { - if (!Array.isArray(object.customClasses)) - throw TypeError(".google.cloud.speech.v1p1beta1.SpeechAdaptation.customClasses: array expected"); - message.customClasses = []; - for (var i = 0; i < object.customClasses.length; ++i) { - if (typeof object.customClasses[i] !== "object") - throw TypeError(".google.cloud.speech.v1p1beta1.SpeechAdaptation.customClasses: object expected"); - message.customClasses[i] = $root.google.cloud.speech.v1p1beta1.CustomClass.fromObject(object.customClasses[i]); - } - } + var message = new $root.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest(); + if (object.name != null) + message.name = String(object.name); return message; }; /** - * Creates a plain object from a SpeechAdaptation message. Also converts values to other types if specified. + * Creates a plain object from a DeleteCustomClassRequest message. Also converts values to other types if specified. * @function toObject - * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation + * @memberof google.cloud.speech.v1p1beta1.DeleteCustomClassRequest * @static - * @param {google.cloud.speech.v1p1beta1.SpeechAdaptation} message SpeechAdaptation + * @param {google.cloud.speech.v1p1beta1.DeleteCustomClassRequest} message DeleteCustomClassRequest * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - SpeechAdaptation.toObject = function toObject(message, options) { + DeleteCustomClassRequest.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) { - object.phraseSets = []; - object.customClasses = []; - } - if (message.phraseSets && message.phraseSets.length) { - object.phraseSets = []; - for (var j = 0; j < message.phraseSets.length; ++j) - object.phraseSets[j] = $root.google.cloud.speech.v1p1beta1.PhraseSet.toObject(message.phraseSets[j], options); - } - if (message.customClasses && message.customClasses.length) { - object.customClasses = []; - for (var j = 0; j < message.customClasses.length; ++j) - object.customClasses[j] = $root.google.cloud.speech.v1p1beta1.CustomClass.toObject(message.customClasses[j], options); - } + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; return object; }; /** - * Converts this SpeechAdaptation to JSON. + * Converts this DeleteCustomClassRequest to JSON. * @function toJSON - * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation + * @memberof google.cloud.speech.v1p1beta1.DeleteCustomClassRequest * @instance * @returns {Object.} JSON object */ - SpeechAdaptation.prototype.toJSON = function toJSON() { + DeleteCustomClassRequest.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; - return SpeechAdaptation; + return DeleteCustomClassRequest; })(); return v1p1beta1; @@ -12220,7 +15211,6 @@ * @property {number} OUTPUT_ONLY=3 OUTPUT_ONLY value * @property {number} INPUT_ONLY=4 INPUT_ONLY value * @property {number} IMMUTABLE=5 IMMUTABLE value - * @property {number} UNORDERED_LIST=6 UNORDERED_LIST value */ api.FieldBehavior = (function() { var valuesById = {}, values = Object.create(valuesById); @@ -12230,7 +15220,6 @@ values[valuesById[3] = "OUTPUT_ONLY"] = 3; values[valuesById[4] = "INPUT_ONLY"] = 4; values[valuesById[5] = "IMMUTABLE"] = 5; - values[valuesById[6] = "UNORDERED_LIST"] = 6; return values; })(); @@ -12246,7 +15235,6 @@ * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history * @property {string|null} [plural] ResourceDescriptor plural * @property {string|null} [singular] ResourceDescriptor singular - * @property {Array.|null} [style] ResourceDescriptor style */ /** @@ -12259,7 +15247,6 @@ */ function ResourceDescriptor(properties) { this.pattern = []; - this.style = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -12314,14 +15301,6 @@ */ ResourceDescriptor.prototype.singular = ""; - /** - * ResourceDescriptor style. - * @member {Array.} style - * @memberof google.api.ResourceDescriptor - * @instance - */ - ResourceDescriptor.prototype.style = $util.emptyArray; - /** * Creates a new ResourceDescriptor instance using the specified properties. * @function create @@ -12359,12 +15338,6 @@ writer.uint32(/* id 5, wireType 2 =*/42).string(message.plural); if (message.singular != null && Object.hasOwnProperty.call(message, "singular")) writer.uint32(/* id 6, wireType 2 =*/50).string(message.singular); - if (message.style != null && message.style.length) { - writer.uint32(/* id 10, wireType 2 =*/82).fork(); - for (var i = 0; i < message.style.length; ++i) - writer.int32(message.style[i]); - writer.ldelim(); - } return writer; }; @@ -12419,16 +15392,6 @@ case 6: message.singular = reader.string(); break; - case 10: - if (!(message.style && message.style.length)) - message.style = []; - if ((tag & 7) === 2) { - var end2 = reader.uint32() + reader.pos; - while (reader.pos < end2) - message.style.push(reader.int32()); - } else - message.style.push(reader.int32()); - break; default: reader.skipType(tag & 7); break; @@ -12492,18 +15455,6 @@ if (message.singular != null && message.hasOwnProperty("singular")) if (!$util.isString(message.singular)) return "singular: string expected"; - if (message.style != null && message.hasOwnProperty("style")) { - if (!Array.isArray(message.style)) - return "style: array expected"; - for (var i = 0; i < message.style.length; ++i) - switch (message.style[i]) { - default: - return "style: enum value[] expected"; - case 0: - case 1: - break; - } - } return null; }; @@ -12548,23 +15499,6 @@ message.plural = String(object.plural); if (object.singular != null) message.singular = String(object.singular); - if (object.style) { - if (!Array.isArray(object.style)) - throw TypeError(".google.api.ResourceDescriptor.style: array expected"); - message.style = []; - for (var i = 0; i < object.style.length; ++i) - switch (object.style[i]) { - default: - case "STYLE_UNSPECIFIED": - case 0: - message.style[i] = 0; - break; - case "DECLARATIVE_FRIENDLY": - case 1: - message.style[i] = 1; - break; - } - } return message; }; @@ -12581,10 +15515,8 @@ if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) { + if (options.arrays || options.defaults) object.pattern = []; - object.style = []; - } if (options.defaults) { object.type = ""; object.nameField = ""; @@ -12607,11 +15539,6 @@ object.plural = message.plural; if (message.singular != null && message.hasOwnProperty("singular")) object.singular = message.singular; - if (message.style && message.style.length) { - object.style = []; - for (var j = 0; j < message.style.length; ++j) - object.style[j] = options.enums === String ? $root.google.api.ResourceDescriptor.Style[message.style[j]] : message.style[j]; - } return object; }; @@ -12642,20 +15569,6 @@ return values; })(); - /** - * Style enum. - * @name google.api.ResourceDescriptor.Style - * @enum {number} - * @property {number} STYLE_UNSPECIFIED=0 STYLE_UNSPECIFIED value - * @property {number} DECLARATIVE_FRIENDLY=1 DECLARATIVE_FRIENDLY value - */ - ResourceDescriptor.Style = (function() { - var valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "STYLE_UNSPECIFIED"] = 0; - values[valuesById[1] = "DECLARATIVE_FRIENDLY"] = 1; - return values; - })(); - return ResourceDescriptor; })(); @@ -18398,7 +21311,6 @@ case 3: case 4: case 5: - case 6: break; } } @@ -18499,10 +21411,6 @@ case 5: message[".google.api.fieldBehavior"][i] = 5; break; - case "UNORDERED_LIST": - case 6: - message[".google.api.fieldBehavior"][i] = 6; - break; } } if (object[".google.api.resourceReference"] != null) { @@ -22415,6 +25323,209 @@ return Timestamp; })(); + protobuf.FieldMask = (function() { + + /** + * Properties of a FieldMask. + * @memberof google.protobuf + * @interface IFieldMask + * @property {Array.|null} [paths] FieldMask paths + */ + + /** + * Constructs a new FieldMask. + * @memberof google.protobuf + * @classdesc Represents a FieldMask. + * @implements IFieldMask + * @constructor + * @param {google.protobuf.IFieldMask=} [properties] Properties to set + */ + function FieldMask(properties) { + this.paths = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldMask paths. + * @member {Array.} paths + * @memberof google.protobuf.FieldMask + * @instance + */ + FieldMask.prototype.paths = $util.emptyArray; + + /** + * Creates a new FieldMask instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.IFieldMask=} [properties] Properties to set + * @returns {google.protobuf.FieldMask} FieldMask instance + */ + FieldMask.create = function create(properties) { + return new FieldMask(properties); + }; + + /** + * Encodes the specified FieldMask message. Does not implicitly {@link google.protobuf.FieldMask.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.IFieldMask} message FieldMask message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldMask.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.paths != null && message.paths.length) + for (var i = 0; i < message.paths.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.paths[i]); + return writer; + }; + + /** + * Encodes the specified FieldMask message, length delimited. Does not implicitly {@link google.protobuf.FieldMask.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.IFieldMask} message FieldMask message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldMask.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FieldMask message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldMask + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldMask} FieldMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldMask.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldMask(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (!(message.paths && message.paths.length)) + message.paths = []; + message.paths.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FieldMask message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldMask + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldMask} FieldMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldMask.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FieldMask message. + * @function verify + * @memberof google.protobuf.FieldMask + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldMask.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.paths != null && message.hasOwnProperty("paths")) { + if (!Array.isArray(message.paths)) + return "paths: array expected"; + for (var i = 0; i < message.paths.length; ++i) + if (!$util.isString(message.paths[i])) + return "paths: string[] expected"; + } + return null; + }; + + /** + * Creates a FieldMask message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldMask + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldMask} FieldMask + */ + FieldMask.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldMask) + return object; + var message = new $root.google.protobuf.FieldMask(); + if (object.paths) { + if (!Array.isArray(object.paths)) + throw TypeError(".google.protobuf.FieldMask.paths: array expected"); + message.paths = []; + for (var i = 0; i < object.paths.length; ++i) + message.paths[i] = String(object.paths[i]); + } + return message; + }; + + /** + * Creates a plain object from a FieldMask message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldMask + * @static + * @param {google.protobuf.FieldMask} message FieldMask + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldMask.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.paths = []; + if (message.paths && message.paths.length) { + object.paths = []; + for (var j = 0; j < message.paths.length; ++j) + object.paths[j] = message.paths[j]; + } + return object; + }; + + /** + * Converts this FieldMask to JSON. + * @function toJSON + * @memberof google.protobuf.FieldMask + * @instance + * @returns {Object.} JSON object + */ + FieldMask.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return FieldMask; + })(); + return protobuf; })(); diff --git a/packages/google-cloud-node/protos/protos.json b/packages/google-cloud-node/protos/protos.json index feae7e1bbc21..5c649f248804 100644 --- a/packages/google-cloud-node/protos/protos.json +++ b/packages/google-cloud-node/protos/protos.json @@ -512,7 +512,7 @@ "cc_enable_arenas": true, "go_package": "google.golang.org/genproto/googleapis/cloud/speech/v1p1beta1;speech", "java_multiple_files": true, - "java_outer_classname": "SpeechResourceProto", + "java_outer_classname": "SpeechAdaptationProto", "java_package": "com.google.cloud.speech.v1p1beta1", "objc_class_prefix": "GCS" }, @@ -1136,10 +1136,393 @@ "type": "PhraseSet", "id": 1 }, + "phraseSetReferences": { + "rule": "repeated", + "type": "string", + "id": 2 + }, "customClasses": { "rule": "repeated", "type": "CustomClass", + "id": 3 + } + } + }, + "Adaptation": { + "options": { + "(google.api.default_host)": "speech.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform" + }, + "methods": { + "CreatePhraseSet": { + "requestType": "CreatePhraseSetRequest", + "responseType": "PhraseSet", + "options": { + "(google.api.http).post": "/v1p1beta1/{parent=projects/*/locations/*}/phraseSets", + "(google.api.http).body": "*", + "(google.api.method_signature)": "parent,phrase_set,phrase_set_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1p1beta1/{parent=projects/*/locations/*}/phraseSets", + "body": "*" + } + }, + { + "(google.api.method_signature)": "parent,phrase_set,phrase_set_id" + } + ] + }, + "GetPhraseSet": { + "requestType": "GetPhraseSetRequest", + "responseType": "PhraseSet", + "options": { + "(google.api.http).get": "/v1p1beta1/{name=projects/*/locations/*/phraseSets/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1p1beta1/{name=projects/*/locations/*/phraseSets/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListPhraseSet": { + "requestType": "ListPhraseSetRequest", + "responseType": "ListPhraseSetResponse", + "options": { + "(google.api.http).get": "/v1p1beta1/{parent=projects/*/locations/*}/phraseSets", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1p1beta1/{parent=projects/*/locations/*}/phraseSets" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "UpdatePhraseSet": { + "requestType": "UpdatePhraseSetRequest", + "responseType": "PhraseSet", + "options": { + "(google.api.http).patch": "/v1p1beta1/{phrase_set.name=projects/*/locations/*/phraseSets/*}", + "(google.api.http).body": "phrase_set" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v1p1beta1/{phrase_set.name=projects/*/locations/*/phraseSets/*}", + "body": "phrase_set" + } + } + ] + }, + "DeletePhraseSet": { + "requestType": "DeletePhraseSetRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v1p1beta1/{name=projects/*/locations/*/phraseSets/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1p1beta1/{name=projects/*/locations/*/phraseSets/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "CreateCustomClass": { + "requestType": "CreateCustomClassRequest", + "responseType": "CustomClass", + "options": { + "(google.api.http).post": "/v1p1beta1/{parent=projects/*/locations/*}/customClasses", + "(google.api.http).body": "*", + "(google.api.method_signature)": "parent,custom_class,custom_class_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1p1beta1/{parent=projects/*/locations/*}/customClasses", + "body": "*" + } + }, + { + "(google.api.method_signature)": "parent,custom_class,custom_class_id" + } + ] + }, + "GetCustomClass": { + "requestType": "GetCustomClassRequest", + "responseType": "CustomClass", + "options": { + "(google.api.http).get": "/v1p1beta1/{name=projects/*/locations/*/customClasses/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1p1beta1/{name=projects/*/locations/*/customClasses/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "ListCustomClasses": { + "requestType": "ListCustomClassesRequest", + "responseType": "ListCustomClassesResponse", + "options": { + "(google.api.http).get": "/v1p1beta1/{parent=projects/*/locations/*}/customClasses", + "(google.api.method_signature)": "parent" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1p1beta1/{parent=projects/*/locations/*}/customClasses" + } + }, + { + "(google.api.method_signature)": "parent" + } + ] + }, + "UpdateCustomClass": { + "requestType": "UpdateCustomClassRequest", + "responseType": "CustomClass", + "options": { + "(google.api.http).patch": "/v1p1beta1/{custom_class.name=projects/*/locations/*/customClasses/*}", + "(google.api.http).body": "custom_class" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "patch": "/v1p1beta1/{custom_class.name=projects/*/locations/*/customClasses/*}", + "body": "custom_class" + } + } + ] + }, + "DeleteCustomClass": { + "requestType": "DeleteCustomClassRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v1p1beta1/{name=projects/*/locations/*/customClasses/*}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1p1beta1/{name=projects/*/locations/*/customClasses/*}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + } + } + }, + "CreatePhraseSetRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "speech.googleapis.com/PhraseSet" + } + }, + "phraseSetId": { + "type": "string", "id": 2 + }, + "phraseSet": { + "type": "PhraseSet", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UpdatePhraseSetRequest": { + "fields": { + "phraseSet": { + "type": "PhraseSet", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "GetPhraseSetRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/PhraseSet" + } + } + } + }, + "ListPhraseSetRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "speech.googleapis.com/PhraseSet" + } + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + } + } + }, + "ListPhraseSetResponse": { + "fields": { + "phraseSets": { + "rule": "repeated", + "type": "PhraseSet", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "DeletePhraseSetRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/PhraseSet" + } + } + } + }, + "CreateCustomClassRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "speech.googleapis.com/CustomClass" + } + }, + "customClassId": { + "type": "string", + "id": 2 + }, + "customClass": { + "type": "CustomClass", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "UpdateCustomClassRequest": { + "fields": { + "customClass": { + "type": "CustomClass", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "updateMask": { + "type": "google.protobuf.FieldMask", + "id": 2 + } + } + }, + "GetCustomClassRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/CustomClass" + } + } + } + }, + "ListCustomClassesRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "speech.googleapis.com/CustomClass" + } + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + } + } + }, + "ListCustomClassesResponse": { + "fields": { + "customClasses": { + "rule": "repeated", + "type": "CustomClass", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "DeleteCustomClassRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "speech.googleapis.com/CustomClass" + } } } } @@ -1275,8 +1658,7 @@ "REQUIRED": 2, "OUTPUT_ONLY": 3, "INPUT_ONLY": 4, - "IMMUTABLE": 5, - "UNORDERED_LIST": 6 + "IMMUTABLE": 5 } }, "resourceReference": { @@ -1321,11 +1703,6 @@ "singular": { "type": "string", "id": 6 - }, - "style": { - "rule": "repeated", - "type": "Style", - "id": 10 } }, "nested": { @@ -1335,12 +1712,6 @@ "ORIGINALLY_SINGLE_PATTERN": 1, "FUTURE_MULTI_PATTERN": 2 } - }, - "Style": { - "values": { - "STYLE_UNSPECIFIED": 0, - "DECLARATIVE_FRIENDLY": 1 - } } } }, @@ -1360,7 +1731,7 @@ }, "protobuf": { "options": { - "go_package": "google.golang.org/protobuf/types/descriptorpb", + "go_package": "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor", "java_package": "com.google.protobuf", "java_outer_classname": "DescriptorProtos", "csharp_namespace": "Google.Protobuf.Reflection", @@ -2291,6 +2662,15 @@ "id": 2 } } + }, + "FieldMask": { + "fields": { + "paths": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } } } }, diff --git a/packages/google-cloud-node/src/v1p1beta1/adaptation_client.ts b/packages/google-cloud-node/src/v1p1beta1/adaptation_client.ts new file mode 100644 index 000000000000..f97a167cbc34 --- /dev/null +++ b/packages/google-cloud-node/src/v1p1beta1/adaptation_client.ts @@ -0,0 +1,1758 @@ +// Copyright 2021 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, +} from 'google-gax'; +import * as path from 'path'; + +import {Transform} from 'stream'; +import {RequestType} from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +/** + * Client JSON configuration object, loaded from + * `src/v1p1beta1/adaptation_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './adaptation_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Service that implements Google Cloud Speech Adaptation API. + * @class + * @memberof v1p1beta1 + */ +export class AdaptationClient { + private _terminated = false; + private _opts: ClientOptions; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + adaptationStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of AdaptationClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof AdaptationClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + // For Node.js, pass the path to JSON proto file. + // For browsers, pass the JSON content. + + const nodejsProtoPath = path.join( + __dirname, + '..', + '..', + 'protos', + 'protos.json' + ); + this._protos = this._gaxGrpc.loadProto( + opts.fallback + ? // eslint-disable-next-line @typescript-eslint/no-var-requires + require('../../protos/protos.json') + : nodejsProtoPath + ); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + customClassPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/customClasses/{custom_class}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + phraseSetPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/phraseSets/{phrase_set}' + ), + projectPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listPhraseSet: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'phraseSets' + ), + listCustomClasses: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'customClasses' + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.speech.v1p1beta1.Adaptation', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.adaptationStub) { + return this.adaptationStub; + } + + // Put together the "service stub" for + // google.cloud.speech.v1p1beta1.Adaptation. + this.adaptationStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.speech.v1p1beta1.Adaptation' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.speech.v1p1beta1.Adaptation, + this._opts + ) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const adaptationStubMethods = [ + 'createPhraseSet', + 'getPhraseSet', + 'listPhraseSet', + 'updatePhraseSet', + 'deletePhraseSet', + 'createCustomClass', + 'getCustomClass', + 'listCustomClasses', + 'updateCustomClass', + 'deleteCustomClass', + ]; + for (const methodName of adaptationStubMethods) { + const callPromise = this.adaptationStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { + throw err; + } + ); + + const descriptor = this.descriptors.page[methodName] || undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.adaptationStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'speech.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'speech.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId( + callback?: Callback + ): Promise | void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- + createPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest | undefined, + {} | undefined + ] + >; + createPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * 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. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource where this phrase set will be created. + * Format: + * {api_version}/projects/{project}/locations/{location}/phraseSets + * @param {string} request.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 /{@link 0-9|a-z}-/. + * @param {google.cloud.speech.v1p1beta1.PhraseSet} request.phraseSet + * Required. The phrase set to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [PhraseSet]{@link google.cloud.speech.v1p1beta1.PhraseSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createPhraseSet(request); + */ + createPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createPhraseSet(request, options, callback); + } + getPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest | undefined, + {} | undefined + ] + >; + getPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Get a phrase set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the phrase set to retrieve. + * Format: + * {api_version}/projects/{project}/locations/{location}/phraseSets/{phrase_set} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [PhraseSet]{@link google.cloud.speech.v1p1beta1.PhraseSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getPhraseSet(request); + */ + getPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getPhraseSet(request, options, callback); + } + updatePhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest | undefined, + {} | undefined + ] + >; + updatePhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updatePhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Update a phrase set. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v1p1beta1.PhraseSet} request.phraseSet + * Required. The phrase set to update. + * + * The phrase set's `name` field is used to identify the set to be + * updated. Format: + * {api_version}/projects/{project}/locations/{location}/phraseSets/{phrase_set} + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to be updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [PhraseSet]{@link google.cloud.speech.v1p1beta1.PhraseSet}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updatePhraseSet(request); + */ + updatePhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'phrase_set.name': request.phraseSet!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updatePhraseSet(request, options, callback); + } + deletePhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest | undefined, + {} | undefined + ] + >; + deletePhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deletePhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Delete a phrase set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the phrase set to delete. + * Format: + * {api_version}/projects/{project}/locations/{location}/phraseSets/{phrase_set} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deletePhraseSet(request); + */ + deletePhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deletePhraseSet(request, options, callback); + } + createCustomClass( + request: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + ( + | protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest + | undefined + ), + {} | undefined + ] + >; + createCustomClass( + request: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createCustomClass( + request: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Create a custom class. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource where this custom class will be created. + * Format: + * {api_version}/projects/{project}/locations/{location}/customClasses + * @param {string} request.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 /{@link 0-9|a-z}-/. + * @param {google.cloud.speech.v1p1beta1.CustomClass} request.customClass + * Required. The custom class to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CustomClass]{@link google.cloud.speech.v1p1beta1.CustomClass}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.createCustomClass(request); + */ + createCustomClass( + request: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + ( + | protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest + | undefined + ), + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createCustomClass(request, options, callback); + } + getCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest | undefined, + {} | undefined + ] + >; + getCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest + | null + | undefined, + {} | null | undefined + > + ): void; + getCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Get a custom class. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the custom class to retrieve. + * Format: + * {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CustomClass]{@link google.cloud.speech.v1p1beta1.CustomClass}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.getCustomClass(request); + */ + getCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getCustomClass(request, options, callback); + } + updateCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + ( + | protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest + | undefined + ), + {} | undefined + ] + >; + updateCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest + | null + | undefined, + {} | null | undefined + > + ): void; + updateCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Update a custom class. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v1p1beta1.CustomClass} request.customClass + * Required. The custom class to update. + * + * The custom class's `name` field is used to identify the custom class to be + * updated. Format: + * {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class} + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to be updated. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CustomClass]{@link google.cloud.speech.v1p1beta1.CustomClass}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.updateCustomClass(request); + */ + updateCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + ( + | protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest + | undefined + ), + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'custom_class.name': request.customClass!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateCustomClass(request, options, callback); + } + deleteCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest + | undefined + ), + {} | undefined + ] + >; + deleteCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest + | null + | undefined, + {} | null | undefined + > + ): void; + deleteCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest + | null + | undefined, + {} | null | undefined + > + ): void; + /** + * Delete a custom class. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the custom class to delete. + * Format: + * {api_version}/projects/{project}/locations/{location}/customClasses/{custom_class} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example + * const [response] = await client.deleteCustomClass(request); + */ + deleteCustomClass( + request: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest + | undefined + ), + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + name: request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteCustomClass(request, options, callback); + } + + listPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet[], + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest | null, + protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse + ] + >; + listPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + | protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.IPhraseSet + > + ): void; + listPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + | protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.IPhraseSet + > + ): void; + /** + * List phrase sets. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of phrase set. + * Format: + * projects/{project}/locations/{location} + * @param {number} request.pageSize + * The maximum number of phrase sets to return. The service may return + * fewer than this value. If unspecified, at most 50 phrase sets will be + * returned. The maximum value is 1000; values above 1000 will be coerced to + * 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListPhraseSet` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListPhraseSet` must + * match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [PhraseSet]{@link google.cloud.speech.v1p1beta1.PhraseSet}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listPhraseSetAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listPhraseSet( + request: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + | protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.IPhraseSet + >, + callback?: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + | protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.IPhraseSet + > + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet[], + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest | null, + protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listPhraseSet(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of phrase set. + * Format: + * projects/{project}/locations/{location} + * @param {number} request.pageSize + * The maximum number of phrase sets to return. The service may return + * fewer than this value. If unspecified, at most 50 phrase sets will be + * returned. The maximum value is 1000; values above 1000 will be coerced to + * 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListPhraseSet` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListPhraseSet` must + * match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [PhraseSet]{@link google.cloud.speech.v1p1beta1.PhraseSet} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listPhraseSetAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listPhraseSetStream( + request?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listPhraseSet.createStream( + this.innerApiCalls.listPhraseSet as gax.GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listPhraseSet`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of phrase set. + * Format: + * projects/{project}/locations/{location} + * @param {number} request.pageSize + * The maximum number of phrase sets to return. The service may return + * fewer than this value. If unspecified, at most 50 phrase sets will be + * returned. The maximum value is 1000; values above 1000 will be coerced to + * 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListPhraseSet` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListPhraseSet` must + * match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [PhraseSet]{@link google.cloud.speech.v1p1beta1.PhraseSet}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listPhraseSetAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listPhraseSetAsync( + request?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listPhraseSet.asyncIterate( + this.innerApiCalls['listPhraseSet'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } + listCustomClasses( + request: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass[], + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest | null, + protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse + ] + >; + listCustomClasses( + request: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + | protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.ICustomClass + > + ): void; + listCustomClasses( + request: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + | protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.ICustomClass + > + ): void; + /** + * List custom classes. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of custom classes. + * Format: + * {api_version}/projects/{project}/locations/{location}/customClasses + * @param {number} request.pageSize + * The maximum number of custom classes to return. The service may return + * fewer than this value. If unspecified, at most 50 custom classes will be + * returned. The maximum value is 1000; values above 1000 will be coerced to + * 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListCustomClass` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListCustomClass` must + * match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [CustomClass]{@link google.cloud.speech.v1p1beta1.CustomClass}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCustomClassesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCustomClasses( + request: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + | protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.ICustomClass + >, + callback?: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + | protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.ICustomClass + > + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass[], + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest | null, + protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listCustomClasses(request, options, callback); + } + + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of custom classes. + * Format: + * {api_version}/projects/{project}/locations/{location}/customClasses + * @param {number} request.pageSize + * The maximum number of custom classes to return. The service may return + * fewer than this value. If unspecified, at most 50 custom classes will be + * returned. The maximum value is 1000; values above 1000 will be coerced to + * 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListCustomClass` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListCustomClass` must + * match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [CustomClass]{@link google.cloud.speech.v1p1beta1.CustomClass} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCustomClassesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listCustomClassesStream( + request?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + options?: CallOptions + ): Transform { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listCustomClasses.createStream( + this.innerApiCalls.listCustomClasses as gax.GaxCall, + request, + callSettings + ); + } + + /** + * Equivalent to `listCustomClasses`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of custom classes. + * Format: + * {api_version}/projects/{project}/locations/{location}/customClasses + * @param {number} request.pageSize + * The maximum number of custom classes to return. The service may return + * fewer than this value. If unspecified, at most 50 custom classes will be + * returned. The maximum value is 1000; values above 1000 will be coerced to + * 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListCustomClass` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListCustomClass` must + * match the call that provided the page token. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [CustomClass]{@link google.cloud.speech.v1p1beta1.CustomClass}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example + * const iterable = client.listCustomClassesAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + listCustomClassesAsync( + request?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + options?: CallOptions + ): AsyncIterable { + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + parent: request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listCustomClasses.asyncIterate( + this.innerApiCalls['listCustomClasses'] as GaxCall, + (request as unknown) as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified customClass resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} custom_class + * @returns {string} Resource name string. + */ + customClassPath(project: string, location: string, customClass: string) { + return this.pathTemplates.customClassPathTemplate.render({ + project: project, + location: location, + custom_class: customClass, + }); + } + + /** + * Parse the project from CustomClass resource. + * + * @param {string} customClassName + * A fully-qualified path representing CustomClass resource. + * @returns {string} A string representing the project. + */ + matchProjectFromCustomClassName(customClassName: string) { + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .project; + } + + /** + * Parse the location from CustomClass resource. + * + * @param {string} customClassName + * A fully-qualified path representing CustomClass resource. + * @returns {string} A string representing the location. + */ + matchLocationFromCustomClassName(customClassName: string) { + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .location; + } + + /** + * Parse the custom_class from CustomClass resource. + * + * @param {string} customClassName + * A fully-qualified path representing CustomClass resource. + * @returns {string} A string representing the custom_class. + */ + matchCustomClassFromCustomClassName(customClassName: string) { + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .custom_class; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project: string, location: string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified phraseSet resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} phrase_set + * @returns {string} Resource name string. + */ + phraseSetPath(project: string, location: string, phraseSet: string) { + return this.pathTemplates.phraseSetPathTemplate.render({ + project: project, + location: location, + phrase_set: phraseSet, + }); + } + + /** + * Parse the project from PhraseSet resource. + * + * @param {string} phraseSetName + * A fully-qualified path representing PhraseSet resource. + * @returns {string} A string representing the project. + */ + matchProjectFromPhraseSetName(phraseSetName: string) { + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .project; + } + + /** + * Parse the location from PhraseSet resource. + * + * @param {string} phraseSetName + * A fully-qualified path representing PhraseSet resource. + * @returns {string} A string representing the location. + */ + matchLocationFromPhraseSetName(phraseSetName: string) { + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .location; + } + + /** + * Parse the phrase_set from PhraseSet resource. + * + * @param {string} phraseSetName + * A fully-qualified path representing PhraseSet resource. + * @returns {string} A string representing the phrase_set. + */ + matchPhraseSetFromPhraseSetName(phraseSetName: string) { + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .phrase_set; + } + + /** + * Return a fully-qualified project resource name string. + * + * @param {string} project + * @returns {string} Resource name string. + */ + projectPath(project: string) { + return this.pathTemplates.projectPathTemplate.render({ + project: project, + }); + } + + /** + * Parse the project from Project resource. + * + * @param {string} projectName + * A fully-qualified path representing Project resource. + * @returns {string} A string representing the project. + */ + matchProjectFromProjectName(projectName: string) { + return this.pathTemplates.projectPathTemplate.match(projectName).project; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + this.initialize(); + if (!this._terminated) { + return this.adaptationStub!.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/packages/google-cloud-node/src/v1p1beta1/adaptation_client_config.json b/packages/google-cloud-node/src/v1p1beta1/adaptation_client_config.json new file mode 100644 index 000000000000..9de684473a2a --- /dev/null +++ b/packages/google-cloud-node/src/v1p1beta1/adaptation_client_config.json @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.cloud.speech.v1p1beta1.Adaptation": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreatePhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetPhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListPhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdatePhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeletePhraseSet": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateCustomClass": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetCustomClass": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ListCustomClasses": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UpdateCustomClass": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteCustomClass": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/packages/google-cloud-node/src/v1p1beta1/adaptation_proto_list.json b/packages/google-cloud-node/src/v1p1beta1/adaptation_proto_list.json new file mode 100644 index 000000000000..d05ded22dc94 --- /dev/null +++ b/packages/google-cloud-node/src/v1p1beta1/adaptation_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/cloud/speech/v1p1beta1/cloud_speech.proto", + "../../protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto", + "../../protos/google/cloud/speech/v1p1beta1/resource.proto" +] diff --git a/packages/google-cloud-node/src/v1p1beta1/gapic_metadata.json b/packages/google-cloud-node/src/v1p1beta1/gapic_metadata.json index fbff0dd05e1f..deb25a92d688 100644 --- a/packages/google-cloud-node/src/v1p1beta1/gapic_metadata.json +++ b/packages/google-cloud-node/src/v1p1beta1/gapic_metadata.json @@ -5,6 +5,128 @@ "protoPackage": "google.cloud.speech.v1p1beta1", "libraryPackage": "@google-cloud/speech", "services": { + "Adaptation": { + "clients": { + "grpc": { + "libraryClient": "AdaptationClient", + "rpcs": { + "CreatePhraseSet": { + "methods": [ + "createPhraseSet" + ] + }, + "GetPhraseSet": { + "methods": [ + "getPhraseSet" + ] + }, + "UpdatePhraseSet": { + "methods": [ + "updatePhraseSet" + ] + }, + "DeletePhraseSet": { + "methods": [ + "deletePhraseSet" + ] + }, + "CreateCustomClass": { + "methods": [ + "createCustomClass" + ] + }, + "GetCustomClass": { + "methods": [ + "getCustomClass" + ] + }, + "UpdateCustomClass": { + "methods": [ + "updateCustomClass" + ] + }, + "DeleteCustomClass": { + "methods": [ + "deleteCustomClass" + ] + }, + "ListPhraseSet": { + "methods": [ + "listPhraseSet", + "listPhraseSetStream", + "listPhraseSetAsync" + ] + }, + "ListCustomClasses": { + "methods": [ + "listCustomClasses", + "listCustomClassesStream", + "listCustomClassesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "AdaptationClient", + "rpcs": { + "CreatePhraseSet": { + "methods": [ + "createPhraseSet" + ] + }, + "GetPhraseSet": { + "methods": [ + "getPhraseSet" + ] + }, + "UpdatePhraseSet": { + "methods": [ + "updatePhraseSet" + ] + }, + "DeletePhraseSet": { + "methods": [ + "deletePhraseSet" + ] + }, + "CreateCustomClass": { + "methods": [ + "createCustomClass" + ] + }, + "GetCustomClass": { + "methods": [ + "getCustomClass" + ] + }, + "UpdateCustomClass": { + "methods": [ + "updateCustomClass" + ] + }, + "DeleteCustomClass": { + "methods": [ + "deleteCustomClass" + ] + }, + "ListPhraseSet": { + "methods": [ + "listPhraseSet", + "listPhraseSetStream", + "listPhraseSetAsync" + ] + }, + "ListCustomClasses": { + "methods": [ + "listCustomClasses", + "listCustomClassesStream", + "listCustomClassesAsync" + ] + } + } + } + } + }, "Speech": { "clients": { "grpc": { diff --git a/packages/google-cloud-node/src/v1p1beta1/index.ts b/packages/google-cloud-node/src/v1p1beta1/index.ts index b96f5883a93a..ae3ec95d395c 100644 --- a/packages/google-cloud-node/src/v1p1beta1/index.ts +++ b/packages/google-cloud-node/src/v1p1beta1/index.ts @@ -16,4 +16,5 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** +export {AdaptationClient} from './adaptation_client'; export {SpeechClient} from './speech_client'; diff --git a/packages/google-cloud-node/src/v1p1beta1/speech_proto_list.json b/packages/google-cloud-node/src/v1p1beta1/speech_proto_list.json index 3b92ac9fac97..d05ded22dc94 100644 --- a/packages/google-cloud-node/src/v1p1beta1/speech_proto_list.json +++ b/packages/google-cloud-node/src/v1p1beta1/speech_proto_list.json @@ -1,4 +1,5 @@ [ "../../protos/google/cloud/speech/v1p1beta1/cloud_speech.proto", + "../../protos/google/cloud/speech/v1p1beta1/cloud_speech_adaptation.proto", "../../protos/google/cloud/speech/v1p1beta1/resource.proto" ] diff --git a/packages/google-cloud-node/synth.metadata b/packages/google-cloud-node/synth.metadata index c9951be35f09..bc692bfd226b 100644 --- a/packages/google-cloud-node/synth.metadata +++ b/packages/google-cloud-node/synth.metadata @@ -3,23 +3,16 @@ { "git": { "name": ".", - "remote": "https://github.com/googleapis/nodejs-speech.git", - "sha": "be7ecff19d02a62118ad62da19509cc3f75cae51" + "remote": "git@github.com:googleapis/nodejs-speech.git", + "sha": "ca2e233f8ea9b0b299e7eeb37e2ddd7f06c83f21" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "d189e871205fea665a9648f7c4676f027495ccaf", - "internalRef": "345596855" - } - }, - { - "git": { - "name": "synthtool", - "remote": "https://github.com/googleapis/synthtool.git", - "sha": "318e351e26ba65b2b3cfa3f61b3b64e3540c3525" + "sha": "4b16c60a8fffe213d3a5002f85696fef2b6a8172", + "internalRef": "362090097" } } ], @@ -28,7 +21,7 @@ "client": { "source": "googleapis", "apiName": "speech", - "apiVersion": "v1", + "apiVersion": "v1p1beta1", "language": "nodejs", "generator": "bazel" } @@ -37,7 +30,7 @@ "client": { "source": "googleapis", "apiName": "speech", - "apiVersion": "v1p1beta1", + "apiVersion": "v1", "language": "nodejs", "generator": "bazel" } diff --git a/packages/google-cloud-node/synth.py b/packages/google-cloud-node/synth.py index 5391cb698ea0..d2c07333a431 100644 --- a/packages/google-cloud-node/synth.py +++ b/packages/google-cloud-node/synth.py @@ -27,7 +27,7 @@ gapic = gcp.GAPICBazel() common_templates = gcp.CommonTemplates() -versions = ['v1', 'v1p1beta1'] +versions = ['v1p1beta1', 'v1'] name = 'speech' for version in versions: @@ -54,5 +54,4 @@ templates = common_templates.node_library(source_location='build/src') s.copy(templates) -# node.postprocess_gapic_library() diff --git a/packages/google-cloud-node/test/gapic_adaptation_v1p1beta1.ts b/packages/google-cloud-node/test/gapic_adaptation_v1p1beta1.ts new file mode 100644 index 000000000000..be19a43938bd --- /dev/null +++ b/packages/google-cloud-node/test/gapic_adaptation_v1p1beta1.ts @@ -0,0 +1,1943 @@ +// Copyright 2021 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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import {describe, it} from 'mocha'; +import * as adaptationModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message).toObject( + instance as protobuf.Message, + {defaults: true} + ); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); + } + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1p1beta1.AdaptationClient', () => { + it('has servicePath', () => { + const servicePath = adaptationModule.v1p1beta1.AdaptationClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = adaptationModule.v1p1beta1.AdaptationClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = adaptationModule.v1p1beta1.AdaptationClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.adaptationStub, undefined); + await client.initialize(); + assert(client.adaptationStub); + }); + + it('has close method', () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.close(); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createPhraseSet', () => { + it('invokes createPhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ); + client.innerApiCalls.createPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.createPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ); + client.innerApiCalls.createPhraseSet = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createPhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createPhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createPhraseSet = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createPhraseSet(request), expectedError); + assert( + (client.innerApiCalls.createPhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('getPhraseSet', () => { + it('invokes getPhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ); + client.innerApiCalls.getPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.getPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ); + client.innerApiCalls.getPhraseSet = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getPhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getPhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getPhraseSet = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getPhraseSet(request), expectedError); + assert( + (client.innerApiCalls.getPhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('updatePhraseSet', () => { + it('invokes updatePhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() + ); + request.phraseSet = {}; + request.phraseSet.name = ''; + const expectedHeaderRequestParams = 'phrase_set.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ); + client.innerApiCalls.updatePhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.updatePhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updatePhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() + ); + request.phraseSet = {}; + request.phraseSet.name = ''; + const expectedHeaderRequestParams = 'phrase_set.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ); + client.innerApiCalls.updatePhraseSet = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updatePhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes updatePhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() + ); + request.phraseSet = {}; + request.phraseSet.name = ''; + const expectedHeaderRequestParams = 'phrase_set.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePhraseSet = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updatePhraseSet(request), expectedError); + assert( + (client.innerApiCalls.updatePhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('deletePhraseSet', () => { + it('invokes deletePhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.deletePhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deletePhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deletePhraseSet = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deletePhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deletePhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePhraseSet = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deletePhraseSet(request), expectedError); + assert( + (client.innerApiCalls.deletePhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('createCustomClass', () => { + it('invokes createCustomClass without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ); + client.innerApiCalls.createCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.createCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createCustomClass without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ); + client.innerApiCalls.createCustomClass = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.createCustomClass( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.ICustomClass | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createCustomClass with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createCustomClass = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createCustomClass(request), expectedError); + assert( + (client.innerApiCalls.createCustomClass as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('getCustomClass', () => { + it('invokes getCustomClass without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ); + client.innerApiCalls.getCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.getCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getCustomClass without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ); + client.innerApiCalls.getCustomClass = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.getCustomClass( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.ICustomClass | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getCustomClass with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getCustomClass = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getCustomClass(request), expectedError); + assert( + (client.innerApiCalls.getCustomClass as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('updateCustomClass', () => { + it('invokes updateCustomClass without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() + ); + request.customClass = {}; + request.customClass.name = ''; + const expectedHeaderRequestParams = 'custom_class.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ); + client.innerApiCalls.updateCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.updateCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateCustomClass without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() + ); + request.customClass = {}; + request.customClass.name = ''; + const expectedHeaderRequestParams = 'custom_class.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ); + client.innerApiCalls.updateCustomClass = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.updateCustomClass( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.ICustomClass | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes updateCustomClass with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() + ); + request.customClass = {}; + request.customClass.name = ''; + const expectedHeaderRequestParams = 'custom_class.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCustomClass = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateCustomClass(request), expectedError); + assert( + (client.innerApiCalls.updateCustomClass as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('deleteCustomClass', () => { + it('invokes deleteCustomClass without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.deleteCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteCustomClass without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteCustomClass = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.deleteCustomClass( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteCustomClass with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCustomClass = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteCustomClass(request), expectedError); + assert( + (client.innerApiCalls.deleteCustomClass as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + + describe('listPhraseSet', () => { + it('invokes listPhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ), + ]; + client.innerApiCalls.listPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.listPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ), + ]; + client.innerApiCalls.listPhraseSet = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listPhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listPhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listPhraseSet = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listPhraseSet(request), expectedError); + assert( + (client.innerApiCalls.listPhraseSet as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listPhraseSetStream without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ), + ]; + client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listPhraseSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1p1beta1.PhraseSet[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v1p1beta1.PhraseSet) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listPhraseSet, request) + ); + assert.strictEqual( + (client.descriptors.page.listPhraseSet + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listPhraseSetStream with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listPhraseSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1p1beta1.PhraseSet[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v1p1beta1.PhraseSet) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listPhraseSet, request) + ); + assert.strictEqual( + (client.descriptors.page.listPhraseSet + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listPhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet() + ), + ]; + client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.cloud.speech.v1p1beta1.IPhraseSet[] = []; + const iterable = client.listPhraseSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listPhraseSet + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listPhraseSet + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listPhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listPhraseSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v1p1beta1.IPhraseSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listPhraseSet + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listPhraseSet + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('listCustomClasses', () => { + it('invokes listCustomClasses without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ), + ]; + client.innerApiCalls.listCustomClasses = stubSimpleCall(expectedResponse); + const [response] = await client.listCustomClasses(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listCustomClasses without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ), + ]; + client.innerApiCalls.listCustomClasses = stubSimpleCallWithCallback( + expectedResponse + ); + const promise = new Promise((resolve, reject) => { + client.listCustomClasses( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.ICustomClass[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listCustomClasses with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listCustomClasses = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listCustomClasses(request), expectedError); + assert( + (client.innerApiCalls.listCustomClasses as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listCustomClassesStream without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ), + ]; + client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall( + expectedResponse + ); + const stream = client.listCustomClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1p1beta1.CustomClass[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v1p1beta1.CustomClass) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCustomClasses, request) + ); + assert.strictEqual( + (client.descriptors.page.listCustomClasses + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('invokes listCustomClassesStream with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listCustomClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1p1beta1.CustomClass[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v1p1beta1.CustomClass) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCustomClasses, request) + ); + assert.strictEqual( + (client.descriptors.page.listCustomClasses + .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCustomClasses without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass() + ), + ]; + client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall( + expectedResponse + ); + const responses: protos.google.cloud.speech.v1p1beta1.ICustomClass[] = []; + const iterable = client.listCustomClassesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCustomClasses + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listCustomClasses + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCustomClasses with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listCustomClassesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v1p1beta1.ICustomClass[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCustomClasses + .asyncIterate as SinonStub).getCall(0).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listCustomClasses + .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ + 'x-goog-request-params' + ], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + describe('customClass', () => { + const fakePath = '/rendered/path/customClass'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + custom_class: 'customClassValue', + }; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.customClassPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.customClassPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('customClassPath', () => { + const result = client.customClassPath( + 'projectValue', + 'locationValue', + 'customClassValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.customClassPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromCustomClassName', () => { + const result = client.matchProjectFromCustomClassName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromCustomClassName', () => { + const result = client.matchLocationFromCustomClassName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchCustomClassFromCustomClassName', () => { + const result = client.matchCustomClassFromCustomClassName(fakePath); + assert.strictEqual(result, 'customClassValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('location', () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.locationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('phraseSet', () => { + const fakePath = '/rendered/path/phraseSet'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + phrase_set: 'phraseSetValue', + }; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.phraseSetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.phraseSetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('phraseSetPath', () => { + const result = client.phraseSetPath( + 'projectValue', + 'locationValue', + 'phraseSetValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.phraseSetPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromPhraseSetName', () => { + const result = client.matchProjectFromPhraseSetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromPhraseSetName', () => { + const result = client.matchLocationFromPhraseSetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchPhraseSetFromPhraseSetName', () => { + const result = client.matchPhraseSetFromPhraseSetName(fakePath); + assert.strictEqual(result, 'phraseSetValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + }); +}); diff --git a/packages/google-cloud-node/webpack.config.js b/packages/google-cloud-node/webpack.config.js index de0be12e3f49..96e74b2426fa 100644 --- a/packages/google-cloud-node/webpack.config.js +++ b/packages/google-cloud-node/webpack.config.js @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC +// Copyright 2021 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.