diff --git a/.jsdoc.js b/.jsdoc.js index d2a7104e..0ba9bd16 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ module.exports = { includePattern: '\\.js$' }, templates: { - copyright: 'Copyright 2022 Google LLC', + copyright: 'Copyright 2023 Google LLC', includeDate: false, sourceFiles: false, systemName: '@google-cloud/speech', diff --git a/protos/google/cloud/speech/v1/cloud_speech.proto b/protos/google/cloud/speech/v1/cloud_speech.proto index 65aed983..e8f19603 100644 --- a/protos/google/cloud/speech/v1/cloud_speech.proto +++ b/protos/google/cloud/speech/v1/cloud_speech.proto @@ -260,8 +260,7 @@ message RecognitionConfig { // The number of channels in the input audio data. // ONLY set this for MULTI-CHANNEL recognition. - // Valid values for LINEAR16 and FLAC are `1`-`8`. - // Valid values for OGG_OPUS are '1'-'254'. + // Valid values for LINEAR16, OGG_OPUS and FLAC are `1`-`8`. // Valid value for MULAW, AMR, AMR_WB and SPEEX_WITH_HEADER_BYTE is only `1`. // If `0` or omitted, defaults to one channel (mono). // Note: We only recognize the first channel by default. @@ -652,6 +651,13 @@ message RecognizeResponse { // When available, billed audio seconds for the corresponding request. google.protobuf.Duration total_billed_time = 3; + + // Provides information on adaptation behavior in response + SpeechAdaptationInfo speech_adaptation_info = 7; + + // The ID associated with the request. This is a unique ID specific only to + // the given request. + int64 request_id = 8; } // The only message returned to the client by the `LongRunningRecognize` method. @@ -672,6 +678,13 @@ message LongRunningRecognizeResponse { // If the transcript output fails this field contains the relevant error. google.rpc.Status output_error = 7; + + // Provides information on speech adaptation behavior in response + SpeechAdaptationInfo speech_adaptation_info = 8; + + // The ID associated with the request. This is a unique ID specific only to + // the given request. + int64 request_id = 9; } // Describes the progress of a long-running `LongRunningRecognize` call. It is @@ -774,6 +787,13 @@ message StreamingRecognizeResponse { // When available, billed audio seconds for the stream. // Set only if this is the last response in the stream. google.protobuf.Duration total_billed_time = 5; + + // Provides information on adaptation behavior in response + SpeechAdaptationInfo speech_adaptation_info = 9; + + // The ID associated with the request. This is a unique ID specific only to + // the given request. + int64 request_id = 10; } // A streaming speech recognition result corresponding to a portion of the audio @@ -897,3 +917,14 @@ message WordInfo { // top alternative. int32 speaker_tag = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; } + +// Information on speech adaptation use in results +message SpeechAdaptationInfo { + // Whether there was a timeout when applying speech adaptation. If true, + // adaptation had no effect in the response transcript. + bool adaptation_timeout = 1; + + // If set, returns a message specifying which part of the speech adaptation + // request timed out. + string timeout_message = 4; +} diff --git a/protos/google/cloud/speech/v1/resource.proto b/protos/google/cloud/speech/v1/resource.proto index 0ae5caa9..63b7ae44 100644 --- a/protos/google/cloud/speech/v1/resource.proto +++ b/protos/google/cloud/speech/v1/resource.proto @@ -120,6 +120,12 @@ message PhraseSet { // Speech adaptation configuration. message SpeechAdaptation { + message ABNFGrammar { + // All declarations and rules of an ABNF grammar broken up into multiple + // strings that will end up concatenated. + repeated string abnf_strings = 1; + } + // A collection of phrase sets. To specify the hints inline, leave the // phrase set's `name` blank and fill in the rest of its fields. Any // phrase set can use any custom class. @@ -127,12 +133,17 @@ message SpeechAdaptation { // A collection of phrase set resource names to use. repeated string phrase_set_references = 2 [(google.api.resource_reference) = { - type: "speech.googleapis.com/PhraseSet" - }]; + type: "speech.googleapis.com/PhraseSet" + }]; // 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 = 3; + + // Augmented Backus-Naur form (ABNF) is a standardized grammar notation + // comprised by a set of derivation rules. + // See specifications: https://www.w3.org/TR/speech-grammar + ABNFGrammar abnf_grammar = 4; } diff --git a/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto b/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto index 9bf36fcc..d1396692 100644 --- a/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto +++ b/protos/google/cloud/speech/v1p1beta1/cloud_speech.proto @@ -266,8 +266,7 @@ message RecognitionConfig { // The number of channels in the input audio data. // ONLY set this for MULTI-CHANNEL recognition. - // Valid values for LINEAR16 and FLAC are `1`-`8`. - // Valid values for OGG_OPUS are '1'-'254'. + // Valid values for LINEAR16, OGG_OPUS and FLAC are `1`-`8`. // Valid value for MULAW, AMR, AMR_WB and SPEEX_WITH_HEADER_BYTE is only `1`. // If `0` or omitted, defaults to one channel (mono). // Note: We only recognize the first channel by default. @@ -679,6 +678,13 @@ message RecognizeResponse { // When available, billed audio seconds for the corresponding request. google.protobuf.Duration total_billed_time = 3; + + // Provides information on adaptation behavior in response + SpeechAdaptationInfo speech_adaptation_info = 7; + + // The ID associated with the request. This is a unique ID specific only to + // the given request. + int64 request_id = 8; } // The only message returned to the client by the `LongRunningRecognize` method. @@ -699,6 +705,13 @@ message LongRunningRecognizeResponse { // If the transcript output fails this field contains the relevant error. google.rpc.Status output_error = 7; + + // Provides information on speech adaptation behavior in response + SpeechAdaptationInfo speech_adaptation_info = 8; + + // The ID associated with the request. This is a unique ID specific only to + // the given request. + int64 request_id = 9; } // Describes the progress of a long-running `LongRunningRecognize` call. It is @@ -804,6 +817,13 @@ message StreamingRecognizeResponse { // When available, billed audio seconds for the stream. // Set only if this is the last response in the stream. google.protobuf.Duration total_billed_time = 5; + + // Provides information on adaptation behavior in response + SpeechAdaptationInfo speech_adaptation_info = 9; + + // The ID associated with the request. This is a unique ID specific only to + // the given request. + int64 request_id = 10; } // A streaming speech recognition result corresponding to a portion of the audio @@ -927,3 +947,14 @@ message WordInfo { // top alternative. int32 speaker_tag = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; } + +// Information on speech adaptation use in results +message SpeechAdaptationInfo { + // Whether there was a timeout when applying speech adaptation. If true, + // adaptation had no effect in the response transcript. + bool adaptation_timeout = 1; + + // If set, returns a message specifying which part of the speech adaptation + // request timed out. + string timeout_message = 4; +} diff --git a/protos/google/cloud/speech/v1p1beta1/resource.proto b/protos/google/cloud/speech/v1p1beta1/resource.proto index 0323b19e..6a9bcaa9 100644 --- a/protos/google/cloud/speech/v1p1beta1/resource.proto +++ b/protos/google/cloud/speech/v1p1beta1/resource.proto @@ -120,6 +120,12 @@ message PhraseSet { // Speech adaptation configuration. message SpeechAdaptation { + message ABNFGrammar { + // All declarations and rules of an ABNF grammar broken up into multiple + // strings that will end up concatenated. + repeated string abnf_strings = 1; + } + // A collection of phrase sets. To specify the hints inline, leave the // phrase set's `name` blank and fill in the rest of its fields. Any // phrase set can use any custom class. @@ -127,14 +133,19 @@ message SpeechAdaptation { // A collection of phrase set resource names to use. repeated string phrase_set_references = 2 [(google.api.resource_reference) = { - type: "speech.googleapis.com/PhraseSet" - }]; + type: "speech.googleapis.com/PhraseSet" + }]; // 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 = 3; + + // Augmented Backus-Naur form (ABNF) is a standardized grammar notation + // comprised by a set of derivation rules. + // See specifications: https://www.w3.org/TR/speech-grammar + ABNFGrammar abnf_grammar = 4; } // Transcription normalization configuration. Use transcription normalization diff --git a/protos/protos.d.ts b/protos/protos.d.ts index effc74ac..a5f91750 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -1374,6 +1374,12 @@ export namespace google { /** RecognizeResponse totalBilledTime */ totalBilledTime?: (google.protobuf.IDuration|null); + + /** RecognizeResponse speechAdaptationInfo */ + speechAdaptationInfo?: (google.cloud.speech.v1.ISpeechAdaptationInfo|null); + + /** RecognizeResponse requestId */ + requestId?: (number|Long|string|null); } /** Represents a RecognizeResponse. */ @@ -1391,6 +1397,12 @@ export namespace google { /** RecognizeResponse totalBilledTime. */ public totalBilledTime?: (google.protobuf.IDuration|null); + /** RecognizeResponse speechAdaptationInfo. */ + public speechAdaptationInfo?: (google.cloud.speech.v1.ISpeechAdaptationInfo|null); + + /** RecognizeResponse requestId. */ + public requestId: (number|Long|string); + /** * Creates a new RecognizeResponse instance using the specified properties. * @param [properties] Properties to set @@ -1483,6 +1495,12 @@ export namespace google { /** LongRunningRecognizeResponse outputError */ outputError?: (google.rpc.IStatus|null); + + /** LongRunningRecognizeResponse speechAdaptationInfo */ + speechAdaptationInfo?: (google.cloud.speech.v1.ISpeechAdaptationInfo|null); + + /** LongRunningRecognizeResponse requestId */ + requestId?: (number|Long|string|null); } /** Represents a LongRunningRecognizeResponse. */ @@ -1506,6 +1524,12 @@ export namespace google { /** LongRunningRecognizeResponse outputError. */ public outputError?: (google.rpc.IStatus|null); + /** LongRunningRecognizeResponse speechAdaptationInfo. */ + public speechAdaptationInfo?: (google.cloud.speech.v1.ISpeechAdaptationInfo|null); + + /** LongRunningRecognizeResponse requestId. */ + public requestId: (number|Long|string); + /** * Creates a new LongRunningRecognizeResponse instance using the specified properties. * @param [properties] Properties to set @@ -1713,6 +1737,12 @@ export namespace google { /** StreamingRecognizeResponse totalBilledTime */ totalBilledTime?: (google.protobuf.IDuration|null); + + /** StreamingRecognizeResponse speechAdaptationInfo */ + speechAdaptationInfo?: (google.cloud.speech.v1.ISpeechAdaptationInfo|null); + + /** StreamingRecognizeResponse requestId */ + requestId?: (number|Long|string|null); } /** Represents a StreamingRecognizeResponse. */ @@ -1736,6 +1766,12 @@ export namespace google { /** StreamingRecognizeResponse totalBilledTime. */ public totalBilledTime?: (google.protobuf.IDuration|null); + /** StreamingRecognizeResponse speechAdaptationInfo. */ + public speechAdaptationInfo?: (google.cloud.speech.v1.ISpeechAdaptationInfo|null); + + /** StreamingRecognizeResponse requestId. */ + public requestId: (number|Long|string); + /** * Creates a new StreamingRecognizeResponse instance using the specified properties. * @param [properties] Properties to set @@ -2295,6 +2331,109 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a SpeechAdaptationInfo. */ + interface ISpeechAdaptationInfo { + + /** SpeechAdaptationInfo adaptationTimeout */ + adaptationTimeout?: (boolean|null); + + /** SpeechAdaptationInfo timeoutMessage */ + timeoutMessage?: (string|null); + } + + /** Represents a SpeechAdaptationInfo. */ + class SpeechAdaptationInfo implements ISpeechAdaptationInfo { + + /** + * Constructs a new SpeechAdaptationInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1.ISpeechAdaptationInfo); + + /** SpeechAdaptationInfo adaptationTimeout. */ + public adaptationTimeout: boolean; + + /** SpeechAdaptationInfo timeoutMessage. */ + public timeoutMessage: string; + + /** + * Creates a new SpeechAdaptationInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns SpeechAdaptationInfo instance + */ + public static create(properties?: google.cloud.speech.v1.ISpeechAdaptationInfo): google.cloud.speech.v1.SpeechAdaptationInfo; + + /** + * Encodes the specified SpeechAdaptationInfo message. Does not implicitly {@link google.cloud.speech.v1.SpeechAdaptationInfo.verify|verify} messages. + * @param message SpeechAdaptationInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1.ISpeechAdaptationInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SpeechAdaptationInfo message, length delimited. Does not implicitly {@link google.cloud.speech.v1.SpeechAdaptationInfo.verify|verify} messages. + * @param message SpeechAdaptationInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1.ISpeechAdaptationInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SpeechAdaptationInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SpeechAdaptationInfo + * @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.v1.SpeechAdaptationInfo; + + /** + * Decodes a SpeechAdaptationInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SpeechAdaptationInfo + * @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.v1.SpeechAdaptationInfo; + + /** + * Verifies a SpeechAdaptationInfo 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 SpeechAdaptationInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SpeechAdaptationInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1.SpeechAdaptationInfo; + + /** + * Creates a plain object from a SpeechAdaptationInfo message. Also converts values to other types if specified. + * @param message SpeechAdaptationInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1.SpeechAdaptationInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SpeechAdaptationInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SpeechAdaptationInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a CustomClass. */ interface ICustomClass { @@ -2730,6 +2869,9 @@ export namespace google { /** SpeechAdaptation customClasses */ customClasses?: (google.cloud.speech.v1.ICustomClass[]|null); + + /** SpeechAdaptation abnfGrammar */ + abnfGrammar?: (google.cloud.speech.v1.SpeechAdaptation.IABNFGrammar|null); } /** Represents a SpeechAdaptation. */ @@ -2750,6 +2892,9 @@ export namespace google { /** SpeechAdaptation customClasses. */ public customClasses: google.cloud.speech.v1.ICustomClass[]; + /** SpeechAdaptation abnfGrammar. */ + public abnfGrammar?: (google.cloud.speech.v1.SpeechAdaptation.IABNFGrammar|null); + /** * Creates a new SpeechAdaptation instance using the specified properties. * @param [properties] Properties to set @@ -2828,6 +2973,106 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace SpeechAdaptation { + + /** Properties of a ABNFGrammar. */ + interface IABNFGrammar { + + /** ABNFGrammar abnfStrings */ + abnfStrings?: (string[]|null); + } + + /** Represents a ABNFGrammar. */ + class ABNFGrammar implements IABNFGrammar { + + /** + * Constructs a new ABNFGrammar. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1.SpeechAdaptation.IABNFGrammar); + + /** ABNFGrammar abnfStrings. */ + public abnfStrings: string[]; + + /** + * Creates a new ABNFGrammar instance using the specified properties. + * @param [properties] Properties to set + * @returns ABNFGrammar instance + */ + public static create(properties?: google.cloud.speech.v1.SpeechAdaptation.IABNFGrammar): google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar; + + /** + * Encodes the specified ABNFGrammar message. Does not implicitly {@link google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar.verify|verify} messages. + * @param message ABNFGrammar message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1.SpeechAdaptation.IABNFGrammar, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ABNFGrammar message, length delimited. Does not implicitly {@link google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar.verify|verify} messages. + * @param message ABNFGrammar message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1.SpeechAdaptation.IABNFGrammar, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ABNFGrammar message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ABNFGrammar + * @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.v1.SpeechAdaptation.ABNFGrammar; + + /** + * Decodes a ABNFGrammar message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ABNFGrammar + * @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.v1.SpeechAdaptation.ABNFGrammar; + + /** + * Verifies a ABNFGrammar 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 ABNFGrammar message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ABNFGrammar + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar; + + /** + * Creates a plain object from a ABNFGrammar message. Also converts values to other types if specified. + * @param message ABNFGrammar + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ABNFGrammar to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ABNFGrammar + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Represents an Adaptation */ class Adaptation extends $protobuf.rpc.Service { @@ -5675,6 +5920,12 @@ export namespace google { /** RecognizeResponse totalBilledTime */ totalBilledTime?: (google.protobuf.IDuration|null); + + /** RecognizeResponse speechAdaptationInfo */ + speechAdaptationInfo?: (google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo|null); + + /** RecognizeResponse requestId */ + requestId?: (number|Long|string|null); } /** Represents a RecognizeResponse. */ @@ -5692,6 +5943,12 @@ export namespace google { /** RecognizeResponse totalBilledTime. */ public totalBilledTime?: (google.protobuf.IDuration|null); + /** RecognizeResponse speechAdaptationInfo. */ + public speechAdaptationInfo?: (google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo|null); + + /** RecognizeResponse requestId. */ + public requestId: (number|Long|string); + /** * Creates a new RecognizeResponse instance using the specified properties. * @param [properties] Properties to set @@ -5784,6 +6041,12 @@ export namespace google { /** LongRunningRecognizeResponse outputError */ outputError?: (google.rpc.IStatus|null); + + /** LongRunningRecognizeResponse speechAdaptationInfo */ + speechAdaptationInfo?: (google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo|null); + + /** LongRunningRecognizeResponse requestId */ + requestId?: (number|Long|string|null); } /** Represents a LongRunningRecognizeResponse. */ @@ -5807,6 +6070,12 @@ export namespace google { /** LongRunningRecognizeResponse outputError. */ public outputError?: (google.rpc.IStatus|null); + /** LongRunningRecognizeResponse speechAdaptationInfo. */ + public speechAdaptationInfo?: (google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo|null); + + /** LongRunningRecognizeResponse requestId. */ + public requestId: (number|Long|string); + /** * Creates a new LongRunningRecognizeResponse instance using the specified properties. * @param [properties] Properties to set @@ -6020,6 +6289,12 @@ export namespace google { /** StreamingRecognizeResponse totalBilledTime */ totalBilledTime?: (google.protobuf.IDuration|null); + + /** StreamingRecognizeResponse speechAdaptationInfo */ + speechAdaptationInfo?: (google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo|null); + + /** StreamingRecognizeResponse requestId */ + requestId?: (number|Long|string|null); } /** Represents a StreamingRecognizeResponse. */ @@ -6043,6 +6318,12 @@ export namespace google { /** StreamingRecognizeResponse totalBilledTime. */ public totalBilledTime?: (google.protobuf.IDuration|null); + /** StreamingRecognizeResponse speechAdaptationInfo. */ + public speechAdaptationInfo?: (google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo|null); + + /** StreamingRecognizeResponse requestId. */ + public requestId: (number|Long|string); + /** * Creates a new StreamingRecognizeResponse instance using the specified properties. * @param [properties] Properties to set @@ -6602,6 +6883,109 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a SpeechAdaptationInfo. */ + interface ISpeechAdaptationInfo { + + /** SpeechAdaptationInfo adaptationTimeout */ + adaptationTimeout?: (boolean|null); + + /** SpeechAdaptationInfo timeoutMessage */ + timeoutMessage?: (string|null); + } + + /** Represents a SpeechAdaptationInfo. */ + class SpeechAdaptationInfo implements ISpeechAdaptationInfo { + + /** + * Constructs a new SpeechAdaptationInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo); + + /** SpeechAdaptationInfo adaptationTimeout. */ + public adaptationTimeout: boolean; + + /** SpeechAdaptationInfo timeoutMessage. */ + public timeoutMessage: string; + + /** + * Creates a new SpeechAdaptationInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns SpeechAdaptationInfo instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo): google.cloud.speech.v1p1beta1.SpeechAdaptationInfo; + + /** + * Encodes the specified SpeechAdaptationInfo message. Does not implicitly {@link google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.verify|verify} messages. + * @param message SpeechAdaptationInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SpeechAdaptationInfo message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.verify|verify} messages. + * @param message SpeechAdaptationInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SpeechAdaptationInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SpeechAdaptationInfo + * @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.SpeechAdaptationInfo; + + /** + * Decodes a SpeechAdaptationInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SpeechAdaptationInfo + * @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.SpeechAdaptationInfo; + + /** + * Verifies a SpeechAdaptationInfo 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 SpeechAdaptationInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SpeechAdaptationInfo + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.SpeechAdaptationInfo; + + /** + * Creates a plain object from a SpeechAdaptationInfo message. Also converts values to other types if specified. + * @param message SpeechAdaptationInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.SpeechAdaptationInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SpeechAdaptationInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SpeechAdaptationInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a CustomClass. */ interface ICustomClass { @@ -7037,6 +7421,9 @@ export namespace google { /** SpeechAdaptation customClasses */ customClasses?: (google.cloud.speech.v1p1beta1.ICustomClass[]|null); + + /** SpeechAdaptation abnfGrammar */ + abnfGrammar?: (google.cloud.speech.v1p1beta1.SpeechAdaptation.IABNFGrammar|null); } /** Represents a SpeechAdaptation. */ @@ -7057,6 +7444,9 @@ export namespace google { /** SpeechAdaptation customClasses. */ public customClasses: google.cloud.speech.v1p1beta1.ICustomClass[]; + /** SpeechAdaptation abnfGrammar. */ + public abnfGrammar?: (google.cloud.speech.v1p1beta1.SpeechAdaptation.IABNFGrammar|null); + /** * Creates a new SpeechAdaptation instance using the specified properties. * @param [properties] Properties to set @@ -7135,6 +7525,106 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace SpeechAdaptation { + + /** Properties of a ABNFGrammar. */ + interface IABNFGrammar { + + /** ABNFGrammar abnfStrings */ + abnfStrings?: (string[]|null); + } + + /** Represents a ABNFGrammar. */ + class ABNFGrammar implements IABNFGrammar { + + /** + * Constructs a new ABNFGrammar. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.speech.v1p1beta1.SpeechAdaptation.IABNFGrammar); + + /** ABNFGrammar abnfStrings. */ + public abnfStrings: string[]; + + /** + * Creates a new ABNFGrammar instance using the specified properties. + * @param [properties] Properties to set + * @returns ABNFGrammar instance + */ + public static create(properties?: google.cloud.speech.v1p1beta1.SpeechAdaptation.IABNFGrammar): google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar; + + /** + * Encodes the specified ABNFGrammar message. Does not implicitly {@link google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar.verify|verify} messages. + * @param message ABNFGrammar message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.speech.v1p1beta1.SpeechAdaptation.IABNFGrammar, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ABNFGrammar message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar.verify|verify} messages. + * @param message ABNFGrammar message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.speech.v1p1beta1.SpeechAdaptation.IABNFGrammar, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ABNFGrammar message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ABNFGrammar + * @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.ABNFGrammar; + + /** + * Decodes a ABNFGrammar message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ABNFGrammar + * @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.ABNFGrammar; + + /** + * Verifies a ABNFGrammar 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 ABNFGrammar message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ABNFGrammar + */ + public static fromObject(object: { [k: string]: any }): google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar; + + /** + * Creates a plain object from a ABNFGrammar message. Also converts values to other types if specified. + * @param message ABNFGrammar + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ABNFGrammar to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ABNFGrammar + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + /** Properties of a TranscriptNormalization. */ interface ITranscriptNormalization { diff --git a/protos/protos.js b/protos/protos.js index 0c56214d..db82a8b6 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -3580,6 +3580,8 @@ * @interface IRecognizeResponse * @property {Array.|null} [results] RecognizeResponse results * @property {google.protobuf.IDuration|null} [totalBilledTime] RecognizeResponse totalBilledTime + * @property {google.cloud.speech.v1.ISpeechAdaptationInfo|null} [speechAdaptationInfo] RecognizeResponse speechAdaptationInfo + * @property {number|Long|null} [requestId] RecognizeResponse requestId */ /** @@ -3614,6 +3616,22 @@ */ RecognizeResponse.prototype.totalBilledTime = null; + /** + * RecognizeResponse speechAdaptationInfo. + * @member {google.cloud.speech.v1.ISpeechAdaptationInfo|null|undefined} speechAdaptationInfo + * @memberof google.cloud.speech.v1.RecognizeResponse + * @instance + */ + RecognizeResponse.prototype.speechAdaptationInfo = null; + + /** + * RecognizeResponse requestId. + * @member {number|Long} requestId + * @memberof google.cloud.speech.v1.RecognizeResponse + * @instance + */ + RecognizeResponse.prototype.requestId = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + /** * Creates a new RecognizeResponse instance using the specified properties. * @function create @@ -3643,6 +3661,10 @@ $root.google.cloud.speech.v1.SpeechRecognitionResult.encode(message.results[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.totalBilledTime != null && Object.hasOwnProperty.call(message, "totalBilledTime")) $root.google.protobuf.Duration.encode(message.totalBilledTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.speechAdaptationInfo != null && Object.hasOwnProperty.call(message, "speechAdaptationInfo")) + $root.google.cloud.speech.v1.SpeechAdaptationInfo.encode(message.speechAdaptationInfo, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 8, wireType 0 =*/64).int64(message.requestId); return writer; }; @@ -3687,6 +3709,14 @@ message.totalBilledTime = $root.google.protobuf.Duration.decode(reader, reader.uint32()); break; } + case 7: { + message.speechAdaptationInfo = $root.google.cloud.speech.v1.SpeechAdaptationInfo.decode(reader, reader.uint32()); + break; + } + case 8: { + message.requestId = reader.int64(); + break; + } default: reader.skipType(tag & 7); break; @@ -3736,6 +3766,14 @@ if (error) return "totalBilledTime." + error; } + if (message.speechAdaptationInfo != null && message.hasOwnProperty("speechAdaptationInfo")) { + var error = $root.google.cloud.speech.v1.SpeechAdaptationInfo.verify(message.speechAdaptationInfo); + if (error) + return "speechAdaptationInfo." + error; + } + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!$util.isInteger(message.requestId) && !(message.requestId && $util.isInteger(message.requestId.low) && $util.isInteger(message.requestId.high))) + return "requestId: integer|Long expected"; return null; }; @@ -3766,6 +3804,20 @@ throw TypeError(".google.cloud.speech.v1.RecognizeResponse.totalBilledTime: object expected"); message.totalBilledTime = $root.google.protobuf.Duration.fromObject(object.totalBilledTime); } + if (object.speechAdaptationInfo != null) { + if (typeof object.speechAdaptationInfo !== "object") + throw TypeError(".google.cloud.speech.v1.RecognizeResponse.speechAdaptationInfo: object expected"); + message.speechAdaptationInfo = $root.google.cloud.speech.v1.SpeechAdaptationInfo.fromObject(object.speechAdaptationInfo); + } + if (object.requestId != null) + if ($util.Long) + (message.requestId = $util.Long.fromValue(object.requestId)).unsigned = false; + else if (typeof object.requestId === "string") + message.requestId = parseInt(object.requestId, 10); + else if (typeof object.requestId === "number") + message.requestId = object.requestId; + else if (typeof object.requestId === "object") + message.requestId = new $util.LongBits(object.requestId.low >>> 0, object.requestId.high >>> 0).toNumber(); return message; }; @@ -3784,8 +3836,15 @@ var object = {}; if (options.arrays || options.defaults) object.results = []; - if (options.defaults) + if (options.defaults) { object.totalBilledTime = null; + object.speechAdaptationInfo = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.requestId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.requestId = options.longs === String ? "0" : 0; + } if (message.results && message.results.length) { object.results = []; for (var j = 0; j < message.results.length; ++j) @@ -3793,6 +3852,13 @@ } if (message.totalBilledTime != null && message.hasOwnProperty("totalBilledTime")) object.totalBilledTime = $root.google.protobuf.Duration.toObject(message.totalBilledTime, options); + if (message.speechAdaptationInfo != null && message.hasOwnProperty("speechAdaptationInfo")) + object.speechAdaptationInfo = $root.google.cloud.speech.v1.SpeechAdaptationInfo.toObject(message.speechAdaptationInfo, options); + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (typeof message.requestId === "number") + object.requestId = options.longs === String ? String(message.requestId) : message.requestId; + else + object.requestId = options.longs === String ? $util.Long.prototype.toString.call(message.requestId) : options.longs === Number ? new $util.LongBits(message.requestId.low >>> 0, message.requestId.high >>> 0).toNumber() : message.requestId; return object; }; @@ -3835,6 +3901,8 @@ * @property {google.protobuf.IDuration|null} [totalBilledTime] LongRunningRecognizeResponse totalBilledTime * @property {google.cloud.speech.v1.ITranscriptOutputConfig|null} [outputConfig] LongRunningRecognizeResponse outputConfig * @property {google.rpc.IStatus|null} [outputError] LongRunningRecognizeResponse outputError + * @property {google.cloud.speech.v1.ISpeechAdaptationInfo|null} [speechAdaptationInfo] LongRunningRecognizeResponse speechAdaptationInfo + * @property {number|Long|null} [requestId] LongRunningRecognizeResponse requestId */ /** @@ -3885,6 +3953,22 @@ */ LongRunningRecognizeResponse.prototype.outputError = null; + /** + * LongRunningRecognizeResponse speechAdaptationInfo. + * @member {google.cloud.speech.v1.ISpeechAdaptationInfo|null|undefined} speechAdaptationInfo + * @memberof google.cloud.speech.v1.LongRunningRecognizeResponse + * @instance + */ + LongRunningRecognizeResponse.prototype.speechAdaptationInfo = null; + + /** + * LongRunningRecognizeResponse requestId. + * @member {number|Long} requestId + * @memberof google.cloud.speech.v1.LongRunningRecognizeResponse + * @instance + */ + LongRunningRecognizeResponse.prototype.requestId = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + /** * Creates a new LongRunningRecognizeResponse instance using the specified properties. * @function create @@ -3918,6 +4002,10 @@ $root.google.cloud.speech.v1.TranscriptOutputConfig.encode(message.outputConfig, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); if (message.outputError != null && Object.hasOwnProperty.call(message, "outputError")) $root.google.rpc.Status.encode(message.outputError, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.speechAdaptationInfo != null && Object.hasOwnProperty.call(message, "speechAdaptationInfo")) + $root.google.cloud.speech.v1.SpeechAdaptationInfo.encode(message.speechAdaptationInfo, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 9, wireType 0 =*/72).int64(message.requestId); return writer; }; @@ -3970,6 +4058,14 @@ message.outputError = $root.google.rpc.Status.decode(reader, reader.uint32()); break; } + case 8: { + message.speechAdaptationInfo = $root.google.cloud.speech.v1.SpeechAdaptationInfo.decode(reader, reader.uint32()); + break; + } + case 9: { + message.requestId = reader.int64(); + break; + } default: reader.skipType(tag & 7); break; @@ -4029,6 +4125,14 @@ if (error) return "outputError." + error; } + if (message.speechAdaptationInfo != null && message.hasOwnProperty("speechAdaptationInfo")) { + var error = $root.google.cloud.speech.v1.SpeechAdaptationInfo.verify(message.speechAdaptationInfo); + if (error) + return "speechAdaptationInfo." + error; + } + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!$util.isInteger(message.requestId) && !(message.requestId && $util.isInteger(message.requestId.low) && $util.isInteger(message.requestId.high))) + return "requestId: integer|Long expected"; return null; }; @@ -4069,6 +4173,20 @@ throw TypeError(".google.cloud.speech.v1.LongRunningRecognizeResponse.outputError: object expected"); message.outputError = $root.google.rpc.Status.fromObject(object.outputError); } + if (object.speechAdaptationInfo != null) { + if (typeof object.speechAdaptationInfo !== "object") + throw TypeError(".google.cloud.speech.v1.LongRunningRecognizeResponse.speechAdaptationInfo: object expected"); + message.speechAdaptationInfo = $root.google.cloud.speech.v1.SpeechAdaptationInfo.fromObject(object.speechAdaptationInfo); + } + if (object.requestId != null) + if ($util.Long) + (message.requestId = $util.Long.fromValue(object.requestId)).unsigned = false; + else if (typeof object.requestId === "string") + message.requestId = parseInt(object.requestId, 10); + else if (typeof object.requestId === "number") + message.requestId = object.requestId; + else if (typeof object.requestId === "object") + message.requestId = new $util.LongBits(object.requestId.low >>> 0, object.requestId.high >>> 0).toNumber(); return message; }; @@ -4091,6 +4209,12 @@ object.totalBilledTime = null; object.outputConfig = null; object.outputError = null; + object.speechAdaptationInfo = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.requestId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.requestId = options.longs === String ? "0" : 0; } if (message.results && message.results.length) { object.results = []; @@ -4103,6 +4227,13 @@ object.outputConfig = $root.google.cloud.speech.v1.TranscriptOutputConfig.toObject(message.outputConfig, options); if (message.outputError != null && message.hasOwnProperty("outputError")) object.outputError = $root.google.rpc.Status.toObject(message.outputError, options); + if (message.speechAdaptationInfo != null && message.hasOwnProperty("speechAdaptationInfo")) + object.speechAdaptationInfo = $root.google.cloud.speech.v1.SpeechAdaptationInfo.toObject(message.speechAdaptationInfo, options); + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (typeof message.requestId === "number") + object.requestId = options.longs === String ? String(message.requestId) : message.requestId; + else + object.requestId = options.longs === String ? $util.Long.prototype.toString.call(message.requestId) : options.longs === Number ? new $util.LongBits(message.requestId.low >>> 0, message.requestId.high >>> 0).toNumber() : message.requestId; return object; }; @@ -4428,6 +4559,8 @@ * @property {Array.|null} [results] StreamingRecognizeResponse results * @property {google.cloud.speech.v1.StreamingRecognizeResponse.SpeechEventType|null} [speechEventType] StreamingRecognizeResponse speechEventType * @property {google.protobuf.IDuration|null} [totalBilledTime] StreamingRecognizeResponse totalBilledTime + * @property {google.cloud.speech.v1.ISpeechAdaptationInfo|null} [speechAdaptationInfo] StreamingRecognizeResponse speechAdaptationInfo + * @property {number|Long|null} [requestId] StreamingRecognizeResponse requestId */ /** @@ -4478,6 +4611,22 @@ */ StreamingRecognizeResponse.prototype.totalBilledTime = null; + /** + * StreamingRecognizeResponse speechAdaptationInfo. + * @member {google.cloud.speech.v1.ISpeechAdaptationInfo|null|undefined} speechAdaptationInfo + * @memberof google.cloud.speech.v1.StreamingRecognizeResponse + * @instance + */ + StreamingRecognizeResponse.prototype.speechAdaptationInfo = null; + + /** + * StreamingRecognizeResponse requestId. + * @member {number|Long} requestId + * @memberof google.cloud.speech.v1.StreamingRecognizeResponse + * @instance + */ + StreamingRecognizeResponse.prototype.requestId = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + /** * Creates a new StreamingRecognizeResponse instance using the specified properties. * @function create @@ -4511,6 +4660,10 @@ writer.uint32(/* id 4, wireType 0 =*/32).int32(message.speechEventType); if (message.totalBilledTime != null && Object.hasOwnProperty.call(message, "totalBilledTime")) $root.google.protobuf.Duration.encode(message.totalBilledTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.speechAdaptationInfo != null && Object.hasOwnProperty.call(message, "speechAdaptationInfo")) + $root.google.cloud.speech.v1.SpeechAdaptationInfo.encode(message.speechAdaptationInfo, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 10, wireType 0 =*/80).int64(message.requestId); return writer; }; @@ -4563,6 +4716,14 @@ message.totalBilledTime = $root.google.protobuf.Duration.decode(reader, reader.uint32()); break; } + case 9: { + message.speechAdaptationInfo = $root.google.cloud.speech.v1.SpeechAdaptationInfo.decode(reader, reader.uint32()); + break; + } + case 10: { + message.requestId = reader.int64(); + break; + } default: reader.skipType(tag & 7); break; @@ -4625,6 +4786,14 @@ if (error) return "totalBilledTime." + error; } + if (message.speechAdaptationInfo != null && message.hasOwnProperty("speechAdaptationInfo")) { + var error = $root.google.cloud.speech.v1.SpeechAdaptationInfo.verify(message.speechAdaptationInfo); + if (error) + return "speechAdaptationInfo." + error; + } + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!$util.isInteger(message.requestId) && !(message.requestId && $util.isInteger(message.requestId.low) && $util.isInteger(message.requestId.high))) + return "requestId: integer|Long expected"; return null; }; @@ -4676,6 +4845,20 @@ throw TypeError(".google.cloud.speech.v1.StreamingRecognizeResponse.totalBilledTime: object expected"); message.totalBilledTime = $root.google.protobuf.Duration.fromObject(object.totalBilledTime); } + if (object.speechAdaptationInfo != null) { + if (typeof object.speechAdaptationInfo !== "object") + throw TypeError(".google.cloud.speech.v1.StreamingRecognizeResponse.speechAdaptationInfo: object expected"); + message.speechAdaptationInfo = $root.google.cloud.speech.v1.SpeechAdaptationInfo.fromObject(object.speechAdaptationInfo); + } + if (object.requestId != null) + if ($util.Long) + (message.requestId = $util.Long.fromValue(object.requestId)).unsigned = false; + else if (typeof object.requestId === "string") + message.requestId = parseInt(object.requestId, 10); + else if (typeof object.requestId === "number") + message.requestId = object.requestId; + else if (typeof object.requestId === "object") + message.requestId = new $util.LongBits(object.requestId.low >>> 0, object.requestId.high >>> 0).toNumber(); return message; }; @@ -4698,6 +4881,12 @@ object.error = null; object.speechEventType = options.enums === String ? "SPEECH_EVENT_UNSPECIFIED" : 0; object.totalBilledTime = null; + object.speechAdaptationInfo = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.requestId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.requestId = options.longs === String ? "0" : 0; } if (message.error != null && message.hasOwnProperty("error")) object.error = $root.google.rpc.Status.toObject(message.error, options); @@ -4710,6 +4899,13 @@ object.speechEventType = options.enums === String ? $root.google.cloud.speech.v1.StreamingRecognizeResponse.SpeechEventType[message.speechEventType] === undefined ? message.speechEventType : $root.google.cloud.speech.v1.StreamingRecognizeResponse.SpeechEventType[message.speechEventType] : message.speechEventType; if (message.totalBilledTime != null && message.hasOwnProperty("totalBilledTime")) object.totalBilledTime = $root.google.protobuf.Duration.toObject(message.totalBilledTime, options); + if (message.speechAdaptationInfo != null && message.hasOwnProperty("speechAdaptationInfo")) + object.speechAdaptationInfo = $root.google.cloud.speech.v1.SpeechAdaptationInfo.toObject(message.speechAdaptationInfo, options); + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (typeof message.requestId === "number") + object.requestId = options.longs === String ? String(message.requestId) : message.requestId; + else + object.requestId = options.longs === String ? $util.Long.prototype.toString.call(message.requestId) : options.longs === Number ? new $util.LongBits(message.requestId.low >>> 0, message.requestId.high >>> 0).toNumber() : message.requestId; return object; }; @@ -5980,6 +6176,233 @@ return WordInfo; })(); + v1.SpeechAdaptationInfo = (function() { + + /** + * Properties of a SpeechAdaptationInfo. + * @memberof google.cloud.speech.v1 + * @interface ISpeechAdaptationInfo + * @property {boolean|null} [adaptationTimeout] SpeechAdaptationInfo adaptationTimeout + * @property {string|null} [timeoutMessage] SpeechAdaptationInfo timeoutMessage + */ + + /** + * Constructs a new SpeechAdaptationInfo. + * @memberof google.cloud.speech.v1 + * @classdesc Represents a SpeechAdaptationInfo. + * @implements ISpeechAdaptationInfo + * @constructor + * @param {google.cloud.speech.v1.ISpeechAdaptationInfo=} [properties] Properties to set + */ + function SpeechAdaptationInfo(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]]; + } + + /** + * SpeechAdaptationInfo adaptationTimeout. + * @member {boolean} adaptationTimeout + * @memberof google.cloud.speech.v1.SpeechAdaptationInfo + * @instance + */ + SpeechAdaptationInfo.prototype.adaptationTimeout = false; + + /** + * SpeechAdaptationInfo timeoutMessage. + * @member {string} timeoutMessage + * @memberof google.cloud.speech.v1.SpeechAdaptationInfo + * @instance + */ + SpeechAdaptationInfo.prototype.timeoutMessage = ""; + + /** + * Creates a new SpeechAdaptationInfo instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1.SpeechAdaptationInfo + * @static + * @param {google.cloud.speech.v1.ISpeechAdaptationInfo=} [properties] Properties to set + * @returns {google.cloud.speech.v1.SpeechAdaptationInfo} SpeechAdaptationInfo instance + */ + SpeechAdaptationInfo.create = function create(properties) { + return new SpeechAdaptationInfo(properties); + }; + + /** + * Encodes the specified SpeechAdaptationInfo message. Does not implicitly {@link google.cloud.speech.v1.SpeechAdaptationInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1.SpeechAdaptationInfo + * @static + * @param {google.cloud.speech.v1.ISpeechAdaptationInfo} message SpeechAdaptationInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpeechAdaptationInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.adaptationTimeout != null && Object.hasOwnProperty.call(message, "adaptationTimeout")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.adaptationTimeout); + if (message.timeoutMessage != null && Object.hasOwnProperty.call(message, "timeoutMessage")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.timeoutMessage); + return writer; + }; + + /** + * Encodes the specified SpeechAdaptationInfo message, length delimited. Does not implicitly {@link google.cloud.speech.v1.SpeechAdaptationInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1.SpeechAdaptationInfo + * @static + * @param {google.cloud.speech.v1.ISpeechAdaptationInfo} message SpeechAdaptationInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpeechAdaptationInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SpeechAdaptationInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1.SpeechAdaptationInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1.SpeechAdaptationInfo} SpeechAdaptationInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeechAdaptationInfo.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.v1.SpeechAdaptationInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.adaptationTimeout = reader.bool(); + break; + } + case 4: { + message.timeoutMessage = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SpeechAdaptationInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1.SpeechAdaptationInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1.SpeechAdaptationInfo} SpeechAdaptationInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeechAdaptationInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SpeechAdaptationInfo message. + * @function verify + * @memberof google.cloud.speech.v1.SpeechAdaptationInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SpeechAdaptationInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.adaptationTimeout != null && message.hasOwnProperty("adaptationTimeout")) + if (typeof message.adaptationTimeout !== "boolean") + return "adaptationTimeout: boolean expected"; + if (message.timeoutMessage != null && message.hasOwnProperty("timeoutMessage")) + if (!$util.isString(message.timeoutMessage)) + return "timeoutMessage: string expected"; + return null; + }; + + /** + * Creates a SpeechAdaptationInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1.SpeechAdaptationInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1.SpeechAdaptationInfo} SpeechAdaptationInfo + */ + SpeechAdaptationInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1.SpeechAdaptationInfo) + return object; + var message = new $root.google.cloud.speech.v1.SpeechAdaptationInfo(); + if (object.adaptationTimeout != null) + message.adaptationTimeout = Boolean(object.adaptationTimeout); + if (object.timeoutMessage != null) + message.timeoutMessage = String(object.timeoutMessage); + return message; + }; + + /** + * Creates a plain object from a SpeechAdaptationInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1.SpeechAdaptationInfo + * @static + * @param {google.cloud.speech.v1.SpeechAdaptationInfo} message SpeechAdaptationInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SpeechAdaptationInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.adaptationTimeout = false; + object.timeoutMessage = ""; + } + if (message.adaptationTimeout != null && message.hasOwnProperty("adaptationTimeout")) + object.adaptationTimeout = message.adaptationTimeout; + if (message.timeoutMessage != null && message.hasOwnProperty("timeoutMessage")) + object.timeoutMessage = message.timeoutMessage; + return object; + }; + + /** + * Converts this SpeechAdaptationInfo to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1.SpeechAdaptationInfo + * @instance + * @returns {Object.} JSON object + */ + SpeechAdaptationInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SpeechAdaptationInfo + * @function getTypeUrl + * @memberof google.cloud.speech.v1.SpeechAdaptationInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SpeechAdaptationInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v1.SpeechAdaptationInfo"; + }; + + return SpeechAdaptationInfo; + })(); + v1.CustomClass = (function() { /** @@ -6963,6 +7386,7 @@ * @property {Array.|null} [phraseSets] SpeechAdaptation phraseSets * @property {Array.|null} [phraseSetReferences] SpeechAdaptation phraseSetReferences * @property {Array.|null} [customClasses] SpeechAdaptation customClasses + * @property {google.cloud.speech.v1.SpeechAdaptation.IABNFGrammar|null} [abnfGrammar] SpeechAdaptation abnfGrammar */ /** @@ -7007,6 +7431,14 @@ */ SpeechAdaptation.prototype.customClasses = $util.emptyArray; + /** + * SpeechAdaptation abnfGrammar. + * @member {google.cloud.speech.v1.SpeechAdaptation.IABNFGrammar|null|undefined} abnfGrammar + * @memberof google.cloud.speech.v1.SpeechAdaptation + * @instance + */ + SpeechAdaptation.prototype.abnfGrammar = null; + /** * Creates a new SpeechAdaptation instance using the specified properties. * @function create @@ -7040,6 +7472,8 @@ if (message.customClasses != null && message.customClasses.length) for (var i = 0; i < message.customClasses.length; ++i) $root.google.cloud.speech.v1.CustomClass.encode(message.customClasses[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.abnfGrammar != null && Object.hasOwnProperty.call(message, "abnfGrammar")) + $root.google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar.encode(message.abnfGrammar, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); return writer; }; @@ -7092,6 +7526,10 @@ message.customClasses.push($root.google.cloud.speech.v1.CustomClass.decode(reader, reader.uint32())); break; } + case 4: { + message.abnfGrammar = $root.google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -7152,6 +7590,11 @@ return "customClasses." + error; } } + if (message.abnfGrammar != null && message.hasOwnProperty("abnfGrammar")) { + var error = $root.google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar.verify(message.abnfGrammar); + if (error) + return "abnfGrammar." + error; + } return null; }; @@ -7194,6 +7637,11 @@ message.customClasses[i] = $root.google.cloud.speech.v1.CustomClass.fromObject(object.customClasses[i]); } } + if (object.abnfGrammar != null) { + if (typeof object.abnfGrammar !== "object") + throw TypeError(".google.cloud.speech.v1.SpeechAdaptation.abnfGrammar: object expected"); + message.abnfGrammar = $root.google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar.fromObject(object.abnfGrammar); + } return message; }; @@ -7215,6 +7663,8 @@ object.phraseSetReferences = []; object.customClasses = []; } + if (options.defaults) + object.abnfGrammar = null; if (message.phraseSets && message.phraseSets.length) { object.phraseSets = []; for (var j = 0; j < message.phraseSets.length; ++j) @@ -7230,6 +7680,8 @@ for (var j = 0; j < message.customClasses.length; ++j) object.customClasses[j] = $root.google.cloud.speech.v1.CustomClass.toObject(message.customClasses[j], options); } + if (message.abnfGrammar != null && message.hasOwnProperty("abnfGrammar")) + object.abnfGrammar = $root.google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar.toObject(message.abnfGrammar, options); return object; }; @@ -7259,24 +7711,243 @@ return typeUrlPrefix + "/google.cloud.speech.v1.SpeechAdaptation"; }; - return SpeechAdaptation; - })(); + SpeechAdaptation.ABNFGrammar = (function() { - v1.Adaptation = (function() { + /** + * Properties of a ABNFGrammar. + * @memberof google.cloud.speech.v1.SpeechAdaptation + * @interface IABNFGrammar + * @property {Array.|null} [abnfStrings] ABNFGrammar abnfStrings + */ - /** - * Constructs a new Adaptation service. - * @memberof google.cloud.speech.v1 - * @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); - } + /** + * Constructs a new ABNFGrammar. + * @memberof google.cloud.speech.v1.SpeechAdaptation + * @classdesc Represents a ABNFGrammar. + * @implements IABNFGrammar + * @constructor + * @param {google.cloud.speech.v1.SpeechAdaptation.IABNFGrammar=} [properties] Properties to set + */ + function ABNFGrammar(properties) { + this.abnfStrings = []; + 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]]; + } + + /** + * ABNFGrammar abnfStrings. + * @member {Array.} abnfStrings + * @memberof google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar + * @instance + */ + ABNFGrammar.prototype.abnfStrings = $util.emptyArray; + + /** + * Creates a new ABNFGrammar instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar + * @static + * @param {google.cloud.speech.v1.SpeechAdaptation.IABNFGrammar=} [properties] Properties to set + * @returns {google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar} ABNFGrammar instance + */ + ABNFGrammar.create = function create(properties) { + return new ABNFGrammar(properties); + }; + + /** + * Encodes the specified ABNFGrammar message. Does not implicitly {@link google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar + * @static + * @param {google.cloud.speech.v1.SpeechAdaptation.IABNFGrammar} message ABNFGrammar message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ABNFGrammar.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.abnfStrings != null && message.abnfStrings.length) + for (var i = 0; i < message.abnfStrings.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.abnfStrings[i]); + return writer; + }; + + /** + * Encodes the specified ABNFGrammar message, length delimited. Does not implicitly {@link google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar + * @static + * @param {google.cloud.speech.v1.SpeechAdaptation.IABNFGrammar} message ABNFGrammar message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ABNFGrammar.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ABNFGrammar message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar} ABNFGrammar + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ABNFGrammar.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.v1.SpeechAdaptation.ABNFGrammar(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.abnfStrings && message.abnfStrings.length)) + message.abnfStrings = []; + message.abnfStrings.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ABNFGrammar message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar} ABNFGrammar + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ABNFGrammar.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ABNFGrammar message. + * @function verify + * @memberof google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ABNFGrammar.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.abnfStrings != null && message.hasOwnProperty("abnfStrings")) { + if (!Array.isArray(message.abnfStrings)) + return "abnfStrings: array expected"; + for (var i = 0; i < message.abnfStrings.length; ++i) + if (!$util.isString(message.abnfStrings[i])) + return "abnfStrings: string[] expected"; + } + return null; + }; + + /** + * Creates a ABNFGrammar message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar} ABNFGrammar + */ + ABNFGrammar.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar) + return object; + var message = new $root.google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar(); + if (object.abnfStrings) { + if (!Array.isArray(object.abnfStrings)) + throw TypeError(".google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar.abnfStrings: array expected"); + message.abnfStrings = []; + for (var i = 0; i < object.abnfStrings.length; ++i) + message.abnfStrings[i] = String(object.abnfStrings[i]); + } + return message; + }; + + /** + * Creates a plain object from a ABNFGrammar message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar + * @static + * @param {google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar} message ABNFGrammar + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ABNFGrammar.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.abnfStrings = []; + if (message.abnfStrings && message.abnfStrings.length) { + object.abnfStrings = []; + for (var j = 0; j < message.abnfStrings.length; ++j) + object.abnfStrings[j] = message.abnfStrings[j]; + } + return object; + }; + + /** + * Converts this ABNFGrammar to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar + * @instance + * @returns {Object.} JSON object + */ + ABNFGrammar.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ABNFGrammar + * @function getTypeUrl + * @memberof google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ABNFGrammar.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v1.SpeechAdaptation.ABNFGrammar"; + }; + + return ABNFGrammar; + })(); + + return SpeechAdaptation; + })(); + + v1.Adaptation = (function() { + + /** + * Constructs a new Adaptation service. + * @memberof google.cloud.speech.v1 + * @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; @@ -14063,6 +14734,8 @@ * @interface IRecognizeResponse * @property {Array.|null} [results] RecognizeResponse results * @property {google.protobuf.IDuration|null} [totalBilledTime] RecognizeResponse totalBilledTime + * @property {google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo|null} [speechAdaptationInfo] RecognizeResponse speechAdaptationInfo + * @property {number|Long|null} [requestId] RecognizeResponse requestId */ /** @@ -14097,6 +14770,22 @@ */ RecognizeResponse.prototype.totalBilledTime = null; + /** + * RecognizeResponse speechAdaptationInfo. + * @member {google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo|null|undefined} speechAdaptationInfo + * @memberof google.cloud.speech.v1p1beta1.RecognizeResponse + * @instance + */ + RecognizeResponse.prototype.speechAdaptationInfo = null; + + /** + * RecognizeResponse requestId. + * @member {number|Long} requestId + * @memberof google.cloud.speech.v1p1beta1.RecognizeResponse + * @instance + */ + RecognizeResponse.prototype.requestId = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + /** * Creates a new RecognizeResponse instance using the specified properties. * @function create @@ -14126,6 +14815,10 @@ $root.google.cloud.speech.v1p1beta1.SpeechRecognitionResult.encode(message.results[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.totalBilledTime != null && Object.hasOwnProperty.call(message, "totalBilledTime")) $root.google.protobuf.Duration.encode(message.totalBilledTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.speechAdaptationInfo != null && Object.hasOwnProperty.call(message, "speechAdaptationInfo")) + $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.encode(message.speechAdaptationInfo, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 8, wireType 0 =*/64).int64(message.requestId); return writer; }; @@ -14170,6 +14863,14 @@ message.totalBilledTime = $root.google.protobuf.Duration.decode(reader, reader.uint32()); break; } + case 7: { + message.speechAdaptationInfo = $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.decode(reader, reader.uint32()); + break; + } + case 8: { + message.requestId = reader.int64(); + break; + } default: reader.skipType(tag & 7); break; @@ -14219,6 +14920,14 @@ if (error) return "totalBilledTime." + error; } + if (message.speechAdaptationInfo != null && message.hasOwnProperty("speechAdaptationInfo")) { + var error = $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.verify(message.speechAdaptationInfo); + if (error) + return "speechAdaptationInfo." + error; + } + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!$util.isInteger(message.requestId) && !(message.requestId && $util.isInteger(message.requestId.low) && $util.isInteger(message.requestId.high))) + return "requestId: integer|Long expected"; return null; }; @@ -14249,6 +14958,20 @@ throw TypeError(".google.cloud.speech.v1p1beta1.RecognizeResponse.totalBilledTime: object expected"); message.totalBilledTime = $root.google.protobuf.Duration.fromObject(object.totalBilledTime); } + if (object.speechAdaptationInfo != null) { + if (typeof object.speechAdaptationInfo !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.RecognizeResponse.speechAdaptationInfo: object expected"); + message.speechAdaptationInfo = $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.fromObject(object.speechAdaptationInfo); + } + if (object.requestId != null) + if ($util.Long) + (message.requestId = $util.Long.fromValue(object.requestId)).unsigned = false; + else if (typeof object.requestId === "string") + message.requestId = parseInt(object.requestId, 10); + else if (typeof object.requestId === "number") + message.requestId = object.requestId; + else if (typeof object.requestId === "object") + message.requestId = new $util.LongBits(object.requestId.low >>> 0, object.requestId.high >>> 0).toNumber(); return message; }; @@ -14267,8 +14990,15 @@ var object = {}; if (options.arrays || options.defaults) object.results = []; - if (options.defaults) + if (options.defaults) { object.totalBilledTime = null; + object.speechAdaptationInfo = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.requestId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.requestId = options.longs === String ? "0" : 0; + } if (message.results && message.results.length) { object.results = []; for (var j = 0; j < message.results.length; ++j) @@ -14276,6 +15006,13 @@ } if (message.totalBilledTime != null && message.hasOwnProperty("totalBilledTime")) object.totalBilledTime = $root.google.protobuf.Duration.toObject(message.totalBilledTime, options); + if (message.speechAdaptationInfo != null && message.hasOwnProperty("speechAdaptationInfo")) + object.speechAdaptationInfo = $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.toObject(message.speechAdaptationInfo, options); + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (typeof message.requestId === "number") + object.requestId = options.longs === String ? String(message.requestId) : message.requestId; + else + object.requestId = options.longs === String ? $util.Long.prototype.toString.call(message.requestId) : options.longs === Number ? new $util.LongBits(message.requestId.low >>> 0, message.requestId.high >>> 0).toNumber() : message.requestId; return object; }; @@ -14318,6 +15055,8 @@ * @property {google.protobuf.IDuration|null} [totalBilledTime] LongRunningRecognizeResponse totalBilledTime * @property {google.cloud.speech.v1p1beta1.ITranscriptOutputConfig|null} [outputConfig] LongRunningRecognizeResponse outputConfig * @property {google.rpc.IStatus|null} [outputError] LongRunningRecognizeResponse outputError + * @property {google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo|null} [speechAdaptationInfo] LongRunningRecognizeResponse speechAdaptationInfo + * @property {number|Long|null} [requestId] LongRunningRecognizeResponse requestId */ /** @@ -14368,6 +15107,22 @@ */ LongRunningRecognizeResponse.prototype.outputError = null; + /** + * LongRunningRecognizeResponse speechAdaptationInfo. + * @member {google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo|null|undefined} speechAdaptationInfo + * @memberof google.cloud.speech.v1p1beta1.LongRunningRecognizeResponse + * @instance + */ + LongRunningRecognizeResponse.prototype.speechAdaptationInfo = null; + + /** + * LongRunningRecognizeResponse requestId. + * @member {number|Long} requestId + * @memberof google.cloud.speech.v1p1beta1.LongRunningRecognizeResponse + * @instance + */ + LongRunningRecognizeResponse.prototype.requestId = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + /** * Creates a new LongRunningRecognizeResponse instance using the specified properties. * @function create @@ -14401,6 +15156,10 @@ $root.google.cloud.speech.v1p1beta1.TranscriptOutputConfig.encode(message.outputConfig, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); if (message.outputError != null && Object.hasOwnProperty.call(message, "outputError")) $root.google.rpc.Status.encode(message.outputError, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.speechAdaptationInfo != null && Object.hasOwnProperty.call(message, "speechAdaptationInfo")) + $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.encode(message.speechAdaptationInfo, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 9, wireType 0 =*/72).int64(message.requestId); return writer; }; @@ -14453,6 +15212,14 @@ message.outputError = $root.google.rpc.Status.decode(reader, reader.uint32()); break; } + case 8: { + message.speechAdaptationInfo = $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.decode(reader, reader.uint32()); + break; + } + case 9: { + message.requestId = reader.int64(); + break; + } default: reader.skipType(tag & 7); break; @@ -14512,6 +15279,14 @@ if (error) return "outputError." + error; } + if (message.speechAdaptationInfo != null && message.hasOwnProperty("speechAdaptationInfo")) { + var error = $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.verify(message.speechAdaptationInfo); + if (error) + return "speechAdaptationInfo." + error; + } + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!$util.isInteger(message.requestId) && !(message.requestId && $util.isInteger(message.requestId.low) && $util.isInteger(message.requestId.high))) + return "requestId: integer|Long expected"; return null; }; @@ -14552,6 +15327,20 @@ throw TypeError(".google.cloud.speech.v1p1beta1.LongRunningRecognizeResponse.outputError: object expected"); message.outputError = $root.google.rpc.Status.fromObject(object.outputError); } + if (object.speechAdaptationInfo != null) { + if (typeof object.speechAdaptationInfo !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.LongRunningRecognizeResponse.speechAdaptationInfo: object expected"); + message.speechAdaptationInfo = $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.fromObject(object.speechAdaptationInfo); + } + if (object.requestId != null) + if ($util.Long) + (message.requestId = $util.Long.fromValue(object.requestId)).unsigned = false; + else if (typeof object.requestId === "string") + message.requestId = parseInt(object.requestId, 10); + else if (typeof object.requestId === "number") + message.requestId = object.requestId; + else if (typeof object.requestId === "object") + message.requestId = new $util.LongBits(object.requestId.low >>> 0, object.requestId.high >>> 0).toNumber(); return message; }; @@ -14574,6 +15363,12 @@ object.totalBilledTime = null; object.outputConfig = null; object.outputError = null; + object.speechAdaptationInfo = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.requestId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.requestId = options.longs === String ? "0" : 0; } if (message.results && message.results.length) { object.results = []; @@ -14586,6 +15381,13 @@ object.outputConfig = $root.google.cloud.speech.v1p1beta1.TranscriptOutputConfig.toObject(message.outputConfig, options); if (message.outputError != null && message.hasOwnProperty("outputError")) object.outputError = $root.google.rpc.Status.toObject(message.outputError, options); + if (message.speechAdaptationInfo != null && message.hasOwnProperty("speechAdaptationInfo")) + object.speechAdaptationInfo = $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.toObject(message.speechAdaptationInfo, options); + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (typeof message.requestId === "number") + object.requestId = options.longs === String ? String(message.requestId) : message.requestId; + else + object.requestId = options.longs === String ? $util.Long.prototype.toString.call(message.requestId) : options.longs === Number ? new $util.LongBits(message.requestId.low >>> 0, message.requestId.high >>> 0).toNumber() : message.requestId; return object; }; @@ -14939,6 +15741,8 @@ * @property {Array.|null} [results] StreamingRecognizeResponse results * @property {google.cloud.speech.v1p1beta1.StreamingRecognizeResponse.SpeechEventType|null} [speechEventType] StreamingRecognizeResponse speechEventType * @property {google.protobuf.IDuration|null} [totalBilledTime] StreamingRecognizeResponse totalBilledTime + * @property {google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo|null} [speechAdaptationInfo] StreamingRecognizeResponse speechAdaptationInfo + * @property {number|Long|null} [requestId] StreamingRecognizeResponse requestId */ /** @@ -14989,6 +15793,22 @@ */ StreamingRecognizeResponse.prototype.totalBilledTime = null; + /** + * StreamingRecognizeResponse speechAdaptationInfo. + * @member {google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo|null|undefined} speechAdaptationInfo + * @memberof google.cloud.speech.v1p1beta1.StreamingRecognizeResponse + * @instance + */ + StreamingRecognizeResponse.prototype.speechAdaptationInfo = null; + + /** + * StreamingRecognizeResponse requestId. + * @member {number|Long} requestId + * @memberof google.cloud.speech.v1p1beta1.StreamingRecognizeResponse + * @instance + */ + StreamingRecognizeResponse.prototype.requestId = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + /** * Creates a new StreamingRecognizeResponse instance using the specified properties. * @function create @@ -15022,6 +15842,10 @@ writer.uint32(/* id 4, wireType 0 =*/32).int32(message.speechEventType); if (message.totalBilledTime != null && Object.hasOwnProperty.call(message, "totalBilledTime")) $root.google.protobuf.Duration.encode(message.totalBilledTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.speechAdaptationInfo != null && Object.hasOwnProperty.call(message, "speechAdaptationInfo")) + $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.encode(message.speechAdaptationInfo, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.requestId != null && Object.hasOwnProperty.call(message, "requestId")) + writer.uint32(/* id 10, wireType 0 =*/80).int64(message.requestId); return writer; }; @@ -15074,6 +15898,14 @@ message.totalBilledTime = $root.google.protobuf.Duration.decode(reader, reader.uint32()); break; } + case 9: { + message.speechAdaptationInfo = $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.decode(reader, reader.uint32()); + break; + } + case 10: { + message.requestId = reader.int64(); + break; + } default: reader.skipType(tag & 7); break; @@ -15136,6 +15968,14 @@ if (error) return "totalBilledTime." + error; } + if (message.speechAdaptationInfo != null && message.hasOwnProperty("speechAdaptationInfo")) { + var error = $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.verify(message.speechAdaptationInfo); + if (error) + return "speechAdaptationInfo." + error; + } + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (!$util.isInteger(message.requestId) && !(message.requestId && $util.isInteger(message.requestId.low) && $util.isInteger(message.requestId.high))) + return "requestId: integer|Long expected"; return null; }; @@ -15187,6 +16027,20 @@ throw TypeError(".google.cloud.speech.v1p1beta1.StreamingRecognizeResponse.totalBilledTime: object expected"); message.totalBilledTime = $root.google.protobuf.Duration.fromObject(object.totalBilledTime); } + if (object.speechAdaptationInfo != null) { + if (typeof object.speechAdaptationInfo !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.StreamingRecognizeResponse.speechAdaptationInfo: object expected"); + message.speechAdaptationInfo = $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.fromObject(object.speechAdaptationInfo); + } + if (object.requestId != null) + if ($util.Long) + (message.requestId = $util.Long.fromValue(object.requestId)).unsigned = false; + else if (typeof object.requestId === "string") + message.requestId = parseInt(object.requestId, 10); + else if (typeof object.requestId === "number") + message.requestId = object.requestId; + else if (typeof object.requestId === "object") + message.requestId = new $util.LongBits(object.requestId.low >>> 0, object.requestId.high >>> 0).toNumber(); return message; }; @@ -15209,6 +16063,12 @@ object.error = null; object.speechEventType = options.enums === String ? "SPEECH_EVENT_UNSPECIFIED" : 0; object.totalBilledTime = null; + object.speechAdaptationInfo = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.requestId = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.requestId = options.longs === String ? "0" : 0; } if (message.error != null && message.hasOwnProperty("error")) object.error = $root.google.rpc.Status.toObject(message.error, options); @@ -15221,6 +16081,13 @@ object.speechEventType = options.enums === String ? $root.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse.SpeechEventType[message.speechEventType] === undefined ? message.speechEventType : $root.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse.SpeechEventType[message.speechEventType] : message.speechEventType; if (message.totalBilledTime != null && message.hasOwnProperty("totalBilledTime")) object.totalBilledTime = $root.google.protobuf.Duration.toObject(message.totalBilledTime, options); + if (message.speechAdaptationInfo != null && message.hasOwnProperty("speechAdaptationInfo")) + object.speechAdaptationInfo = $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.toObject(message.speechAdaptationInfo, options); + if (message.requestId != null && message.hasOwnProperty("requestId")) + if (typeof message.requestId === "number") + object.requestId = options.longs === String ? String(message.requestId) : message.requestId; + else + object.requestId = options.longs === String ? $util.Long.prototype.toString.call(message.requestId) : options.longs === Number ? new $util.LongBits(message.requestId.low >>> 0, message.requestId.high >>> 0).toNumber() : message.requestId; return object; }; @@ -16491,6 +17358,233 @@ return WordInfo; })(); + v1p1beta1.SpeechAdaptationInfo = (function() { + + /** + * Properties of a SpeechAdaptationInfo. + * @memberof google.cloud.speech.v1p1beta1 + * @interface ISpeechAdaptationInfo + * @property {boolean|null} [adaptationTimeout] SpeechAdaptationInfo adaptationTimeout + * @property {string|null} [timeoutMessage] SpeechAdaptationInfo timeoutMessage + */ + + /** + * Constructs a new SpeechAdaptationInfo. + * @memberof google.cloud.speech.v1p1beta1 + * @classdesc Represents a SpeechAdaptationInfo. + * @implements ISpeechAdaptationInfo + * @constructor + * @param {google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo=} [properties] Properties to set + */ + function SpeechAdaptationInfo(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]]; + } + + /** + * SpeechAdaptationInfo adaptationTimeout. + * @member {boolean} adaptationTimeout + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptationInfo + * @instance + */ + SpeechAdaptationInfo.prototype.adaptationTimeout = false; + + /** + * SpeechAdaptationInfo timeoutMessage. + * @member {string} timeoutMessage + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptationInfo + * @instance + */ + SpeechAdaptationInfo.prototype.timeoutMessage = ""; + + /** + * Creates a new SpeechAdaptationInfo instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptationInfo + * @static + * @param {google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.SpeechAdaptationInfo} SpeechAdaptationInfo instance + */ + SpeechAdaptationInfo.create = function create(properties) { + return new SpeechAdaptationInfo(properties); + }; + + /** + * Encodes the specified SpeechAdaptationInfo message. Does not implicitly {@link google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptationInfo + * @static + * @param {google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo} message SpeechAdaptationInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpeechAdaptationInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.adaptationTimeout != null && Object.hasOwnProperty.call(message, "adaptationTimeout")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.adaptationTimeout); + if (message.timeoutMessage != null && Object.hasOwnProperty.call(message, "timeoutMessage")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.timeoutMessage); + return writer; + }; + + /** + * Encodes the specified SpeechAdaptationInfo message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.SpeechAdaptationInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptationInfo + * @static + * @param {google.cloud.speech.v1p1beta1.ISpeechAdaptationInfo} message SpeechAdaptationInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SpeechAdaptationInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SpeechAdaptationInfo message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptationInfo + * @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.SpeechAdaptationInfo} SpeechAdaptationInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeechAdaptationInfo.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.SpeechAdaptationInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.adaptationTimeout = reader.bool(); + break; + } + case 4: { + message.timeoutMessage = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SpeechAdaptationInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptationInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.SpeechAdaptationInfo} SpeechAdaptationInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SpeechAdaptationInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SpeechAdaptationInfo message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptationInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SpeechAdaptationInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.adaptationTimeout != null && message.hasOwnProperty("adaptationTimeout")) + if (typeof message.adaptationTimeout !== "boolean") + return "adaptationTimeout: boolean expected"; + if (message.timeoutMessage != null && message.hasOwnProperty("timeoutMessage")) + if (!$util.isString(message.timeoutMessage)) + return "timeoutMessage: string expected"; + return null; + }; + + /** + * Creates a SpeechAdaptationInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptationInfo + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.SpeechAdaptationInfo} SpeechAdaptationInfo + */ + SpeechAdaptationInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.SpeechAdaptationInfo(); + if (object.adaptationTimeout != null) + message.adaptationTimeout = Boolean(object.adaptationTimeout); + if (object.timeoutMessage != null) + message.timeoutMessage = String(object.timeoutMessage); + return message; + }; + + /** + * Creates a plain object from a SpeechAdaptationInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptationInfo + * @static + * @param {google.cloud.speech.v1p1beta1.SpeechAdaptationInfo} message SpeechAdaptationInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SpeechAdaptationInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.adaptationTimeout = false; + object.timeoutMessage = ""; + } + if (message.adaptationTimeout != null && message.hasOwnProperty("adaptationTimeout")) + object.adaptationTimeout = message.adaptationTimeout; + if (message.timeoutMessage != null && message.hasOwnProperty("timeoutMessage")) + object.timeoutMessage = message.timeoutMessage; + return object; + }; + + /** + * Converts this SpeechAdaptationInfo to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptationInfo + * @instance + * @returns {Object.} JSON object + */ + SpeechAdaptationInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SpeechAdaptationInfo + * @function getTypeUrl + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptationInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SpeechAdaptationInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v1p1beta1.SpeechAdaptationInfo"; + }; + + return SpeechAdaptationInfo; + })(); + v1p1beta1.CustomClass = (function() { /** @@ -17474,6 +18568,7 @@ * @property {Array.|null} [phraseSets] SpeechAdaptation phraseSets * @property {Array.|null} [phraseSetReferences] SpeechAdaptation phraseSetReferences * @property {Array.|null} [customClasses] SpeechAdaptation customClasses + * @property {google.cloud.speech.v1p1beta1.SpeechAdaptation.IABNFGrammar|null} [abnfGrammar] SpeechAdaptation abnfGrammar */ /** @@ -17518,6 +18613,14 @@ */ SpeechAdaptation.prototype.customClasses = $util.emptyArray; + /** + * SpeechAdaptation abnfGrammar. + * @member {google.cloud.speech.v1p1beta1.SpeechAdaptation.IABNFGrammar|null|undefined} abnfGrammar + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation + * @instance + */ + SpeechAdaptation.prototype.abnfGrammar = null; + /** * Creates a new SpeechAdaptation instance using the specified properties. * @function create @@ -17551,6 +18654,8 @@ 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 3, wireType 2 =*/26).fork()).ldelim(); + if (message.abnfGrammar != null && Object.hasOwnProperty.call(message, "abnfGrammar")) + $root.google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar.encode(message.abnfGrammar, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); return writer; }; @@ -17603,6 +18708,10 @@ message.customClasses.push($root.google.cloud.speech.v1p1beta1.CustomClass.decode(reader, reader.uint32())); break; } + case 4: { + message.abnfGrammar = $root.google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -17663,6 +18772,11 @@ return "customClasses." + error; } } + if (message.abnfGrammar != null && message.hasOwnProperty("abnfGrammar")) { + var error = $root.google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar.verify(message.abnfGrammar); + if (error) + return "abnfGrammar." + error; + } return null; }; @@ -17705,6 +18819,11 @@ message.customClasses[i] = $root.google.cloud.speech.v1p1beta1.CustomClass.fromObject(object.customClasses[i]); } } + if (object.abnfGrammar != null) { + if (typeof object.abnfGrammar !== "object") + throw TypeError(".google.cloud.speech.v1p1beta1.SpeechAdaptation.abnfGrammar: object expected"); + message.abnfGrammar = $root.google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar.fromObject(object.abnfGrammar); + } return message; }; @@ -17726,6 +18845,8 @@ object.phraseSetReferences = []; object.customClasses = []; } + if (options.defaults) + object.abnfGrammar = null; if (message.phraseSets && message.phraseSets.length) { object.phraseSets = []; for (var j = 0; j < message.phraseSets.length; ++j) @@ -17741,6 +18862,8 @@ 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.abnfGrammar != null && message.hasOwnProperty("abnfGrammar")) + object.abnfGrammar = $root.google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar.toObject(message.abnfGrammar, options); return object; }; @@ -17770,6 +18893,225 @@ return typeUrlPrefix + "/google.cloud.speech.v1p1beta1.SpeechAdaptation"; }; + SpeechAdaptation.ABNFGrammar = (function() { + + /** + * Properties of a ABNFGrammar. + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation + * @interface IABNFGrammar + * @property {Array.|null} [abnfStrings] ABNFGrammar abnfStrings + */ + + /** + * Constructs a new ABNFGrammar. + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation + * @classdesc Represents a ABNFGrammar. + * @implements IABNFGrammar + * @constructor + * @param {google.cloud.speech.v1p1beta1.SpeechAdaptation.IABNFGrammar=} [properties] Properties to set + */ + function ABNFGrammar(properties) { + this.abnfStrings = []; + 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]]; + } + + /** + * ABNFGrammar abnfStrings. + * @member {Array.} abnfStrings + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar + * @instance + */ + ABNFGrammar.prototype.abnfStrings = $util.emptyArray; + + /** + * Creates a new ABNFGrammar instance using the specified properties. + * @function create + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar + * @static + * @param {google.cloud.speech.v1p1beta1.SpeechAdaptation.IABNFGrammar=} [properties] Properties to set + * @returns {google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar} ABNFGrammar instance + */ + ABNFGrammar.create = function create(properties) { + return new ABNFGrammar(properties); + }; + + /** + * Encodes the specified ABNFGrammar message. Does not implicitly {@link google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar.verify|verify} messages. + * @function encode + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar + * @static + * @param {google.cloud.speech.v1p1beta1.SpeechAdaptation.IABNFGrammar} message ABNFGrammar message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ABNFGrammar.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.abnfStrings != null && message.abnfStrings.length) + for (var i = 0; i < message.abnfStrings.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.abnfStrings[i]); + return writer; + }; + + /** + * Encodes the specified ABNFGrammar message, length delimited. Does not implicitly {@link google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar + * @static + * @param {google.cloud.speech.v1p1beta1.SpeechAdaptation.IABNFGrammar} message ABNFGrammar message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ABNFGrammar.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ABNFGrammar message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar + * @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.SpeechAdaptation.ABNFGrammar} ABNFGrammar + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ABNFGrammar.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.SpeechAdaptation.ABNFGrammar(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.abnfStrings && message.abnfStrings.length)) + message.abnfStrings = []; + message.abnfStrings.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ABNFGrammar message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar} ABNFGrammar + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ABNFGrammar.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ABNFGrammar message. + * @function verify + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ABNFGrammar.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.abnfStrings != null && message.hasOwnProperty("abnfStrings")) { + if (!Array.isArray(message.abnfStrings)) + return "abnfStrings: array expected"; + for (var i = 0; i < message.abnfStrings.length; ++i) + if (!$util.isString(message.abnfStrings[i])) + return "abnfStrings: string[] expected"; + } + return null; + }; + + /** + * Creates a ABNFGrammar message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar} ABNFGrammar + */ + ABNFGrammar.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar) + return object; + var message = new $root.google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar(); + if (object.abnfStrings) { + if (!Array.isArray(object.abnfStrings)) + throw TypeError(".google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar.abnfStrings: array expected"); + message.abnfStrings = []; + for (var i = 0; i < object.abnfStrings.length; ++i) + message.abnfStrings[i] = String(object.abnfStrings[i]); + } + return message; + }; + + /** + * Creates a plain object from a ABNFGrammar message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar + * @static + * @param {google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar} message ABNFGrammar + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ABNFGrammar.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.abnfStrings = []; + if (message.abnfStrings && message.abnfStrings.length) { + object.abnfStrings = []; + for (var j = 0; j < message.abnfStrings.length; ++j) + object.abnfStrings[j] = message.abnfStrings[j]; + } + return object; + }; + + /** + * Converts this ABNFGrammar to JSON. + * @function toJSON + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar + * @instance + * @returns {Object.} JSON object + */ + ABNFGrammar.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ABNFGrammar + * @function getTypeUrl + * @memberof google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ABNFGrammar.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.speech.v1p1beta1.SpeechAdaptation.ABNFGrammar"; + }; + + return ABNFGrammar; + })(); + return SpeechAdaptation; })(); diff --git a/protos/protos.json b/protos/protos.json index 8a11a1b3..bcc5a168 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -422,6 +422,14 @@ "totalBilledTime": { "type": "google.protobuf.Duration", "id": 3 + }, + "speechAdaptationInfo": { + "type": "SpeechAdaptationInfo", + "id": 7 + }, + "requestId": { + "type": "int64", + "id": 8 } } }, @@ -443,6 +451,14 @@ "outputError": { "type": "google.rpc.Status", "id": 7 + }, + "speechAdaptationInfo": { + "type": "SpeechAdaptationInfo", + "id": 8 + }, + "requestId": { + "type": "int64", + "id": 9 } } }, @@ -487,6 +503,14 @@ "totalBilledTime": { "type": "google.protobuf.Duration", "id": 5 + }, + "speechAdaptationInfo": { + "type": "SpeechAdaptationInfo", + "id": 9 + }, + "requestId": { + "type": "int64", + "id": 10 } }, "nested": { @@ -598,6 +622,18 @@ } } }, + "SpeechAdaptationInfo": { + "fields": { + "adaptationTimeout": { + "type": "bool", + "id": 1 + }, + "timeoutMessage": { + "type": "string", + "id": 4 + } + } + }, "CustomClass": { "options": { "(google.api.resource).type": "speech.googleapis.com/CustomClass", @@ -683,6 +719,21 @@ "rule": "repeated", "type": "CustomClass", "id": 3 + }, + "abnfGrammar": { + "type": "ABNFGrammar", + "id": 4 + } + }, + "nested": { + "ABNFGrammar": { + "fields": { + "abnfStrings": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } } } }, @@ -1522,6 +1573,14 @@ "totalBilledTime": { "type": "google.protobuf.Duration", "id": 3 + }, + "speechAdaptationInfo": { + "type": "SpeechAdaptationInfo", + "id": 7 + }, + "requestId": { + "type": "int64", + "id": 8 } } }, @@ -1543,6 +1602,14 @@ "outputError": { "type": "google.rpc.Status", "id": 7 + }, + "speechAdaptationInfo": { + "type": "SpeechAdaptationInfo", + "id": 8 + }, + "requestId": { + "type": "int64", + "id": 9 } } }, @@ -1594,6 +1661,14 @@ "totalBilledTime": { "type": "google.protobuf.Duration", "id": 5 + }, + "speechAdaptationInfo": { + "type": "SpeechAdaptationInfo", + "id": 9 + }, + "requestId": { + "type": "int64", + "id": 10 } }, "nested": { @@ -1705,6 +1780,18 @@ } } }, + "SpeechAdaptationInfo": { + "fields": { + "adaptationTimeout": { + "type": "bool", + "id": 1 + }, + "timeoutMessage": { + "type": "string", + "id": 4 + } + } + }, "CustomClass": { "options": { "(google.api.resource).type": "speech.googleapis.com/CustomClass", @@ -1790,6 +1877,21 @@ "rule": "repeated", "type": "CustomClass", "id": 3 + }, + "abnfGrammar": { + "type": "ABNFGrammar", + "id": 4 + } + }, + "nested": { + "ABNFGrammar": { + "fields": { + "abnfStrings": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } } } }, diff --git a/samples/generated/v1/adaptation.create_custom_class.js b/samples/generated/v1/adaptation.create_custom_class.js index ebc4d9be..d148d4f4 100644 --- a/samples/generated/v1/adaptation.create_custom_class.js +++ b/samples/generated/v1/adaptation.create_custom_class.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1/adaptation.create_phrase_set.js b/samples/generated/v1/adaptation.create_phrase_set.js index 7aedc67a..ba2132aa 100644 --- a/samples/generated/v1/adaptation.create_phrase_set.js +++ b/samples/generated/v1/adaptation.create_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1/adaptation.delete_custom_class.js b/samples/generated/v1/adaptation.delete_custom_class.js index 09105820..bbefe64f 100644 --- a/samples/generated/v1/adaptation.delete_custom_class.js +++ b/samples/generated/v1/adaptation.delete_custom_class.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1/adaptation.delete_phrase_set.js b/samples/generated/v1/adaptation.delete_phrase_set.js index 18e7f7ff..0bbee4c5 100644 --- a/samples/generated/v1/adaptation.delete_phrase_set.js +++ b/samples/generated/v1/adaptation.delete_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1/adaptation.get_custom_class.js b/samples/generated/v1/adaptation.get_custom_class.js index 40cffe02..7336aad4 100644 --- a/samples/generated/v1/adaptation.get_custom_class.js +++ b/samples/generated/v1/adaptation.get_custom_class.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1/adaptation.get_phrase_set.js b/samples/generated/v1/adaptation.get_phrase_set.js index 65ccaa4b..519b4364 100644 --- a/samples/generated/v1/adaptation.get_phrase_set.js +++ b/samples/generated/v1/adaptation.get_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1/adaptation.list_custom_classes.js b/samples/generated/v1/adaptation.list_custom_classes.js index bb2692b8..f09631fb 100644 --- a/samples/generated/v1/adaptation.list_custom_classes.js +++ b/samples/generated/v1/adaptation.list_custom_classes.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1/adaptation.list_phrase_set.js b/samples/generated/v1/adaptation.list_phrase_set.js index 14f715d8..bbcf9651 100644 --- a/samples/generated/v1/adaptation.list_phrase_set.js +++ b/samples/generated/v1/adaptation.list_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1/adaptation.update_custom_class.js b/samples/generated/v1/adaptation.update_custom_class.js index a5b6946e..f4cce56d 100644 --- a/samples/generated/v1/adaptation.update_custom_class.js +++ b/samples/generated/v1/adaptation.update_custom_class.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1/adaptation.update_phrase_set.js b/samples/generated/v1/adaptation.update_phrase_set.js index 076453a9..87d1e71b 100644 --- a/samples/generated/v1/adaptation.update_phrase_set.js +++ b/samples/generated/v1/adaptation.update_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1/speech.long_running_recognize.js b/samples/generated/v1/speech.long_running_recognize.js index 0400a955..d55a1505 100644 --- a/samples/generated/v1/speech.long_running_recognize.js +++ b/samples/generated/v1/speech.long_running_recognize.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1/speech.recognize.js b/samples/generated/v1/speech.recognize.js index 4d3d67cd..ee2466ac 100644 --- a/samples/generated/v1/speech.recognize.js +++ b/samples/generated/v1/speech.recognize.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1/speech.streaming_recognize.js b/samples/generated/v1/speech.streaming_recognize.js index 39205be9..12524b47 100644 --- a/samples/generated/v1/speech.streaming_recognize.js +++ b/samples/generated/v1/speech.streaming_recognize.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1p1beta1/adaptation.create_custom_class.js b/samples/generated/v1p1beta1/adaptation.create_custom_class.js index 0429b977..9ce168a3 100644 --- a/samples/generated/v1p1beta1/adaptation.create_custom_class.js +++ b/samples/generated/v1p1beta1/adaptation.create_custom_class.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1p1beta1/adaptation.create_phrase_set.js b/samples/generated/v1p1beta1/adaptation.create_phrase_set.js index 4025a95d..0f235669 100644 --- a/samples/generated/v1p1beta1/adaptation.create_phrase_set.js +++ b/samples/generated/v1p1beta1/adaptation.create_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1p1beta1/adaptation.delete_custom_class.js b/samples/generated/v1p1beta1/adaptation.delete_custom_class.js index 47693ff1..e2306de6 100644 --- a/samples/generated/v1p1beta1/adaptation.delete_custom_class.js +++ b/samples/generated/v1p1beta1/adaptation.delete_custom_class.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1p1beta1/adaptation.delete_phrase_set.js b/samples/generated/v1p1beta1/adaptation.delete_phrase_set.js index 76aed0d0..2c83406b 100644 --- a/samples/generated/v1p1beta1/adaptation.delete_phrase_set.js +++ b/samples/generated/v1p1beta1/adaptation.delete_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1p1beta1/adaptation.get_custom_class.js b/samples/generated/v1p1beta1/adaptation.get_custom_class.js index 2e4208b9..486e9bd1 100644 --- a/samples/generated/v1p1beta1/adaptation.get_custom_class.js +++ b/samples/generated/v1p1beta1/adaptation.get_custom_class.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1p1beta1/adaptation.get_phrase_set.js b/samples/generated/v1p1beta1/adaptation.get_phrase_set.js index b94463a1..f48582a0 100644 --- a/samples/generated/v1p1beta1/adaptation.get_phrase_set.js +++ b/samples/generated/v1p1beta1/adaptation.get_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1p1beta1/adaptation.list_custom_classes.js b/samples/generated/v1p1beta1/adaptation.list_custom_classes.js index 8a935c16..e6ee125f 100644 --- a/samples/generated/v1p1beta1/adaptation.list_custom_classes.js +++ b/samples/generated/v1p1beta1/adaptation.list_custom_classes.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1p1beta1/adaptation.list_phrase_set.js b/samples/generated/v1p1beta1/adaptation.list_phrase_set.js index 0912eb8f..dad5c3fa 100644 --- a/samples/generated/v1p1beta1/adaptation.list_phrase_set.js +++ b/samples/generated/v1p1beta1/adaptation.list_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1p1beta1/adaptation.update_custom_class.js b/samples/generated/v1p1beta1/adaptation.update_custom_class.js index 7676ed2a..202f17bf 100644 --- a/samples/generated/v1p1beta1/adaptation.update_custom_class.js +++ b/samples/generated/v1p1beta1/adaptation.update_custom_class.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1p1beta1/adaptation.update_phrase_set.js b/samples/generated/v1p1beta1/adaptation.update_phrase_set.js index 8a8b15a3..9d92540d 100644 --- a/samples/generated/v1p1beta1/adaptation.update_phrase_set.js +++ b/samples/generated/v1p1beta1/adaptation.update_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1p1beta1/speech.long_running_recognize.js b/samples/generated/v1p1beta1/speech.long_running_recognize.js index 5521bfb8..8bea3bd5 100644 --- a/samples/generated/v1p1beta1/speech.long_running_recognize.js +++ b/samples/generated/v1p1beta1/speech.long_running_recognize.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1p1beta1/speech.recognize.js b/samples/generated/v1p1beta1/speech.recognize.js index 8d1ba6b1..1b2591c0 100644 --- a/samples/generated/v1p1beta1/speech.recognize.js +++ b/samples/generated/v1p1beta1/speech.recognize.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v1p1beta1/speech.streaming_recognize.js b/samples/generated/v1p1beta1/speech.streaming_recognize.js index 5cd87845..23ef34bd 100644 --- a/samples/generated/v1p1beta1/speech.streaming_recognize.js +++ b/samples/generated/v1p1beta1/speech.streaming_recognize.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.batch_recognize.js b/samples/generated/v2/speech.batch_recognize.js index 38711397..1f5d23c1 100644 --- a/samples/generated/v2/speech.batch_recognize.js +++ b/samples/generated/v2/speech.batch_recognize.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.create_custom_class.js b/samples/generated/v2/speech.create_custom_class.js index 9527870a..d2664dac 100644 --- a/samples/generated/v2/speech.create_custom_class.js +++ b/samples/generated/v2/speech.create_custom_class.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.create_phrase_set.js b/samples/generated/v2/speech.create_phrase_set.js index ac0043ed..8220fecc 100644 --- a/samples/generated/v2/speech.create_phrase_set.js +++ b/samples/generated/v2/speech.create_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.create_recognizer.js b/samples/generated/v2/speech.create_recognizer.js index 29613c7d..394807b0 100644 --- a/samples/generated/v2/speech.create_recognizer.js +++ b/samples/generated/v2/speech.create_recognizer.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.delete_custom_class.js b/samples/generated/v2/speech.delete_custom_class.js index 273a7fb7..e5698c47 100644 --- a/samples/generated/v2/speech.delete_custom_class.js +++ b/samples/generated/v2/speech.delete_custom_class.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.delete_phrase_set.js b/samples/generated/v2/speech.delete_phrase_set.js index ceef8b27..ccd1e668 100644 --- a/samples/generated/v2/speech.delete_phrase_set.js +++ b/samples/generated/v2/speech.delete_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.delete_recognizer.js b/samples/generated/v2/speech.delete_recognizer.js index bfe1e3d6..f09bf435 100644 --- a/samples/generated/v2/speech.delete_recognizer.js +++ b/samples/generated/v2/speech.delete_recognizer.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.get_config.js b/samples/generated/v2/speech.get_config.js index 99a2f0c0..3924b912 100644 --- a/samples/generated/v2/speech.get_config.js +++ b/samples/generated/v2/speech.get_config.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.get_custom_class.js b/samples/generated/v2/speech.get_custom_class.js index 733eeb01..ec6e7f03 100644 --- a/samples/generated/v2/speech.get_custom_class.js +++ b/samples/generated/v2/speech.get_custom_class.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.get_phrase_set.js b/samples/generated/v2/speech.get_phrase_set.js index abdf07d9..775ca046 100644 --- a/samples/generated/v2/speech.get_phrase_set.js +++ b/samples/generated/v2/speech.get_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.get_recognizer.js b/samples/generated/v2/speech.get_recognizer.js index c08c8b94..80f04494 100644 --- a/samples/generated/v2/speech.get_recognizer.js +++ b/samples/generated/v2/speech.get_recognizer.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.list_custom_classes.js b/samples/generated/v2/speech.list_custom_classes.js index 740d5ecd..275b5920 100644 --- a/samples/generated/v2/speech.list_custom_classes.js +++ b/samples/generated/v2/speech.list_custom_classes.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.list_phrase_sets.js b/samples/generated/v2/speech.list_phrase_sets.js index 0a54a64a..e4f73a9e 100644 --- a/samples/generated/v2/speech.list_phrase_sets.js +++ b/samples/generated/v2/speech.list_phrase_sets.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.list_recognizers.js b/samples/generated/v2/speech.list_recognizers.js index 7ce62ed5..94b2123e 100644 --- a/samples/generated/v2/speech.list_recognizers.js +++ b/samples/generated/v2/speech.list_recognizers.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.recognize.js b/samples/generated/v2/speech.recognize.js index 7a4c0bd1..a0afd3c3 100644 --- a/samples/generated/v2/speech.recognize.js +++ b/samples/generated/v2/speech.recognize.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.streaming_recognize.js b/samples/generated/v2/speech.streaming_recognize.js index a774b855..c5d42a3f 100644 --- a/samples/generated/v2/speech.streaming_recognize.js +++ b/samples/generated/v2/speech.streaming_recognize.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.undelete_custom_class.js b/samples/generated/v2/speech.undelete_custom_class.js index 0abcc642..2feff89b 100644 --- a/samples/generated/v2/speech.undelete_custom_class.js +++ b/samples/generated/v2/speech.undelete_custom_class.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.undelete_phrase_set.js b/samples/generated/v2/speech.undelete_phrase_set.js index 35c4387a..6a6e6cf7 100644 --- a/samples/generated/v2/speech.undelete_phrase_set.js +++ b/samples/generated/v2/speech.undelete_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.undelete_recognizer.js b/samples/generated/v2/speech.undelete_recognizer.js index 8f361f35..63bbb100 100644 --- a/samples/generated/v2/speech.undelete_recognizer.js +++ b/samples/generated/v2/speech.undelete_recognizer.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.update_config.js b/samples/generated/v2/speech.update_config.js index ecff3491..048aae6b 100644 --- a/samples/generated/v2/speech.update_config.js +++ b/samples/generated/v2/speech.update_config.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.update_custom_class.js b/samples/generated/v2/speech.update_custom_class.js index bd9d42fd..83a4bb86 100644 --- a/samples/generated/v2/speech.update_custom_class.js +++ b/samples/generated/v2/speech.update_custom_class.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.update_phrase_set.js b/samples/generated/v2/speech.update_phrase_set.js index 5f4638e0..f1d3cb6d 100644 --- a/samples/generated/v2/speech.update_phrase_set.js +++ b/samples/generated/v2/speech.update_phrase_set.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/samples/generated/v2/speech.update_recognizer.js b/samples/generated/v2/speech.update_recognizer.js index c455d581..72ddd754 100644 --- a/samples/generated/v2/speech.update_recognizer.js +++ b/samples/generated/v2/speech.update_recognizer.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/v1/adaptation_client.ts b/src/v1/adaptation_client.ts index 33eec017..393b16e3 100644 --- a/src/v1/adaptation_client.ts +++ b/src/v1/adaptation_client.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -120,6 +120,9 @@ export class AdaptationClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // 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; diff --git a/src/v1/index.ts b/src/v1/index.ts index 5b4cfbf4..516c23c3 100644 --- a/src/v1/index.ts +++ b/src/v1/index.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/v1/speech_client.ts b/src/v1/speech_client.ts index 17d5dbb3..3873facd 100644 --- a/src/v1/speech_client.ts +++ b/src/v1/speech_client.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -121,6 +121,9 @@ export class SpeechClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // 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; @@ -632,6 +635,183 @@ export class SpeechClient { protos.google.cloud.speech.v1.LongRunningRecognizeMetadata >; } + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + // -------------------- // -- Path templates -- // -------------------- diff --git a/src/v1p1beta1/adaptation_client.ts b/src/v1p1beta1/adaptation_client.ts index 80f1ff00..827180ed 100644 --- a/src/v1p1beta1/adaptation_client.ts +++ b/src/v1p1beta1/adaptation_client.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -120,6 +120,9 @@ export class AdaptationClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // 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; diff --git a/src/v1p1beta1/index.ts b/src/v1p1beta1/index.ts index 5b4cfbf4..516c23c3 100644 --- a/src/v1p1beta1/index.ts +++ b/src/v1p1beta1/index.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/v1p1beta1/speech_client.ts b/src/v1p1beta1/speech_client.ts index 026f0d3d..197f7b7c 100644 --- a/src/v1p1beta1/speech_client.ts +++ b/src/v1p1beta1/speech_client.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -121,6 +121,9 @@ export class SpeechClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // 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; @@ -634,6 +637,183 @@ export class SpeechClient { protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeMetadata >; } + /** + * Gets the latest state of a long-running operation. Clients can use this + * method to poll the operation result at intervals as recommended by the API + * service. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error, ?Object)=} callback + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. + * @return {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * [google.longrunning.Operation]{@link + * external:"google.longrunning.Operation"}. The promise has a method named + * "cancel" which cancels the ongoing API call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * const name = ''; + * const [response] = await client.getOperation({name}); + * // doThingsWith(response) + * ``` + */ + getOperation( + request: protos.google.longrunning.GetOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.longrunning.Operation, + protos.google.longrunning.GetOperationRequest, + {} | null | undefined + > + ): Promise<[protos.google.longrunning.Operation]> { + return this.operationsClient.getOperation(request, options, callback); + } + /** + * Lists operations that match the specified filter in the request. If the + * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. + * + * For-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation collection. + * @param {string} request.filter - The standard list filter. + * @param {number=} request.pageSize - + * The maximum number of resources contained in the underlying API + * response. If page streaming is performed per-resource, this + * parameter does not affect the return value. If page streaming is + * performed per-page, this determines the maximum number of + * resources in a page. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * for await (const response of client.listOperationsAsync(request)); + * // doThingsWith(response) + * ``` + */ + listOperationsAsync( + request: protos.google.longrunning.ListOperationsRequest, + options?: gax.CallOptions + ): AsyncIterable { + return this.operationsClient.listOperationsAsync(request, options); + } + /** + * Starts asynchronous cancellation on a long-running operation. The server + * makes a best effort to cancel the operation, but success is not + * guaranteed. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. Clients can use + * {@link Operations.GetOperation} or + * other methods to check whether the cancellation succeeded or whether the + * operation completed despite cancellation. On successful cancellation, + * the operation is not deleted; instead, it becomes an operation with + * an {@link Operation.error} value with a {@link google.rpc.Status.code} of + * 1, corresponding to `Code.CANCELLED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be cancelled. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.cancelOperation({name: ''}); + * ``` + */ + cancelOperation( + request: protos.google.longrunning.CancelOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.CancelOperationRequest, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + > + ): Promise { + return this.operationsClient.cancelOperation(request, options, callback); + } + + /** + * Deletes a long-running operation. This method indicates that the client is + * no longer interested in the operation result. It does not cancel the + * operation. If the server doesn't support this method, it returns + * `google.rpc.Code.UNIMPLEMENTED`. + * + * @param {Object} request - The request object that will be sent. + * @param {string} request.name - The name of the operation resource to be deleted. + * @param {Object=} options + * Optional parameters. You can override the default settings for this call, + * e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the + * details. + * @param {function(?Error)=} callback + * The function which will be called with the result of the API call. + * @return {Promise} - The promise which resolves when API call finishes. + * The promise has a method named "cancel" which cancels the ongoing API + * call. + * + * @example + * ``` + * const client = longrunning.operationsClient(); + * await client.deleteOperation({name: ''}); + * ``` + */ + deleteOperation( + request: protos.google.longrunning.DeleteOperationRequest, + options?: + | gax.CallOptions + | Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.Empty, + protos.google.longrunning.DeleteOperationRequest, + {} | null | undefined + > + ): Promise { + return this.operationsClient.deleteOperation(request, options, callback); + } + // -------------------- // -- Path templates -- // -------------------- diff --git a/src/v2/index.ts b/src/v2/index.ts index 9e550a1a..cb4fd78a 100644 --- a/src/v2/index.ts +++ b/src/v2/index.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/src/v2/speech_client.ts b/src/v2/speech_client.ts index fb4813a3..c5cfdacf 100644 --- a/src/v2/speech_client.ts +++ b/src/v2/speech_client.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -123,6 +123,9 @@ export class SpeechClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // 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; diff --git a/system-test/fixtures/sample/src/index.js b/system-test/fixtures/sample/src/index.js index a1c1745b..88650026 100644 --- a/system-test/fixtures/sample/src/index.js +++ b/system-test/fixtures/sample/src/index.js @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/system-test/fixtures/sample/src/index.ts b/system-test/fixtures/sample/src/index.ts index 1c746cf8..8171ad1f 100644 --- a/system-test/fixtures/sample/src/index.ts +++ b/system-test/fixtures/sample/src/index.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/system-test/install.ts b/system-test/install.ts index 6dd1eaad..f61fe236 100644 --- a/system-test/install.ts +++ b/system-test/install.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/gapic_adaptation_v1.ts b/test/gapic_adaptation_v1.ts index b623764d..85421c74 100644 --- a/test/gapic_adaptation_v1.ts +++ b/test/gapic_adaptation_v1.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/gapic_adaptation_v1p1beta1.ts b/test/gapic_adaptation_v1p1beta1.ts index 4c749174..5bc07ef2 100644 --- a/test/gapic_adaptation_v1p1beta1.ts +++ b/test/gapic_adaptation_v1p1beta1.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/gapic_speech_v1.ts b/test/gapic_speech_v1.ts index 5ff11d05..f152ae60 100644 --- a/test/gapic_speech_v1.ts +++ b/test/gapic_speech_v1.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -112,6 +112,29 @@ function stubLongRunningCallWithCallback( : sinon.stub().callsArgWith(2, null, mockOperation); } +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('v1.SpeechClient', () => { describe('Common methods', () => { it('has servicePath', () => { @@ -517,6 +540,311 @@ describe('v1.SpeechClient', () => { ); }); }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); describe('Path templates', () => { describe('customClass', () => { diff --git a/test/gapic_speech_v1p1beta1.ts b/test/gapic_speech_v1p1beta1.ts index 9784590e..9d29eb0b 100644 --- a/test/gapic_speech_v1p1beta1.ts +++ b/test/gapic_speech_v1p1beta1.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -112,6 +112,29 @@ function stubLongRunningCallWithCallback( : sinon.stub().callsArgWith(2, null, mockOperation); } +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.SpeechClient', () => { describe('Common methods', () => { it('has servicePath', () => { @@ -517,6 +540,311 @@ describe('v1p1beta1.SpeechClient', () => { ); }); }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); describe('Path templates', () => { describe('customClass', () => { diff --git a/test/gapic_speech_v2.ts b/test/gapic_speech_v2.ts index 168a00b0..8b1aec2d 100644 --- a/test/gapic_speech_v2.ts +++ b/test/gapic_speech_v2.ts @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.