diff --git a/protos/google/cloud/dialogflow/v2/audio_config.proto b/protos/google/cloud/dialogflow/v2/audio_config.proto index 98258ee2..b86a9d3a 100644 --- a/protos/google/cloud/dialogflow/v2/audio_config.proto +++ b/protos/google/cloud/dialogflow/v2/audio_config.proto @@ -369,6 +369,67 @@ message OutputAudioConfig { SynthesizeSpeechConfig synthesize_speech_config = 3; } +// [DTMF](https://en.wikipedia.org/wiki/Dual-tone_multi-frequency_signaling) +// digit in Telephony Gateway. +enum TelephonyDtmf { + // Not specified. This value may be used to indicate an absent digit. + TELEPHONY_DTMF_UNSPECIFIED = 0; + + // Number: '1'. + DTMF_ONE = 1; + + // Number: '2'. + DTMF_TWO = 2; + + // Number: '3'. + DTMF_THREE = 3; + + // Number: '4'. + DTMF_FOUR = 4; + + // Number: '5'. + DTMF_FIVE = 5; + + // Number: '6'. + DTMF_SIX = 6; + + // Number: '7'. + DTMF_SEVEN = 7; + + // Number: '8'. + DTMF_EIGHT = 8; + + // Number: '9'. + DTMF_NINE = 9; + + // Number: '0'. + DTMF_ZERO = 10; + + // Letter: 'A'. + DTMF_A = 11; + + // Letter: 'B'. + DTMF_B = 12; + + // Letter: 'C'. + DTMF_C = 13; + + // Letter: 'D'. + DTMF_D = 14; + + // Asterisk/star: '*'. + DTMF_STAR = 15; + + // Pound/diamond/hash/square/gate/octothorpe: '#'. + DTMF_POUND = 16; +} + +// A wrapper of repeated TelephonyDtmf digits. +message TelephonyDtmfEvents { + // A sequence of TelephonyDtmf digits. + repeated TelephonyDtmf dtmf_events = 1; +} + // Configures speech transcription for [ConversationProfile][google.cloud.dialogflow.v2.ConversationProfile]. message SpeechToTextConfig { // The speech model used in speech to text. @@ -379,4 +440,13 @@ message SpeechToTextConfig { // version of the specified model for the language does not exist, then it // would emit an error. SpeechModelVariant speech_model_variant = 1; + + // Which Speech model to select. Select the model best suited to your domain + // to get best results. If a model is not explicitly specified, then a default + // model is used. + // Refer to + // [Cloud Speech API + // documentation](https://cloud.google.com/speech-to-text/docs/basics#select-model) + // for more details. + string model = 2; } diff --git a/protos/google/cloud/dialogflow/v2/participant.proto b/protos/google/cloud/dialogflow/v2/participant.proto index 35b6106e..a39d49fb 100644 --- a/protos/google/cloud/dialogflow/v2/participant.proto +++ b/protos/google/cloud/dialogflow/v2/participant.proto @@ -109,6 +109,24 @@ service Participants { option (google.api.method_signature) = "participant,event_input"; } + // Adds a text (chat, for example), or audio (phone recording, for example) + // message from a participant into the conversation. + // Note: This method is only available through the gRPC API (not REST). + // + // The top-level message sent to the client by the server is + // `StreamingAnalyzeContentResponse`. Multiple response messages can be + // returned in order. The first one or more messages contain the + // `recognition_result` field. Each result represents a more complete + // transcript of what the user said. The next message contains the + // `reply_text` field and potentially the `reply_audio` field. The message can + // also contain the `automated_agent_reply` field. + // + // Note: Always use agent versions for production traffic + // sent to virtual agents. See [Versions and + // environments](https://cloud.google.com/dialogflow/es/docs/agents-versions). + rpc StreamingAnalyzeContent(stream StreamingAnalyzeContentRequest) returns (stream StreamingAnalyzeContentResponse) { + } + // Gets suggested articles for a participant based on specific historical // messages. rpc SuggestArticles(SuggestArticlesRequest) returns (SuggestArticlesResponse) { @@ -190,6 +208,36 @@ message Participant { // media stream to this participant. This field can be updated. string sip_recording_media_label = 6 [(google.api.field_behavior) = OPTIONAL]; + // Optional. Obfuscated user id that should be associated with the created participant. + // + // You can specify a user id as follows: + // + // 1. If you set this field in + // [CreateParticipantRequest][google.cloud.dialogflow.v2.CreateParticipantRequest.participant] or + // [UpdateParticipantRequest][google.cloud.dialogflow.v2.UpdateParticipantRequest.participant], + // Dialogflow adds the obfuscated user id with the participant. + // + // 2. If you set this field in + // [AnalyzeContent][google.cloud.dialogflow.v2.AnalyzeContentRequest.obfuscated_external_user_id] or + // [StreamingAnalyzeContent][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.obfuscated_external_user_id], + // Dialogflow will update [Participant.obfuscated_external_user_id][google.cloud.dialogflow.v2.Participant.obfuscated_external_user_id]. + // + // Dialogflow returns an error if you try to add a user id for a + // non-[END_USER][google.cloud.dialogflow.v2.Participant.Role.END_USER] participant. + // + // Dialogflow uses this user id for billing and measurement purposes. For + // example, Dialogflow determines whether a user in one conversation returned + // in a later conversation. + // + // Note: + // + // * Please never pass raw user ids to Dialogflow. Always obfuscate your user + // id first. + // * Dialogflow only accepts a UTF-8 encoded string, e.g., a hex digest of a + // hash function like SHA-512. + // * The length of the user id must be <= 256 characters. + string obfuscated_external_user_id = 7 [(google.api.field_behavior) = OPTIONAL]; + // Optional. Key-value filters on the metadata of documents returned by article // suggestion. If specified, article suggestion only returns suggested // documents that match all filters in their [Document.metadata][google.cloud.dialogflow.v2.Document.metadata]. Multiple @@ -425,6 +473,171 @@ message AnalyzeContentResponse { DtmfParameters dtmf_parameters = 9; } +// The top-level message sent by the client to the +// [Participants.StreamingAnalyzeContent][google.cloud.dialogflow.v2.Participants.StreamingAnalyzeContent] method. +// +// Multiple request messages should be sent in order: +// +// 1. The first message must contain +// [participant][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.participant], +// [config][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.config] and optionally +// [query_params][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.query_params]. If you want +// to receive an audio response, it should also contain +// [reply_audio_config][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.reply_audio_config]. +// The message must not contain +// [input][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.input]. +// +// 2. If [config][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.config] in the first message +// was set to [audio_config][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.audio_config], +// all subsequent messages must contain +// [input_audio][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.input_audio] to continue +// with Speech recognition. +// However, note that: +// +// * Dialogflow will bill you for the audio so far. +// * Dialogflow discards all Speech recognition results in favor of the +// text input. +// +// 3. If [StreamingAnalyzeContentRequest.config][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.config] in the first message was set +// to [StreamingAnalyzeContentRequest.text_config][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.text_config], then the second message +// must contain only [input_text][google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.input_text]. +// Moreover, you must not send more than two messages. +// +// After you sent all input, you must half-close or abort the request stream. +message StreamingAnalyzeContentRequest { + // Required. The name of the participant this text comes from. + // Format: `projects//locations//conversations//participants/`. + string participant = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "dialogflow.googleapis.com/Participant" + } + ]; + + // The input config. + oneof config { + // Instructs the speech recognizer how to process the speech audio. + InputAudioConfig audio_config = 2; + + // The natural language text to be processed. + InputTextConfig text_config = 3; + } + + // Speech synthesis configuration. + // The speech synthesis settings for a virtual agent that may be configured + // for the associated conversation profile are not used when calling + // StreamingAnalyzeContent. If this configuration is not supplied, speech + // synthesis is disabled. + OutputAudioConfig reply_audio_config = 4; + + // The input. + oneof input { + // The input audio content to be recognized. Must be sent if `audio_config` + // is set in the first message. The complete audio over all streaming + // messages must not exceed 1 minute. + bytes input_audio = 5; + + // The UTF-8 encoded natural language text to be processed. Must be sent if + // `text_config` is set in the first message. Text length must not exceed + // 256 bytes for virtual agent interactions. The `input_text` field can be + // only sent once. + string input_text = 6; + + // The DTMF digits used to invoke intent and fill in parameter value. + // + // This input is ignored if the previous response indicated that DTMF input + // is not accepted. + TelephonyDtmfEvents input_dtmf = 9; + } + + // Parameters for a Dialogflow virtual-agent query. + QueryParameters query_params = 7; + + // Parameters for a human assist query. + AssistQueryParameters assist_query_params = 8; + + // Additional parameters to be put into Dialogflow CX session parameters. To + // remove a parameter from the session, clients should explicitly set the + // parameter value to null. + // + // Note: this field should only be used if you are connecting to a Dialogflow + // CX agent. + google.protobuf.Struct cx_parameters = 13; + + // Enable partial virtual agent responses. If this flag is not enabled, + // response stream still contains only one final response even if some + // `Fulfillment`s in Dialogflow virtual agent have been configured to return + // partial responses. + bool enable_partial_automated_agent_reply = 12; +} + +// The top-level message returned from the `StreamingAnalyzeContent` method. +// +// Multiple response messages can be returned in order: +// +// 1. If the input was set to streaming audio, the first one or more messages +// contain `recognition_result`. Each `recognition_result` represents a more +// complete transcript of what the user said. The last `recognition_result` +// has `is_final` set to `true`. +// +// 2. In virtual agent stage: if `enable_partial_automated_agent_reply` is +// true, the following N (currently 1 <= N <= 4) messages +// contain `automated_agent_reply` and optionally `reply_audio` +// returned by the virtual agent. The first (N-1) +// `automated_agent_reply`s will have `automated_agent_reply_type` set to +// `PARTIAL`. The last `automated_agent_reply` has +// `automated_agent_reply_type` set to `FINAL`. +// If `enable_partial_automated_agent_reply` is not enabled, response stream +// only contains the final reply. +// +// In human assist stage: the following N (N >= 1) messages contain +// `human_agent_suggestion_results`, `end_user_suggestion_results` or +// `message`. +message StreamingAnalyzeContentResponse { + // The result of speech recognition. + StreamingRecognitionResult recognition_result = 1; + + // The output text content. + // This field is set if an automated agent responded with a text for the user. + string reply_text = 2; + + // The audio data bytes encoded as specified in the request. + // This field is set if: + // + // - The `reply_audio_config` field is specified in the request. + // - The automated agent, which this output comes from, responded with audio. + // In such case, the `reply_audio.config` field contains settings used to + // synthesize the speech. + // + // In some scenarios, multiple output audio fields may be present in the + // response structure. In these cases, only the top-most-level audio output + // has content. + OutputAudio reply_audio = 3; + + // Only set if a Dialogflow automated agent has responded. + // Note that: [AutomatedAgentReply.detect_intent_response.output_audio][] + // and [AutomatedAgentReply.detect_intent_response.output_audio_config][] + // are always empty, use [reply_audio][google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.reply_audio] instead. + AutomatedAgentReply automated_agent_reply = 4; + + // Message analyzed by CCAI. + Message message = 6; + + // The suggestions for most recent human agent. The order is the same as + // [HumanAgentAssistantConfig.SuggestionConfig.feature_configs][google.cloud.dialogflow.v2.HumanAgentAssistantConfig.SuggestionConfig.feature_configs] of + // [HumanAgentAssistantConfig.human_agent_suggestion_config][google.cloud.dialogflow.v2.HumanAgentAssistantConfig.human_agent_suggestion_config]. + repeated SuggestionResult human_agent_suggestion_results = 7; + + // The suggestions for end user. The order is the same as + // [HumanAgentAssistantConfig.SuggestionConfig.feature_configs][google.cloud.dialogflow.v2.HumanAgentAssistantConfig.SuggestionConfig.feature_configs] of + // [HumanAgentAssistantConfig.end_user_suggestion_config][google.cloud.dialogflow.v2.HumanAgentAssistantConfig.end_user_suggestion_config]. + repeated SuggestionResult end_user_suggestion_results = 8; + + // Indicates the parameters of DTMF. + DtmfParameters dtmf_parameters = 10; +} + // The request message for [Participants.SuggestArticles][google.cloud.dialogflow.v2.Participants.SuggestArticles]. message SuggestArticlesRequest { // Required. The name of the participant to fetch suggestion for. @@ -720,6 +933,14 @@ message SuggestionResult { } } +// Defines the language used in the input text. +message InputTextConfig { + // Required. The language of this conversational query. See [Language + // Support](https://cloud.google.com/dialogflow/docs/reference/language) + // for a list of the currently supported language codes. + string language_code = 1 [(google.api.field_behavior) = REQUIRED]; +} + // Represents a part of a message possibly annotated with an entity. The part // can be an entity or purely a part of the message between two entities or // message start/end. diff --git a/protos/google/cloud/dialogflow/v2beta1/audio_config.proto b/protos/google/cloud/dialogflow/v2beta1/audio_config.proto index c72899df..b9e83b20 100644 --- a/protos/google/cloud/dialogflow/v2beta1/audio_config.proto +++ b/protos/google/cloud/dialogflow/v2beta1/audio_config.proto @@ -111,7 +111,8 @@ message SpeechContext { float boost = 2; } -// Variant of the specified [Speech model][google.cloud.dialogflow.v2beta1.InputAudioConfig.model] to use. +// Variant of the specified [Speech +// model][google.cloud.dialogflow.v2beta1.InputAudioConfig.model] to use. // // See the [Cloud Speech // documentation](https://cloud.google.com/speech-to-text/docs/enhanced-models) @@ -140,8 +141,8 @@ enum SpeechModelVariant { // Use an enhanced model variant: // // * If an enhanced variant does not exist for the given - // [model][google.cloud.dialogflow.v2beta1.InputAudioConfig.model] and request language, Dialogflow falls - // back to the standard variant. + // [model][google.cloud.dialogflow.v2beta1.InputAudioConfig.model] and + // request language, Dialogflow falls back to the standard variant. // // The [Cloud Speech // documentation](https://cloud.google.com/speech-to-text/docs/enhanced-models) @@ -198,10 +199,12 @@ message InputAudioConfig { // the same session do not necessarily need to specify the same language. string language_code = 3; - // If `true`, Dialogflow returns [SpeechWordInfo][google.cloud.dialogflow.v2beta1.SpeechWordInfo] in - // [StreamingRecognitionResult][google.cloud.dialogflow.v2beta1.StreamingRecognitionResult] with information about the recognized speech - // words, e.g. start and end time offsets. If false or unspecified, Speech - // doesn't return any word-level information. + // If `true`, Dialogflow returns + // [SpeechWordInfo][google.cloud.dialogflow.v2beta1.SpeechWordInfo] in + // [StreamingRecognitionResult][google.cloud.dialogflow.v2beta1.StreamingRecognitionResult] + // with information about the recognized speech words, e.g. start and end time + // offsets. If false or unspecified, Speech doesn't return any word-level + // information. bool enable_word_info = 13; // A list of strings containing words and phrases that the speech @@ -236,7 +239,8 @@ message InputAudioConfig { // for more details. string model = 7; - // Which variant of the [Speech model][google.cloud.dialogflow.v2beta1.InputAudioConfig.model] to use. + // Which variant of the [Speech + // model][google.cloud.dialogflow.v2beta1.InputAudioConfig.model] to use. SpeechModelVariant model_variant = 10; // If `false` (default), recognition does not cease until the @@ -251,7 +255,9 @@ message InputAudioConfig { // over StreamingDetectIntentRequest.single_utterance. bool single_utterance = 8; - // Only used in [Participants.AnalyzeContent][google.cloud.dialogflow.v2beta1.Participants.AnalyzeContent] and + // Only used in + // [Participants.AnalyzeContent][google.cloud.dialogflow.v2beta1.Participants.AnalyzeContent] + // and // [Participants.StreamingAnalyzeContent][google.cloud.dialogflow.v2beta1.Participants.StreamingAnalyzeContent]. // If `false` and recognition doesn't return any result, trigger // `NO_SPEECH_RECOGNIZED` event to Dialogflow agent. @@ -287,9 +293,10 @@ message VoiceSelectionParams { // Optional. The preferred gender of the voice. If not set, the service will // choose a voice based on the other parameters such as language_code and - // [name][google.cloud.dialogflow.v2beta1.VoiceSelectionParams.name]. Note that this is only a preference, not requirement. If a - // voice of the appropriate gender is not available, the synthesizer should - // substitute a voice with a different gender rather than failing the request. + // [name][google.cloud.dialogflow.v2beta1.VoiceSelectionParams.name]. Note + // that this is only a preference, not requirement. If a voice of the + // appropriate gender is not available, the synthesizer should substitute a + // voice with a different gender rather than failing the request. SsmlVoiceGender ssml_gender = 2; } @@ -355,7 +362,8 @@ enum OutputAudioEncoding { // text-to-speech settings applied to the agent. message OutputAudioConfig { // Required. Audio encoding of the synthesized audio content. - OutputAudioEncoding audio_encoding = 1 [(google.api.field_behavior) = REQUIRED]; + OutputAudioEncoding audio_encoding = 1 + [(google.api.field_behavior) = REQUIRED]; // The synthesis sample rate (in hertz) for this audio. If not // provided, then the synthesizer will use the default sample rate based on @@ -429,14 +437,26 @@ message TelephonyDtmfEvents { repeated TelephonyDtmf dtmf_events = 1; } -// Configures speech transcription for [ConversationProfile][google.cloud.dialogflow.v2beta1.ConversationProfile]. +// Configures speech transcription for +// [ConversationProfile][google.cloud.dialogflow.v2beta1.ConversationProfile]. message SpeechToTextConfig { // The speech model used in speech to text. // `SPEECH_MODEL_VARIANT_UNSPECIFIED`, `USE_BEST_AVAILABLE` will be treated as - // `USE_ENHANCED`. It can be overridden in [AnalyzeContentRequest][google.cloud.dialogflow.v2beta1.AnalyzeContentRequest] and - // [StreamingAnalyzeContentRequest][google.cloud.dialogflow.v2beta1.StreamingAnalyzeContentRequest] request. - // If enhanced model variant is specified and an enhanced - // version of the specified model for the language does not exist, then it - // would emit an error. + // `USE_ENHANCED`. It can be overridden in + // [AnalyzeContentRequest][google.cloud.dialogflow.v2beta1.AnalyzeContentRequest] + // and + // [StreamingAnalyzeContentRequest][google.cloud.dialogflow.v2beta1.StreamingAnalyzeContentRequest] + // request. If enhanced model variant is specified and an enhanced version of + // the specified model for the language does not exist, then it would emit an + // error. SpeechModelVariant speech_model_variant = 1; + + // Which Speech model to select. Select the model best suited to your domain + // to get best results. If a model is not explicitly specified, then a default + // model is used. + // Refer to + // [Cloud Speech API + // documentation](https://cloud.google.com/speech-to-text/docs/basics#select-model) + // for more details. + string model = 2; } diff --git a/protos/protos.d.ts b/protos/protos.d.ts index d8bcf9df..e01ea55f 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -2757,6 +2757,20 @@ export namespace google { */ public analyzeContent(request: google.cloud.dialogflow.v2.IAnalyzeContentRequest): Promise; + /** + * Calls StreamingAnalyzeContent. + * @param request StreamingAnalyzeContentRequest message or plain object + * @param callback Node-style callback called with the error, if any, and StreamingAnalyzeContentResponse + */ + public streamingAnalyzeContent(request: google.cloud.dialogflow.v2.IStreamingAnalyzeContentRequest, callback: google.cloud.dialogflow.v2.Participants.StreamingAnalyzeContentCallback): void; + + /** + * Calls StreamingAnalyzeContent. + * @param request StreamingAnalyzeContentRequest message or plain object + * @returns Promise + */ + public streamingAnalyzeContent(request: google.cloud.dialogflow.v2.IStreamingAnalyzeContentRequest): Promise; + /** * Calls SuggestArticles. * @param request SuggestArticlesRequest message or plain object @@ -2837,6 +2851,13 @@ export namespace google { */ type AnalyzeContentCallback = (error: (Error|null), response?: google.cloud.dialogflow.v2.AnalyzeContentResponse) => void; + /** + * Callback as used by {@link google.cloud.dialogflow.v2.Participants|streamingAnalyzeContent}. + * @param error Error, if any + * @param [response] StreamingAnalyzeContentResponse + */ + type StreamingAnalyzeContentCallback = (error: (Error|null), response?: google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse) => void; + /** * Callback as used by {@link google.cloud.dialogflow.v2.Participants|suggestArticles}. * @param error Error, if any @@ -2871,6 +2892,9 @@ export namespace google { /** Participant sipRecordingMediaLabel */ sipRecordingMediaLabel?: (string|null); + /** Participant obfuscatedExternalUserId */ + obfuscatedExternalUserId?: (string|null); + /** Participant documentsMetadataFilters */ documentsMetadataFilters?: ({ [k: string]: string }|null); } @@ -2893,6 +2917,9 @@ export namespace google { /** Participant sipRecordingMediaLabel. */ public sipRecordingMediaLabel: string; + /** Participant obfuscatedExternalUserId. */ + public obfuscatedExternalUserId: string; + /** Participant documentsMetadataFilters. */ public documentsMetadataFilters: { [k: string]: string }; @@ -4017,6 +4044,308 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a StreamingAnalyzeContentRequest. */ + interface IStreamingAnalyzeContentRequest { + + /** StreamingAnalyzeContentRequest participant */ + participant?: (string|null); + + /** StreamingAnalyzeContentRequest audioConfig */ + audioConfig?: (google.cloud.dialogflow.v2.IInputAudioConfig|null); + + /** StreamingAnalyzeContentRequest textConfig */ + textConfig?: (google.cloud.dialogflow.v2.IInputTextConfig|null); + + /** StreamingAnalyzeContentRequest replyAudioConfig */ + replyAudioConfig?: (google.cloud.dialogflow.v2.IOutputAudioConfig|null); + + /** StreamingAnalyzeContentRequest inputAudio */ + inputAudio?: (Uint8Array|string|null); + + /** StreamingAnalyzeContentRequest inputText */ + inputText?: (string|null); + + /** StreamingAnalyzeContentRequest inputDtmf */ + inputDtmf?: (google.cloud.dialogflow.v2.ITelephonyDtmfEvents|null); + + /** StreamingAnalyzeContentRequest queryParams */ + queryParams?: (google.cloud.dialogflow.v2.IQueryParameters|null); + + /** StreamingAnalyzeContentRequest assistQueryParams */ + assistQueryParams?: (google.cloud.dialogflow.v2.IAssistQueryParameters|null); + + /** StreamingAnalyzeContentRequest cxParameters */ + cxParameters?: (google.protobuf.IStruct|null); + + /** StreamingAnalyzeContentRequest enablePartialAutomatedAgentReply */ + enablePartialAutomatedAgentReply?: (boolean|null); + } + + /** Represents a StreamingAnalyzeContentRequest. */ + class StreamingAnalyzeContentRequest implements IStreamingAnalyzeContentRequest { + + /** + * Constructs a new StreamingAnalyzeContentRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.dialogflow.v2.IStreamingAnalyzeContentRequest); + + /** StreamingAnalyzeContentRequest participant. */ + public participant: string; + + /** StreamingAnalyzeContentRequest audioConfig. */ + public audioConfig?: (google.cloud.dialogflow.v2.IInputAudioConfig|null); + + /** StreamingAnalyzeContentRequest textConfig. */ + public textConfig?: (google.cloud.dialogflow.v2.IInputTextConfig|null); + + /** StreamingAnalyzeContentRequest replyAudioConfig. */ + public replyAudioConfig?: (google.cloud.dialogflow.v2.IOutputAudioConfig|null); + + /** StreamingAnalyzeContentRequest inputAudio. */ + public inputAudio?: (Uint8Array|string|null); + + /** StreamingAnalyzeContentRequest inputText. */ + public inputText?: (string|null); + + /** StreamingAnalyzeContentRequest inputDtmf. */ + public inputDtmf?: (google.cloud.dialogflow.v2.ITelephonyDtmfEvents|null); + + /** StreamingAnalyzeContentRequest queryParams. */ + public queryParams?: (google.cloud.dialogflow.v2.IQueryParameters|null); + + /** StreamingAnalyzeContentRequest assistQueryParams. */ + public assistQueryParams?: (google.cloud.dialogflow.v2.IAssistQueryParameters|null); + + /** StreamingAnalyzeContentRequest cxParameters. */ + public cxParameters?: (google.protobuf.IStruct|null); + + /** StreamingAnalyzeContentRequest enablePartialAutomatedAgentReply. */ + public enablePartialAutomatedAgentReply: boolean; + + /** StreamingAnalyzeContentRequest config. */ + public config?: ("audioConfig"|"textConfig"); + + /** StreamingAnalyzeContentRequest input. */ + public input?: ("inputAudio"|"inputText"|"inputDtmf"); + + /** + * Creates a new StreamingAnalyzeContentRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamingAnalyzeContentRequest instance + */ + public static create(properties?: google.cloud.dialogflow.v2.IStreamingAnalyzeContentRequest): google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest; + + /** + * Encodes the specified StreamingAnalyzeContentRequest message. Does not implicitly {@link google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.verify|verify} messages. + * @param message StreamingAnalyzeContentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.dialogflow.v2.IStreamingAnalyzeContentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamingAnalyzeContentRequest message, length delimited. Does not implicitly {@link google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.verify|verify} messages. + * @param message StreamingAnalyzeContentRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.dialogflow.v2.IStreamingAnalyzeContentRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamingAnalyzeContentRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamingAnalyzeContentRequest + * @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.dialogflow.v2.StreamingAnalyzeContentRequest; + + /** + * Decodes a StreamingAnalyzeContentRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamingAnalyzeContentRequest + * @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.dialogflow.v2.StreamingAnalyzeContentRequest; + + /** + * Verifies a StreamingAnalyzeContentRequest 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 StreamingAnalyzeContentRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamingAnalyzeContentRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest; + + /** + * Creates a plain object from a StreamingAnalyzeContentRequest message. Also converts values to other types if specified. + * @param message StreamingAnalyzeContentRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamingAnalyzeContentRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamingAnalyzeContentRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a StreamingAnalyzeContentResponse. */ + interface IStreamingAnalyzeContentResponse { + + /** StreamingAnalyzeContentResponse recognitionResult */ + recognitionResult?: (google.cloud.dialogflow.v2.IStreamingRecognitionResult|null); + + /** StreamingAnalyzeContentResponse replyText */ + replyText?: (string|null); + + /** StreamingAnalyzeContentResponse replyAudio */ + replyAudio?: (google.cloud.dialogflow.v2.IOutputAudio|null); + + /** StreamingAnalyzeContentResponse automatedAgentReply */ + automatedAgentReply?: (google.cloud.dialogflow.v2.IAutomatedAgentReply|null); + + /** StreamingAnalyzeContentResponse message */ + message?: (google.cloud.dialogflow.v2.IMessage|null); + + /** StreamingAnalyzeContentResponse humanAgentSuggestionResults */ + humanAgentSuggestionResults?: (google.cloud.dialogflow.v2.ISuggestionResult[]|null); + + /** StreamingAnalyzeContentResponse endUserSuggestionResults */ + endUserSuggestionResults?: (google.cloud.dialogflow.v2.ISuggestionResult[]|null); + + /** StreamingAnalyzeContentResponse dtmfParameters */ + dtmfParameters?: (google.cloud.dialogflow.v2.IDtmfParameters|null); + } + + /** Represents a StreamingAnalyzeContentResponse. */ + class StreamingAnalyzeContentResponse implements IStreamingAnalyzeContentResponse { + + /** + * Constructs a new StreamingAnalyzeContentResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.dialogflow.v2.IStreamingAnalyzeContentResponse); + + /** StreamingAnalyzeContentResponse recognitionResult. */ + public recognitionResult?: (google.cloud.dialogflow.v2.IStreamingRecognitionResult|null); + + /** StreamingAnalyzeContentResponse replyText. */ + public replyText: string; + + /** StreamingAnalyzeContentResponse replyAudio. */ + public replyAudio?: (google.cloud.dialogflow.v2.IOutputAudio|null); + + /** StreamingAnalyzeContentResponse automatedAgentReply. */ + public automatedAgentReply?: (google.cloud.dialogflow.v2.IAutomatedAgentReply|null); + + /** StreamingAnalyzeContentResponse message. */ + public message?: (google.cloud.dialogflow.v2.IMessage|null); + + /** StreamingAnalyzeContentResponse humanAgentSuggestionResults. */ + public humanAgentSuggestionResults: google.cloud.dialogflow.v2.ISuggestionResult[]; + + /** StreamingAnalyzeContentResponse endUserSuggestionResults. */ + public endUserSuggestionResults: google.cloud.dialogflow.v2.ISuggestionResult[]; + + /** StreamingAnalyzeContentResponse dtmfParameters. */ + public dtmfParameters?: (google.cloud.dialogflow.v2.IDtmfParameters|null); + + /** + * Creates a new StreamingAnalyzeContentResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns StreamingAnalyzeContentResponse instance + */ + public static create(properties?: google.cloud.dialogflow.v2.IStreamingAnalyzeContentResponse): google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse; + + /** + * Encodes the specified StreamingAnalyzeContentResponse message. Does not implicitly {@link google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.verify|verify} messages. + * @param message StreamingAnalyzeContentResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.dialogflow.v2.IStreamingAnalyzeContentResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StreamingAnalyzeContentResponse message, length delimited. Does not implicitly {@link google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.verify|verify} messages. + * @param message StreamingAnalyzeContentResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.dialogflow.v2.IStreamingAnalyzeContentResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StreamingAnalyzeContentResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StreamingAnalyzeContentResponse + * @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.dialogflow.v2.StreamingAnalyzeContentResponse; + + /** + * Decodes a StreamingAnalyzeContentResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StreamingAnalyzeContentResponse + * @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.dialogflow.v2.StreamingAnalyzeContentResponse; + + /** + * Verifies a StreamingAnalyzeContentResponse 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 StreamingAnalyzeContentResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StreamingAnalyzeContentResponse + */ + public static fromObject(object: { [k: string]: any }): google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse; + + /** + * Creates a plain object from a StreamingAnalyzeContentResponse message. Also converts values to other types if specified. + * @param message StreamingAnalyzeContentResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StreamingAnalyzeContentResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StreamingAnalyzeContentResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a SuggestArticlesRequest. */ interface ISuggestArticlesRequest { @@ -5392,6 +5721,103 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of an InputTextConfig. */ + interface IInputTextConfig { + + /** InputTextConfig languageCode */ + languageCode?: (string|null); + } + + /** Represents an InputTextConfig. */ + class InputTextConfig implements IInputTextConfig { + + /** + * Constructs a new InputTextConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.dialogflow.v2.IInputTextConfig); + + /** InputTextConfig languageCode. */ + public languageCode: string; + + /** + * Creates a new InputTextConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns InputTextConfig instance + */ + public static create(properties?: google.cloud.dialogflow.v2.IInputTextConfig): google.cloud.dialogflow.v2.InputTextConfig; + + /** + * Encodes the specified InputTextConfig message. Does not implicitly {@link google.cloud.dialogflow.v2.InputTextConfig.verify|verify} messages. + * @param message InputTextConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.dialogflow.v2.IInputTextConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified InputTextConfig message, length delimited. Does not implicitly {@link google.cloud.dialogflow.v2.InputTextConfig.verify|verify} messages. + * @param message InputTextConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.dialogflow.v2.IInputTextConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an InputTextConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns InputTextConfig + * @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.dialogflow.v2.InputTextConfig; + + /** + * Decodes an InputTextConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns InputTextConfig + * @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.dialogflow.v2.InputTextConfig; + + /** + * Verifies an InputTextConfig message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an InputTextConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns InputTextConfig + */ + public static fromObject(object: { [k: string]: any }): google.cloud.dialogflow.v2.InputTextConfig; + + /** + * Creates a plain object from an InputTextConfig message. Also converts values to other types if specified. + * @param message InputTextConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.dialogflow.v2.InputTextConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this InputTextConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for InputTextConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of an AnnotatedMessagePart. */ interface IAnnotatedMessagePart { @@ -6441,11 +6867,132 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** TelephonyDtmf enum. */ + enum TelephonyDtmf { + TELEPHONY_DTMF_UNSPECIFIED = 0, + DTMF_ONE = 1, + DTMF_TWO = 2, + DTMF_THREE = 3, + DTMF_FOUR = 4, + DTMF_FIVE = 5, + DTMF_SIX = 6, + DTMF_SEVEN = 7, + DTMF_EIGHT = 8, + DTMF_NINE = 9, + DTMF_ZERO = 10, + DTMF_A = 11, + DTMF_B = 12, + DTMF_C = 13, + DTMF_D = 14, + DTMF_STAR = 15, + DTMF_POUND = 16 + } + + /** Properties of a TelephonyDtmfEvents. */ + interface ITelephonyDtmfEvents { + + /** TelephonyDtmfEvents dtmfEvents */ + dtmfEvents?: (google.cloud.dialogflow.v2.TelephonyDtmf[]|null); + } + + /** Represents a TelephonyDtmfEvents. */ + class TelephonyDtmfEvents implements ITelephonyDtmfEvents { + + /** + * Constructs a new TelephonyDtmfEvents. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.dialogflow.v2.ITelephonyDtmfEvents); + + /** TelephonyDtmfEvents dtmfEvents. */ + public dtmfEvents: google.cloud.dialogflow.v2.TelephonyDtmf[]; + + /** + * Creates a new TelephonyDtmfEvents instance using the specified properties. + * @param [properties] Properties to set + * @returns TelephonyDtmfEvents instance + */ + public static create(properties?: google.cloud.dialogflow.v2.ITelephonyDtmfEvents): google.cloud.dialogflow.v2.TelephonyDtmfEvents; + + /** + * Encodes the specified TelephonyDtmfEvents message. Does not implicitly {@link google.cloud.dialogflow.v2.TelephonyDtmfEvents.verify|verify} messages. + * @param message TelephonyDtmfEvents message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.dialogflow.v2.ITelephonyDtmfEvents, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TelephonyDtmfEvents message, length delimited. Does not implicitly {@link google.cloud.dialogflow.v2.TelephonyDtmfEvents.verify|verify} messages. + * @param message TelephonyDtmfEvents message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.dialogflow.v2.ITelephonyDtmfEvents, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TelephonyDtmfEvents message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TelephonyDtmfEvents + * @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.dialogflow.v2.TelephonyDtmfEvents; + + /** + * Decodes a TelephonyDtmfEvents message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TelephonyDtmfEvents + * @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.dialogflow.v2.TelephonyDtmfEvents; + + /** + * Verifies a TelephonyDtmfEvents 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 TelephonyDtmfEvents message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TelephonyDtmfEvents + */ + public static fromObject(object: { [k: string]: any }): google.cloud.dialogflow.v2.TelephonyDtmfEvents; + + /** + * Creates a plain object from a TelephonyDtmfEvents message. Also converts values to other types if specified. + * @param message TelephonyDtmfEvents + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.dialogflow.v2.TelephonyDtmfEvents, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TelephonyDtmfEvents to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TelephonyDtmfEvents + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a SpeechToTextConfig. */ interface ISpeechToTextConfig { /** SpeechToTextConfig speechModelVariant */ speechModelVariant?: (google.cloud.dialogflow.v2.SpeechModelVariant|keyof typeof google.cloud.dialogflow.v2.SpeechModelVariant|null); + + /** SpeechToTextConfig model */ + model?: (string|null); } /** Represents a SpeechToTextConfig. */ @@ -6460,6 +7007,9 @@ export namespace google { /** SpeechToTextConfig speechModelVariant. */ public speechModelVariant: (google.cloud.dialogflow.v2.SpeechModelVariant|keyof typeof google.cloud.dialogflow.v2.SpeechModelVariant); + /** SpeechToTextConfig model. */ + public model: string; + /** * Creates a new SpeechToTextConfig instance using the specified properties. * @param [properties] Properties to set @@ -41544,6 +42094,9 @@ export namespace google { /** SpeechToTextConfig speechModelVariant */ speechModelVariant?: (google.cloud.dialogflow.v2beta1.SpeechModelVariant|keyof typeof google.cloud.dialogflow.v2beta1.SpeechModelVariant|null); + + /** SpeechToTextConfig model */ + model?: (string|null); } /** Represents a SpeechToTextConfig. */ @@ -41558,6 +42111,9 @@ export namespace google { /** SpeechToTextConfig speechModelVariant. */ public speechModelVariant: (google.cloud.dialogflow.v2beta1.SpeechModelVariant|keyof typeof google.cloud.dialogflow.v2beta1.SpeechModelVariant); + /** SpeechToTextConfig model. */ + public model: string; + /** * Creates a new SpeechToTextConfig instance using the specified properties. * @param [properties] Properties to set diff --git a/protos/protos.js b/protos/protos.js index aee34af8..3bfb1ff4 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -6525,6 +6525,39 @@ * @variation 2 */ + /** + * Callback as used by {@link google.cloud.dialogflow.v2.Participants|streamingAnalyzeContent}. + * @memberof google.cloud.dialogflow.v2.Participants + * @typedef StreamingAnalyzeContentCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse} [response] StreamingAnalyzeContentResponse + */ + + /** + * Calls StreamingAnalyzeContent. + * @function streamingAnalyzeContent + * @memberof google.cloud.dialogflow.v2.Participants + * @instance + * @param {google.cloud.dialogflow.v2.IStreamingAnalyzeContentRequest} request StreamingAnalyzeContentRequest message or plain object + * @param {google.cloud.dialogflow.v2.Participants.StreamingAnalyzeContentCallback} callback Node-style callback called with the error, if any, and StreamingAnalyzeContentResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Participants.prototype.streamingAnalyzeContent = function streamingAnalyzeContent(request, callback) { + return this.rpcCall(streamingAnalyzeContent, $root.google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest, $root.google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse, request, callback); + }, "name", { value: "StreamingAnalyzeContent" }); + + /** + * Calls StreamingAnalyzeContent. + * @function streamingAnalyzeContent + * @memberof google.cloud.dialogflow.v2.Participants + * @instance + * @param {google.cloud.dialogflow.v2.IStreamingAnalyzeContentRequest} request StreamingAnalyzeContentRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.cloud.dialogflow.v2.Participants|suggestArticles}. * @memberof google.cloud.dialogflow.v2.Participants @@ -6636,6 +6669,7 @@ * @property {string|null} [name] Participant name * @property {google.cloud.dialogflow.v2.Participant.Role|null} [role] Participant role * @property {string|null} [sipRecordingMediaLabel] Participant sipRecordingMediaLabel + * @property {string|null} [obfuscatedExternalUserId] Participant obfuscatedExternalUserId * @property {Object.|null} [documentsMetadataFilters] Participant documentsMetadataFilters */ @@ -6679,6 +6713,14 @@ */ Participant.prototype.sipRecordingMediaLabel = ""; + /** + * Participant obfuscatedExternalUserId. + * @member {string} obfuscatedExternalUserId + * @memberof google.cloud.dialogflow.v2.Participant + * @instance + */ + Participant.prototype.obfuscatedExternalUserId = ""; + /** * Participant documentsMetadataFilters. * @member {Object.} documentsMetadataFilters @@ -6717,6 +6759,8 @@ writer.uint32(/* id 2, wireType 0 =*/16).int32(message.role); if (message.sipRecordingMediaLabel != null && Object.hasOwnProperty.call(message, "sipRecordingMediaLabel")) writer.uint32(/* id 6, wireType 2 =*/50).string(message.sipRecordingMediaLabel); + if (message.obfuscatedExternalUserId != null && Object.hasOwnProperty.call(message, "obfuscatedExternalUserId")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.obfuscatedExternalUserId); if (message.documentsMetadataFilters != null && Object.hasOwnProperty.call(message, "documentsMetadataFilters")) for (var keys = Object.keys(message.documentsMetadataFilters), i = 0; i < keys.length; ++i) writer.uint32(/* id 8, wireType 2 =*/66).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.documentsMetadataFilters[keys[i]]).ldelim(); @@ -6766,6 +6810,10 @@ message.sipRecordingMediaLabel = reader.string(); break; } + case 7: { + message.obfuscatedExternalUserId = reader.string(); + break; + } case 8: { if (message.documentsMetadataFilters === $util.emptyObject) message.documentsMetadataFilters = {}; @@ -6840,6 +6888,9 @@ if (message.sipRecordingMediaLabel != null && message.hasOwnProperty("sipRecordingMediaLabel")) if (!$util.isString(message.sipRecordingMediaLabel)) return "sipRecordingMediaLabel: string expected"; + if (message.obfuscatedExternalUserId != null && message.hasOwnProperty("obfuscatedExternalUserId")) + if (!$util.isString(message.obfuscatedExternalUserId)) + return "obfuscatedExternalUserId: string expected"; if (message.documentsMetadataFilters != null && message.hasOwnProperty("documentsMetadataFilters")) { if (!$util.isObject(message.documentsMetadataFilters)) return "documentsMetadataFilters: object expected"; @@ -6891,6 +6942,8 @@ } if (object.sipRecordingMediaLabel != null) message.sipRecordingMediaLabel = String(object.sipRecordingMediaLabel); + if (object.obfuscatedExternalUserId != null) + message.obfuscatedExternalUserId = String(object.obfuscatedExternalUserId); if (object.documentsMetadataFilters) { if (typeof object.documentsMetadataFilters !== "object") throw TypeError(".google.cloud.dialogflow.v2.Participant.documentsMetadataFilters: object expected"); @@ -6920,6 +6973,7 @@ object.name = ""; object.role = options.enums === String ? "ROLE_UNSPECIFIED" : 0; object.sipRecordingMediaLabel = ""; + object.obfuscatedExternalUserId = ""; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -6927,6 +6981,8 @@ object.role = options.enums === String ? $root.google.cloud.dialogflow.v2.Participant.Role[message.role] === undefined ? message.role : $root.google.cloud.dialogflow.v2.Participant.Role[message.role] : message.role; if (message.sipRecordingMediaLabel != null && message.hasOwnProperty("sipRecordingMediaLabel")) object.sipRecordingMediaLabel = message.sipRecordingMediaLabel; + if (message.obfuscatedExternalUserId != null && message.hasOwnProperty("obfuscatedExternalUserId")) + object.obfuscatedExternalUserId = message.obfuscatedExternalUserId; var keys2; if (message.documentsMetadataFilters && (keys2 = Object.keys(message.documentsMetadataFilters)).length) { object.documentsMetadataFilters = {}; @@ -9113,132 +9169,1066 @@ break; } } - return message; - }; - - /** - * Decodes a DtmfParameters message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.cloud.dialogflow.v2.DtmfParameters - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.cloud.dialogflow.v2.DtmfParameters} DtmfParameters - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DtmfParameters.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a DtmfParameters message. - * @function verify - * @memberof google.cloud.dialogflow.v2.DtmfParameters - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - DtmfParameters.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.acceptsDtmfInput != null && message.hasOwnProperty("acceptsDtmfInput")) - if (typeof message.acceptsDtmfInput !== "boolean") - return "acceptsDtmfInput: boolean expected"; + return message; + }; + + /** + * Decodes a DtmfParameters message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.dialogflow.v2.DtmfParameters + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.dialogflow.v2.DtmfParameters} DtmfParameters + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DtmfParameters.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DtmfParameters message. + * @function verify + * @memberof google.cloud.dialogflow.v2.DtmfParameters + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DtmfParameters.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.acceptsDtmfInput != null && message.hasOwnProperty("acceptsDtmfInput")) + if (typeof message.acceptsDtmfInput !== "boolean") + return "acceptsDtmfInput: boolean expected"; + return null; + }; + + /** + * Creates a DtmfParameters message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.dialogflow.v2.DtmfParameters + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.dialogflow.v2.DtmfParameters} DtmfParameters + */ + DtmfParameters.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.dialogflow.v2.DtmfParameters) + return object; + var message = new $root.google.cloud.dialogflow.v2.DtmfParameters(); + if (object.acceptsDtmfInput != null) + message.acceptsDtmfInput = Boolean(object.acceptsDtmfInput); + return message; + }; + + /** + * Creates a plain object from a DtmfParameters message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.dialogflow.v2.DtmfParameters + * @static + * @param {google.cloud.dialogflow.v2.DtmfParameters} message DtmfParameters + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DtmfParameters.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.acceptsDtmfInput = false; + if (message.acceptsDtmfInput != null && message.hasOwnProperty("acceptsDtmfInput")) + object.acceptsDtmfInput = message.acceptsDtmfInput; + return object; + }; + + /** + * Converts this DtmfParameters to JSON. + * @function toJSON + * @memberof google.cloud.dialogflow.v2.DtmfParameters + * @instance + * @returns {Object.} JSON object + */ + DtmfParameters.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DtmfParameters + * @function getTypeUrl + * @memberof google.cloud.dialogflow.v2.DtmfParameters + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DtmfParameters.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.dialogflow.v2.DtmfParameters"; + }; + + return DtmfParameters; + })(); + + v2.AnalyzeContentResponse = (function() { + + /** + * Properties of an AnalyzeContentResponse. + * @memberof google.cloud.dialogflow.v2 + * @interface IAnalyzeContentResponse + * @property {string|null} [replyText] AnalyzeContentResponse replyText + * @property {google.cloud.dialogflow.v2.IOutputAudio|null} [replyAudio] AnalyzeContentResponse replyAudio + * @property {google.cloud.dialogflow.v2.IAutomatedAgentReply|null} [automatedAgentReply] AnalyzeContentResponse automatedAgentReply + * @property {google.cloud.dialogflow.v2.IMessage|null} [message] AnalyzeContentResponse message + * @property {Array.|null} [humanAgentSuggestionResults] AnalyzeContentResponse humanAgentSuggestionResults + * @property {Array.|null} [endUserSuggestionResults] AnalyzeContentResponse endUserSuggestionResults + * @property {google.cloud.dialogflow.v2.IDtmfParameters|null} [dtmfParameters] AnalyzeContentResponse dtmfParameters + */ + + /** + * Constructs a new AnalyzeContentResponse. + * @memberof google.cloud.dialogflow.v2 + * @classdesc Represents an AnalyzeContentResponse. + * @implements IAnalyzeContentResponse + * @constructor + * @param {google.cloud.dialogflow.v2.IAnalyzeContentResponse=} [properties] Properties to set + */ + function AnalyzeContentResponse(properties) { + this.humanAgentSuggestionResults = []; + this.endUserSuggestionResults = []; + 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]]; + } + + /** + * AnalyzeContentResponse replyText. + * @member {string} replyText + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @instance + */ + AnalyzeContentResponse.prototype.replyText = ""; + + /** + * AnalyzeContentResponse replyAudio. + * @member {google.cloud.dialogflow.v2.IOutputAudio|null|undefined} replyAudio + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @instance + */ + AnalyzeContentResponse.prototype.replyAudio = null; + + /** + * AnalyzeContentResponse automatedAgentReply. + * @member {google.cloud.dialogflow.v2.IAutomatedAgentReply|null|undefined} automatedAgentReply + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @instance + */ + AnalyzeContentResponse.prototype.automatedAgentReply = null; + + /** + * AnalyzeContentResponse message. + * @member {google.cloud.dialogflow.v2.IMessage|null|undefined} message + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @instance + */ + AnalyzeContentResponse.prototype.message = null; + + /** + * AnalyzeContentResponse humanAgentSuggestionResults. + * @member {Array.} humanAgentSuggestionResults + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @instance + */ + AnalyzeContentResponse.prototype.humanAgentSuggestionResults = $util.emptyArray; + + /** + * AnalyzeContentResponse endUserSuggestionResults. + * @member {Array.} endUserSuggestionResults + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @instance + */ + AnalyzeContentResponse.prototype.endUserSuggestionResults = $util.emptyArray; + + /** + * AnalyzeContentResponse dtmfParameters. + * @member {google.cloud.dialogflow.v2.IDtmfParameters|null|undefined} dtmfParameters + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @instance + */ + AnalyzeContentResponse.prototype.dtmfParameters = null; + + /** + * Creates a new AnalyzeContentResponse instance using the specified properties. + * @function create + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @static + * @param {google.cloud.dialogflow.v2.IAnalyzeContentResponse=} [properties] Properties to set + * @returns {google.cloud.dialogflow.v2.AnalyzeContentResponse} AnalyzeContentResponse instance + */ + AnalyzeContentResponse.create = function create(properties) { + return new AnalyzeContentResponse(properties); + }; + + /** + * Encodes the specified AnalyzeContentResponse message. Does not implicitly {@link google.cloud.dialogflow.v2.AnalyzeContentResponse.verify|verify} messages. + * @function encode + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @static + * @param {google.cloud.dialogflow.v2.IAnalyzeContentResponse} message AnalyzeContentResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AnalyzeContentResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.replyText != null && Object.hasOwnProperty.call(message, "replyText")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.replyText); + if (message.replyAudio != null && Object.hasOwnProperty.call(message, "replyAudio")) + $root.google.cloud.dialogflow.v2.OutputAudio.encode(message.replyAudio, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.automatedAgentReply != null && Object.hasOwnProperty.call(message, "automatedAgentReply")) + $root.google.cloud.dialogflow.v2.AutomatedAgentReply.encode(message.automatedAgentReply, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.message != null && Object.hasOwnProperty.call(message, "message")) + $root.google.cloud.dialogflow.v2.Message.encode(message.message, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.humanAgentSuggestionResults != null && message.humanAgentSuggestionResults.length) + for (var i = 0; i < message.humanAgentSuggestionResults.length; ++i) + $root.google.cloud.dialogflow.v2.SuggestionResult.encode(message.humanAgentSuggestionResults[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.endUserSuggestionResults != null && message.endUserSuggestionResults.length) + for (var i = 0; i < message.endUserSuggestionResults.length; ++i) + $root.google.cloud.dialogflow.v2.SuggestionResult.encode(message.endUserSuggestionResults[i], writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.dtmfParameters != null && Object.hasOwnProperty.call(message, "dtmfParameters")) + $root.google.cloud.dialogflow.v2.DtmfParameters.encode(message.dtmfParameters, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified AnalyzeContentResponse message, length delimited. Does not implicitly {@link google.cloud.dialogflow.v2.AnalyzeContentResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @static + * @param {google.cloud.dialogflow.v2.IAnalyzeContentResponse} message AnalyzeContentResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AnalyzeContentResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AnalyzeContentResponse message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.dialogflow.v2.AnalyzeContentResponse} AnalyzeContentResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AnalyzeContentResponse.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.dialogflow.v2.AnalyzeContentResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.replyText = reader.string(); + break; + } + case 2: { + message.replyAudio = $root.google.cloud.dialogflow.v2.OutputAudio.decode(reader, reader.uint32()); + break; + } + case 3: { + message.automatedAgentReply = $root.google.cloud.dialogflow.v2.AutomatedAgentReply.decode(reader, reader.uint32()); + break; + } + case 5: { + message.message = $root.google.cloud.dialogflow.v2.Message.decode(reader, reader.uint32()); + break; + } + case 6: { + if (!(message.humanAgentSuggestionResults && message.humanAgentSuggestionResults.length)) + message.humanAgentSuggestionResults = []; + message.humanAgentSuggestionResults.push($root.google.cloud.dialogflow.v2.SuggestionResult.decode(reader, reader.uint32())); + break; + } + case 7: { + if (!(message.endUserSuggestionResults && message.endUserSuggestionResults.length)) + message.endUserSuggestionResults = []; + message.endUserSuggestionResults.push($root.google.cloud.dialogflow.v2.SuggestionResult.decode(reader, reader.uint32())); + break; + } + case 9: { + message.dtmfParameters = $root.google.cloud.dialogflow.v2.DtmfParameters.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AnalyzeContentResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.dialogflow.v2.AnalyzeContentResponse} AnalyzeContentResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AnalyzeContentResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AnalyzeContentResponse message. + * @function verify + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AnalyzeContentResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.replyText != null && message.hasOwnProperty("replyText")) + if (!$util.isString(message.replyText)) + return "replyText: string expected"; + if (message.replyAudio != null && message.hasOwnProperty("replyAudio")) { + var error = $root.google.cloud.dialogflow.v2.OutputAudio.verify(message.replyAudio); + if (error) + return "replyAudio." + error; + } + if (message.automatedAgentReply != null && message.hasOwnProperty("automatedAgentReply")) { + var error = $root.google.cloud.dialogflow.v2.AutomatedAgentReply.verify(message.automatedAgentReply); + if (error) + return "automatedAgentReply." + error; + } + if (message.message != null && message.hasOwnProperty("message")) { + var error = $root.google.cloud.dialogflow.v2.Message.verify(message.message); + if (error) + return "message." + error; + } + if (message.humanAgentSuggestionResults != null && message.hasOwnProperty("humanAgentSuggestionResults")) { + if (!Array.isArray(message.humanAgentSuggestionResults)) + return "humanAgentSuggestionResults: array expected"; + for (var i = 0; i < message.humanAgentSuggestionResults.length; ++i) { + var error = $root.google.cloud.dialogflow.v2.SuggestionResult.verify(message.humanAgentSuggestionResults[i]); + if (error) + return "humanAgentSuggestionResults." + error; + } + } + if (message.endUserSuggestionResults != null && message.hasOwnProperty("endUserSuggestionResults")) { + if (!Array.isArray(message.endUserSuggestionResults)) + return "endUserSuggestionResults: array expected"; + for (var i = 0; i < message.endUserSuggestionResults.length; ++i) { + var error = $root.google.cloud.dialogflow.v2.SuggestionResult.verify(message.endUserSuggestionResults[i]); + if (error) + return "endUserSuggestionResults." + error; + } + } + if (message.dtmfParameters != null && message.hasOwnProperty("dtmfParameters")) { + var error = $root.google.cloud.dialogflow.v2.DtmfParameters.verify(message.dtmfParameters); + if (error) + return "dtmfParameters." + error; + } + return null; + }; + + /** + * Creates an AnalyzeContentResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.dialogflow.v2.AnalyzeContentResponse} AnalyzeContentResponse + */ + AnalyzeContentResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.dialogflow.v2.AnalyzeContentResponse) + return object; + var message = new $root.google.cloud.dialogflow.v2.AnalyzeContentResponse(); + if (object.replyText != null) + message.replyText = String(object.replyText); + if (object.replyAudio != null) { + if (typeof object.replyAudio !== "object") + throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.replyAudio: object expected"); + message.replyAudio = $root.google.cloud.dialogflow.v2.OutputAudio.fromObject(object.replyAudio); + } + if (object.automatedAgentReply != null) { + if (typeof object.automatedAgentReply !== "object") + throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.automatedAgentReply: object expected"); + message.automatedAgentReply = $root.google.cloud.dialogflow.v2.AutomatedAgentReply.fromObject(object.automatedAgentReply); + } + if (object.message != null) { + if (typeof object.message !== "object") + throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.message: object expected"); + message.message = $root.google.cloud.dialogflow.v2.Message.fromObject(object.message); + } + if (object.humanAgentSuggestionResults) { + if (!Array.isArray(object.humanAgentSuggestionResults)) + throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.humanAgentSuggestionResults: array expected"); + message.humanAgentSuggestionResults = []; + for (var i = 0; i < object.humanAgentSuggestionResults.length; ++i) { + if (typeof object.humanAgentSuggestionResults[i] !== "object") + throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.humanAgentSuggestionResults: object expected"); + message.humanAgentSuggestionResults[i] = $root.google.cloud.dialogflow.v2.SuggestionResult.fromObject(object.humanAgentSuggestionResults[i]); + } + } + if (object.endUserSuggestionResults) { + if (!Array.isArray(object.endUserSuggestionResults)) + throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.endUserSuggestionResults: array expected"); + message.endUserSuggestionResults = []; + for (var i = 0; i < object.endUserSuggestionResults.length; ++i) { + if (typeof object.endUserSuggestionResults[i] !== "object") + throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.endUserSuggestionResults: object expected"); + message.endUserSuggestionResults[i] = $root.google.cloud.dialogflow.v2.SuggestionResult.fromObject(object.endUserSuggestionResults[i]); + } + } + if (object.dtmfParameters != null) { + if (typeof object.dtmfParameters !== "object") + throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.dtmfParameters: object expected"); + message.dtmfParameters = $root.google.cloud.dialogflow.v2.DtmfParameters.fromObject(object.dtmfParameters); + } + return message; + }; + + /** + * Creates a plain object from an AnalyzeContentResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @static + * @param {google.cloud.dialogflow.v2.AnalyzeContentResponse} message AnalyzeContentResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AnalyzeContentResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.humanAgentSuggestionResults = []; + object.endUserSuggestionResults = []; + } + if (options.defaults) { + object.replyText = ""; + object.replyAudio = null; + object.automatedAgentReply = null; + object.message = null; + object.dtmfParameters = null; + } + if (message.replyText != null && message.hasOwnProperty("replyText")) + object.replyText = message.replyText; + if (message.replyAudio != null && message.hasOwnProperty("replyAudio")) + object.replyAudio = $root.google.cloud.dialogflow.v2.OutputAudio.toObject(message.replyAudio, options); + if (message.automatedAgentReply != null && message.hasOwnProperty("automatedAgentReply")) + object.automatedAgentReply = $root.google.cloud.dialogflow.v2.AutomatedAgentReply.toObject(message.automatedAgentReply, options); + if (message.message != null && message.hasOwnProperty("message")) + object.message = $root.google.cloud.dialogflow.v2.Message.toObject(message.message, options); + if (message.humanAgentSuggestionResults && message.humanAgentSuggestionResults.length) { + object.humanAgentSuggestionResults = []; + for (var j = 0; j < message.humanAgentSuggestionResults.length; ++j) + object.humanAgentSuggestionResults[j] = $root.google.cloud.dialogflow.v2.SuggestionResult.toObject(message.humanAgentSuggestionResults[j], options); + } + if (message.endUserSuggestionResults && message.endUserSuggestionResults.length) { + object.endUserSuggestionResults = []; + for (var j = 0; j < message.endUserSuggestionResults.length; ++j) + object.endUserSuggestionResults[j] = $root.google.cloud.dialogflow.v2.SuggestionResult.toObject(message.endUserSuggestionResults[j], options); + } + if (message.dtmfParameters != null && message.hasOwnProperty("dtmfParameters")) + object.dtmfParameters = $root.google.cloud.dialogflow.v2.DtmfParameters.toObject(message.dtmfParameters, options); + return object; + }; + + /** + * Converts this AnalyzeContentResponse to JSON. + * @function toJSON + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @instance + * @returns {Object.} JSON object + */ + AnalyzeContentResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AnalyzeContentResponse + * @function getTypeUrl + * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AnalyzeContentResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.dialogflow.v2.AnalyzeContentResponse"; + }; + + return AnalyzeContentResponse; + })(); + + v2.StreamingAnalyzeContentRequest = (function() { + + /** + * Properties of a StreamingAnalyzeContentRequest. + * @memberof google.cloud.dialogflow.v2 + * @interface IStreamingAnalyzeContentRequest + * @property {string|null} [participant] StreamingAnalyzeContentRequest participant + * @property {google.cloud.dialogflow.v2.IInputAudioConfig|null} [audioConfig] StreamingAnalyzeContentRequest audioConfig + * @property {google.cloud.dialogflow.v2.IInputTextConfig|null} [textConfig] StreamingAnalyzeContentRequest textConfig + * @property {google.cloud.dialogflow.v2.IOutputAudioConfig|null} [replyAudioConfig] StreamingAnalyzeContentRequest replyAudioConfig + * @property {Uint8Array|null} [inputAudio] StreamingAnalyzeContentRequest inputAudio + * @property {string|null} [inputText] StreamingAnalyzeContentRequest inputText + * @property {google.cloud.dialogflow.v2.ITelephonyDtmfEvents|null} [inputDtmf] StreamingAnalyzeContentRequest inputDtmf + * @property {google.cloud.dialogflow.v2.IQueryParameters|null} [queryParams] StreamingAnalyzeContentRequest queryParams + * @property {google.cloud.dialogflow.v2.IAssistQueryParameters|null} [assistQueryParams] StreamingAnalyzeContentRequest assistQueryParams + * @property {google.protobuf.IStruct|null} [cxParameters] StreamingAnalyzeContentRequest cxParameters + * @property {boolean|null} [enablePartialAutomatedAgentReply] StreamingAnalyzeContentRequest enablePartialAutomatedAgentReply + */ + + /** + * Constructs a new StreamingAnalyzeContentRequest. + * @memberof google.cloud.dialogflow.v2 + * @classdesc Represents a StreamingAnalyzeContentRequest. + * @implements IStreamingAnalyzeContentRequest + * @constructor + * @param {google.cloud.dialogflow.v2.IStreamingAnalyzeContentRequest=} [properties] Properties to set + */ + function StreamingAnalyzeContentRequest(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]]; + } + + /** + * StreamingAnalyzeContentRequest participant. + * @member {string} participant + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @instance + */ + StreamingAnalyzeContentRequest.prototype.participant = ""; + + /** + * StreamingAnalyzeContentRequest audioConfig. + * @member {google.cloud.dialogflow.v2.IInputAudioConfig|null|undefined} audioConfig + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @instance + */ + StreamingAnalyzeContentRequest.prototype.audioConfig = null; + + /** + * StreamingAnalyzeContentRequest textConfig. + * @member {google.cloud.dialogflow.v2.IInputTextConfig|null|undefined} textConfig + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @instance + */ + StreamingAnalyzeContentRequest.prototype.textConfig = null; + + /** + * StreamingAnalyzeContentRequest replyAudioConfig. + * @member {google.cloud.dialogflow.v2.IOutputAudioConfig|null|undefined} replyAudioConfig + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @instance + */ + StreamingAnalyzeContentRequest.prototype.replyAudioConfig = null; + + /** + * StreamingAnalyzeContentRequest inputAudio. + * @member {Uint8Array|null|undefined} inputAudio + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @instance + */ + StreamingAnalyzeContentRequest.prototype.inputAudio = null; + + /** + * StreamingAnalyzeContentRequest inputText. + * @member {string|null|undefined} inputText + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @instance + */ + StreamingAnalyzeContentRequest.prototype.inputText = null; + + /** + * StreamingAnalyzeContentRequest inputDtmf. + * @member {google.cloud.dialogflow.v2.ITelephonyDtmfEvents|null|undefined} inputDtmf + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @instance + */ + StreamingAnalyzeContentRequest.prototype.inputDtmf = null; + + /** + * StreamingAnalyzeContentRequest queryParams. + * @member {google.cloud.dialogflow.v2.IQueryParameters|null|undefined} queryParams + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @instance + */ + StreamingAnalyzeContentRequest.prototype.queryParams = null; + + /** + * StreamingAnalyzeContentRequest assistQueryParams. + * @member {google.cloud.dialogflow.v2.IAssistQueryParameters|null|undefined} assistQueryParams + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @instance + */ + StreamingAnalyzeContentRequest.prototype.assistQueryParams = null; + + /** + * StreamingAnalyzeContentRequest cxParameters. + * @member {google.protobuf.IStruct|null|undefined} cxParameters + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @instance + */ + StreamingAnalyzeContentRequest.prototype.cxParameters = null; + + /** + * StreamingAnalyzeContentRequest enablePartialAutomatedAgentReply. + * @member {boolean} enablePartialAutomatedAgentReply + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @instance + */ + StreamingAnalyzeContentRequest.prototype.enablePartialAutomatedAgentReply = false; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * StreamingAnalyzeContentRequest config. + * @member {"audioConfig"|"textConfig"|undefined} config + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @instance + */ + Object.defineProperty(StreamingAnalyzeContentRequest.prototype, "config", { + get: $util.oneOfGetter($oneOfFields = ["audioConfig", "textConfig"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * StreamingAnalyzeContentRequest input. + * @member {"inputAudio"|"inputText"|"inputDtmf"|undefined} input + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @instance + */ + Object.defineProperty(StreamingAnalyzeContentRequest.prototype, "input", { + get: $util.oneOfGetter($oneOfFields = ["inputAudio", "inputText", "inputDtmf"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new StreamingAnalyzeContentRequest instance using the specified properties. + * @function create + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @static + * @param {google.cloud.dialogflow.v2.IStreamingAnalyzeContentRequest=} [properties] Properties to set + * @returns {google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest} StreamingAnalyzeContentRequest instance + */ + StreamingAnalyzeContentRequest.create = function create(properties) { + return new StreamingAnalyzeContentRequest(properties); + }; + + /** + * Encodes the specified StreamingAnalyzeContentRequest message. Does not implicitly {@link google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @static + * @param {google.cloud.dialogflow.v2.IStreamingAnalyzeContentRequest} message StreamingAnalyzeContentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamingAnalyzeContentRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.participant != null && Object.hasOwnProperty.call(message, "participant")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.participant); + if (message.audioConfig != null && Object.hasOwnProperty.call(message, "audioConfig")) + $root.google.cloud.dialogflow.v2.InputAudioConfig.encode(message.audioConfig, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.textConfig != null && Object.hasOwnProperty.call(message, "textConfig")) + $root.google.cloud.dialogflow.v2.InputTextConfig.encode(message.textConfig, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.replyAudioConfig != null && Object.hasOwnProperty.call(message, "replyAudioConfig")) + $root.google.cloud.dialogflow.v2.OutputAudioConfig.encode(message.replyAudioConfig, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.inputAudio != null && Object.hasOwnProperty.call(message, "inputAudio")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.inputAudio); + if (message.inputText != null && Object.hasOwnProperty.call(message, "inputText")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.inputText); + if (message.queryParams != null && Object.hasOwnProperty.call(message, "queryParams")) + $root.google.cloud.dialogflow.v2.QueryParameters.encode(message.queryParams, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.assistQueryParams != null && Object.hasOwnProperty.call(message, "assistQueryParams")) + $root.google.cloud.dialogflow.v2.AssistQueryParameters.encode(message.assistQueryParams, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.inputDtmf != null && Object.hasOwnProperty.call(message, "inputDtmf")) + $root.google.cloud.dialogflow.v2.TelephonyDtmfEvents.encode(message.inputDtmf, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.enablePartialAutomatedAgentReply != null && Object.hasOwnProperty.call(message, "enablePartialAutomatedAgentReply")) + writer.uint32(/* id 12, wireType 0 =*/96).bool(message.enablePartialAutomatedAgentReply); + if (message.cxParameters != null && Object.hasOwnProperty.call(message, "cxParameters")) + $root.google.protobuf.Struct.encode(message.cxParameters, writer.uint32(/* id 13, wireType 2 =*/106).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified StreamingAnalyzeContentRequest message, length delimited. Does not implicitly {@link google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @static + * @param {google.cloud.dialogflow.v2.IStreamingAnalyzeContentRequest} message StreamingAnalyzeContentRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StreamingAnalyzeContentRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StreamingAnalyzeContentRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest} StreamingAnalyzeContentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamingAnalyzeContentRequest.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.dialogflow.v2.StreamingAnalyzeContentRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.participant = reader.string(); + break; + } + case 2: { + message.audioConfig = $root.google.cloud.dialogflow.v2.InputAudioConfig.decode(reader, reader.uint32()); + break; + } + case 3: { + message.textConfig = $root.google.cloud.dialogflow.v2.InputTextConfig.decode(reader, reader.uint32()); + break; + } + case 4: { + message.replyAudioConfig = $root.google.cloud.dialogflow.v2.OutputAudioConfig.decode(reader, reader.uint32()); + break; + } + case 5: { + message.inputAudio = reader.bytes(); + break; + } + case 6: { + message.inputText = reader.string(); + break; + } + case 9: { + message.inputDtmf = $root.google.cloud.dialogflow.v2.TelephonyDtmfEvents.decode(reader, reader.uint32()); + break; + } + case 7: { + message.queryParams = $root.google.cloud.dialogflow.v2.QueryParameters.decode(reader, reader.uint32()); + break; + } + case 8: { + message.assistQueryParams = $root.google.cloud.dialogflow.v2.AssistQueryParameters.decode(reader, reader.uint32()); + break; + } + case 13: { + message.cxParameters = $root.google.protobuf.Struct.decode(reader, reader.uint32()); + break; + } + case 12: { + message.enablePartialAutomatedAgentReply = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StreamingAnalyzeContentRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest} StreamingAnalyzeContentRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StreamingAnalyzeContentRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StreamingAnalyzeContentRequest message. + * @function verify + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StreamingAnalyzeContentRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.participant != null && message.hasOwnProperty("participant")) + if (!$util.isString(message.participant)) + return "participant: string expected"; + if (message.audioConfig != null && message.hasOwnProperty("audioConfig")) { + properties.config = 1; + { + var error = $root.google.cloud.dialogflow.v2.InputAudioConfig.verify(message.audioConfig); + if (error) + return "audioConfig." + error; + } + } + if (message.textConfig != null && message.hasOwnProperty("textConfig")) { + if (properties.config === 1) + return "config: multiple values"; + properties.config = 1; + { + var error = $root.google.cloud.dialogflow.v2.InputTextConfig.verify(message.textConfig); + if (error) + return "textConfig." + error; + } + } + if (message.replyAudioConfig != null && message.hasOwnProperty("replyAudioConfig")) { + var error = $root.google.cloud.dialogflow.v2.OutputAudioConfig.verify(message.replyAudioConfig); + if (error) + return "replyAudioConfig." + error; + } + if (message.inputAudio != null && message.hasOwnProperty("inputAudio")) { + properties.input = 1; + if (!(message.inputAudio && typeof message.inputAudio.length === "number" || $util.isString(message.inputAudio))) + return "inputAudio: buffer expected"; + } + if (message.inputText != null && message.hasOwnProperty("inputText")) { + if (properties.input === 1) + return "input: multiple values"; + properties.input = 1; + if (!$util.isString(message.inputText)) + return "inputText: string expected"; + } + if (message.inputDtmf != null && message.hasOwnProperty("inputDtmf")) { + if (properties.input === 1) + return "input: multiple values"; + properties.input = 1; + { + var error = $root.google.cloud.dialogflow.v2.TelephonyDtmfEvents.verify(message.inputDtmf); + if (error) + return "inputDtmf." + error; + } + } + if (message.queryParams != null && message.hasOwnProperty("queryParams")) { + var error = $root.google.cloud.dialogflow.v2.QueryParameters.verify(message.queryParams); + if (error) + return "queryParams." + error; + } + if (message.assistQueryParams != null && message.hasOwnProperty("assistQueryParams")) { + var error = $root.google.cloud.dialogflow.v2.AssistQueryParameters.verify(message.assistQueryParams); + if (error) + return "assistQueryParams." + error; + } + if (message.cxParameters != null && message.hasOwnProperty("cxParameters")) { + var error = $root.google.protobuf.Struct.verify(message.cxParameters); + if (error) + return "cxParameters." + error; + } + if (message.enablePartialAutomatedAgentReply != null && message.hasOwnProperty("enablePartialAutomatedAgentReply")) + if (typeof message.enablePartialAutomatedAgentReply !== "boolean") + return "enablePartialAutomatedAgentReply: boolean expected"; return null; }; /** - * Creates a DtmfParameters message from a plain object. Also converts values to their respective internal types. + * Creates a StreamingAnalyzeContentRequest message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.cloud.dialogflow.v2.DtmfParameters + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest * @static * @param {Object.} object Plain object - * @returns {google.cloud.dialogflow.v2.DtmfParameters} DtmfParameters + * @returns {google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest} StreamingAnalyzeContentRequest */ - DtmfParameters.fromObject = function fromObject(object) { - if (object instanceof $root.google.cloud.dialogflow.v2.DtmfParameters) + StreamingAnalyzeContentRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest) return object; - var message = new $root.google.cloud.dialogflow.v2.DtmfParameters(); - if (object.acceptsDtmfInput != null) - message.acceptsDtmfInput = Boolean(object.acceptsDtmfInput); + var message = new $root.google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest(); + if (object.participant != null) + message.participant = String(object.participant); + if (object.audioConfig != null) { + if (typeof object.audioConfig !== "object") + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.audioConfig: object expected"); + message.audioConfig = $root.google.cloud.dialogflow.v2.InputAudioConfig.fromObject(object.audioConfig); + } + if (object.textConfig != null) { + if (typeof object.textConfig !== "object") + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.textConfig: object expected"); + message.textConfig = $root.google.cloud.dialogflow.v2.InputTextConfig.fromObject(object.textConfig); + } + if (object.replyAudioConfig != null) { + if (typeof object.replyAudioConfig !== "object") + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.replyAudioConfig: object expected"); + message.replyAudioConfig = $root.google.cloud.dialogflow.v2.OutputAudioConfig.fromObject(object.replyAudioConfig); + } + if (object.inputAudio != null) + if (typeof object.inputAudio === "string") + $util.base64.decode(object.inputAudio, message.inputAudio = $util.newBuffer($util.base64.length(object.inputAudio)), 0); + else if (object.inputAudio.length >= 0) + message.inputAudio = object.inputAudio; + if (object.inputText != null) + message.inputText = String(object.inputText); + if (object.inputDtmf != null) { + if (typeof object.inputDtmf !== "object") + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.inputDtmf: object expected"); + message.inputDtmf = $root.google.cloud.dialogflow.v2.TelephonyDtmfEvents.fromObject(object.inputDtmf); + } + if (object.queryParams != null) { + if (typeof object.queryParams !== "object") + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.queryParams: object expected"); + message.queryParams = $root.google.cloud.dialogflow.v2.QueryParameters.fromObject(object.queryParams); + } + if (object.assistQueryParams != null) { + if (typeof object.assistQueryParams !== "object") + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.assistQueryParams: object expected"); + message.assistQueryParams = $root.google.cloud.dialogflow.v2.AssistQueryParameters.fromObject(object.assistQueryParams); + } + if (object.cxParameters != null) { + if (typeof object.cxParameters !== "object") + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest.cxParameters: object expected"); + message.cxParameters = $root.google.protobuf.Struct.fromObject(object.cxParameters); + } + if (object.enablePartialAutomatedAgentReply != null) + message.enablePartialAutomatedAgentReply = Boolean(object.enablePartialAutomatedAgentReply); return message; }; /** - * Creates a plain object from a DtmfParameters message. Also converts values to other types if specified. + * Creates a plain object from a StreamingAnalyzeContentRequest message. Also converts values to other types if specified. * @function toObject - * @memberof google.cloud.dialogflow.v2.DtmfParameters + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest * @static - * @param {google.cloud.dialogflow.v2.DtmfParameters} message DtmfParameters + * @param {google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest} message StreamingAnalyzeContentRequest * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - DtmfParameters.toObject = function toObject(message, options) { + StreamingAnalyzeContentRequest.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; - if (options.defaults) - object.acceptsDtmfInput = false; - if (message.acceptsDtmfInput != null && message.hasOwnProperty("acceptsDtmfInput")) - object.acceptsDtmfInput = message.acceptsDtmfInput; + if (options.defaults) { + object.participant = ""; + object.replyAudioConfig = null; + object.queryParams = null; + object.assistQueryParams = null; + object.enablePartialAutomatedAgentReply = false; + object.cxParameters = null; + } + if (message.participant != null && message.hasOwnProperty("participant")) + object.participant = message.participant; + if (message.audioConfig != null && message.hasOwnProperty("audioConfig")) { + object.audioConfig = $root.google.cloud.dialogflow.v2.InputAudioConfig.toObject(message.audioConfig, options); + if (options.oneofs) + object.config = "audioConfig"; + } + if (message.textConfig != null && message.hasOwnProperty("textConfig")) { + object.textConfig = $root.google.cloud.dialogflow.v2.InputTextConfig.toObject(message.textConfig, options); + if (options.oneofs) + object.config = "textConfig"; + } + if (message.replyAudioConfig != null && message.hasOwnProperty("replyAudioConfig")) + object.replyAudioConfig = $root.google.cloud.dialogflow.v2.OutputAudioConfig.toObject(message.replyAudioConfig, options); + if (message.inputAudio != null && message.hasOwnProperty("inputAudio")) { + object.inputAudio = options.bytes === String ? $util.base64.encode(message.inputAudio, 0, message.inputAudio.length) : options.bytes === Array ? Array.prototype.slice.call(message.inputAudio) : message.inputAudio; + if (options.oneofs) + object.input = "inputAudio"; + } + if (message.inputText != null && message.hasOwnProperty("inputText")) { + object.inputText = message.inputText; + if (options.oneofs) + object.input = "inputText"; + } + if (message.queryParams != null && message.hasOwnProperty("queryParams")) + object.queryParams = $root.google.cloud.dialogflow.v2.QueryParameters.toObject(message.queryParams, options); + if (message.assistQueryParams != null && message.hasOwnProperty("assistQueryParams")) + object.assistQueryParams = $root.google.cloud.dialogflow.v2.AssistQueryParameters.toObject(message.assistQueryParams, options); + if (message.inputDtmf != null && message.hasOwnProperty("inputDtmf")) { + object.inputDtmf = $root.google.cloud.dialogflow.v2.TelephonyDtmfEvents.toObject(message.inputDtmf, options); + if (options.oneofs) + object.input = "inputDtmf"; + } + if (message.enablePartialAutomatedAgentReply != null && message.hasOwnProperty("enablePartialAutomatedAgentReply")) + object.enablePartialAutomatedAgentReply = message.enablePartialAutomatedAgentReply; + if (message.cxParameters != null && message.hasOwnProperty("cxParameters")) + object.cxParameters = $root.google.protobuf.Struct.toObject(message.cxParameters, options); return object; }; /** - * Converts this DtmfParameters to JSON. + * Converts this StreamingAnalyzeContentRequest to JSON. * @function toJSON - * @memberof google.cloud.dialogflow.v2.DtmfParameters + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest * @instance * @returns {Object.} JSON object */ - DtmfParameters.prototype.toJSON = function toJSON() { + StreamingAnalyzeContentRequest.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for DtmfParameters + * Gets the default type url for StreamingAnalyzeContentRequest * @function getTypeUrl - * @memberof google.cloud.dialogflow.v2.DtmfParameters + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - DtmfParameters.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + StreamingAnalyzeContentRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.cloud.dialogflow.v2.DtmfParameters"; + return typeUrlPrefix + "/google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest"; }; - return DtmfParameters; + return StreamingAnalyzeContentRequest; })(); - v2.AnalyzeContentResponse = (function() { + v2.StreamingAnalyzeContentResponse = (function() { /** - * Properties of an AnalyzeContentResponse. + * Properties of a StreamingAnalyzeContentResponse. * @memberof google.cloud.dialogflow.v2 - * @interface IAnalyzeContentResponse - * @property {string|null} [replyText] AnalyzeContentResponse replyText - * @property {google.cloud.dialogflow.v2.IOutputAudio|null} [replyAudio] AnalyzeContentResponse replyAudio - * @property {google.cloud.dialogflow.v2.IAutomatedAgentReply|null} [automatedAgentReply] AnalyzeContentResponse automatedAgentReply - * @property {google.cloud.dialogflow.v2.IMessage|null} [message] AnalyzeContentResponse message - * @property {Array.|null} [humanAgentSuggestionResults] AnalyzeContentResponse humanAgentSuggestionResults - * @property {Array.|null} [endUserSuggestionResults] AnalyzeContentResponse endUserSuggestionResults - * @property {google.cloud.dialogflow.v2.IDtmfParameters|null} [dtmfParameters] AnalyzeContentResponse dtmfParameters + * @interface IStreamingAnalyzeContentResponse + * @property {google.cloud.dialogflow.v2.IStreamingRecognitionResult|null} [recognitionResult] StreamingAnalyzeContentResponse recognitionResult + * @property {string|null} [replyText] StreamingAnalyzeContentResponse replyText + * @property {google.cloud.dialogflow.v2.IOutputAudio|null} [replyAudio] StreamingAnalyzeContentResponse replyAudio + * @property {google.cloud.dialogflow.v2.IAutomatedAgentReply|null} [automatedAgentReply] StreamingAnalyzeContentResponse automatedAgentReply + * @property {google.cloud.dialogflow.v2.IMessage|null} [message] StreamingAnalyzeContentResponse message + * @property {Array.|null} [humanAgentSuggestionResults] StreamingAnalyzeContentResponse humanAgentSuggestionResults + * @property {Array.|null} [endUserSuggestionResults] StreamingAnalyzeContentResponse endUserSuggestionResults + * @property {google.cloud.dialogflow.v2.IDtmfParameters|null} [dtmfParameters] StreamingAnalyzeContentResponse dtmfParameters */ /** - * Constructs a new AnalyzeContentResponse. + * Constructs a new StreamingAnalyzeContentResponse. * @memberof google.cloud.dialogflow.v2 - * @classdesc Represents an AnalyzeContentResponse. - * @implements IAnalyzeContentResponse + * @classdesc Represents a StreamingAnalyzeContentResponse. + * @implements IStreamingAnalyzeContentResponse * @constructor - * @param {google.cloud.dialogflow.v2.IAnalyzeContentResponse=} [properties] Properties to set + * @param {google.cloud.dialogflow.v2.IStreamingAnalyzeContentResponse=} [properties] Properties to set */ - function AnalyzeContentResponse(properties) { + function StreamingAnalyzeContentResponse(properties) { this.humanAgentSuggestionResults = []; this.endUserSuggestionResults = []; if (properties) @@ -9248,164 +10238,178 @@ } /** - * AnalyzeContentResponse replyText. + * StreamingAnalyzeContentResponse recognitionResult. + * @member {google.cloud.dialogflow.v2.IStreamingRecognitionResult|null|undefined} recognitionResult + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse + * @instance + */ + StreamingAnalyzeContentResponse.prototype.recognitionResult = null; + + /** + * StreamingAnalyzeContentResponse replyText. * @member {string} replyText - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @instance */ - AnalyzeContentResponse.prototype.replyText = ""; + StreamingAnalyzeContentResponse.prototype.replyText = ""; /** - * AnalyzeContentResponse replyAudio. + * StreamingAnalyzeContentResponse replyAudio. * @member {google.cloud.dialogflow.v2.IOutputAudio|null|undefined} replyAudio - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @instance */ - AnalyzeContentResponse.prototype.replyAudio = null; + StreamingAnalyzeContentResponse.prototype.replyAudio = null; /** - * AnalyzeContentResponse automatedAgentReply. + * StreamingAnalyzeContentResponse automatedAgentReply. * @member {google.cloud.dialogflow.v2.IAutomatedAgentReply|null|undefined} automatedAgentReply - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @instance */ - AnalyzeContentResponse.prototype.automatedAgentReply = null; + StreamingAnalyzeContentResponse.prototype.automatedAgentReply = null; /** - * AnalyzeContentResponse message. + * StreamingAnalyzeContentResponse message. * @member {google.cloud.dialogflow.v2.IMessage|null|undefined} message - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @instance */ - AnalyzeContentResponse.prototype.message = null; + StreamingAnalyzeContentResponse.prototype.message = null; /** - * AnalyzeContentResponse humanAgentSuggestionResults. + * StreamingAnalyzeContentResponse humanAgentSuggestionResults. * @member {Array.} humanAgentSuggestionResults - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @instance */ - AnalyzeContentResponse.prototype.humanAgentSuggestionResults = $util.emptyArray; + StreamingAnalyzeContentResponse.prototype.humanAgentSuggestionResults = $util.emptyArray; /** - * AnalyzeContentResponse endUserSuggestionResults. + * StreamingAnalyzeContentResponse endUserSuggestionResults. * @member {Array.} endUserSuggestionResults - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @instance */ - AnalyzeContentResponse.prototype.endUserSuggestionResults = $util.emptyArray; + StreamingAnalyzeContentResponse.prototype.endUserSuggestionResults = $util.emptyArray; /** - * AnalyzeContentResponse dtmfParameters. + * StreamingAnalyzeContentResponse dtmfParameters. * @member {google.cloud.dialogflow.v2.IDtmfParameters|null|undefined} dtmfParameters - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @instance */ - AnalyzeContentResponse.prototype.dtmfParameters = null; + StreamingAnalyzeContentResponse.prototype.dtmfParameters = null; /** - * Creates a new AnalyzeContentResponse instance using the specified properties. + * Creates a new StreamingAnalyzeContentResponse instance using the specified properties. * @function create - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @static - * @param {google.cloud.dialogflow.v2.IAnalyzeContentResponse=} [properties] Properties to set - * @returns {google.cloud.dialogflow.v2.AnalyzeContentResponse} AnalyzeContentResponse instance + * @param {google.cloud.dialogflow.v2.IStreamingAnalyzeContentResponse=} [properties] Properties to set + * @returns {google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse} StreamingAnalyzeContentResponse instance */ - AnalyzeContentResponse.create = function create(properties) { - return new AnalyzeContentResponse(properties); + StreamingAnalyzeContentResponse.create = function create(properties) { + return new StreamingAnalyzeContentResponse(properties); }; /** - * Encodes the specified AnalyzeContentResponse message. Does not implicitly {@link google.cloud.dialogflow.v2.AnalyzeContentResponse.verify|verify} messages. + * Encodes the specified StreamingAnalyzeContentResponse message. Does not implicitly {@link google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.verify|verify} messages. * @function encode - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @static - * @param {google.cloud.dialogflow.v2.IAnalyzeContentResponse} message AnalyzeContentResponse message or plain object to encode + * @param {google.cloud.dialogflow.v2.IStreamingAnalyzeContentResponse} message StreamingAnalyzeContentResponse message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - AnalyzeContentResponse.encode = function encode(message, writer) { + StreamingAnalyzeContentResponse.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); + if (message.recognitionResult != null && Object.hasOwnProperty.call(message, "recognitionResult")) + $root.google.cloud.dialogflow.v2.StreamingRecognitionResult.encode(message.recognitionResult, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); if (message.replyText != null && Object.hasOwnProperty.call(message, "replyText")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.replyText); + writer.uint32(/* id 2, wireType 2 =*/18).string(message.replyText); if (message.replyAudio != null && Object.hasOwnProperty.call(message, "replyAudio")) - $root.google.cloud.dialogflow.v2.OutputAudio.encode(message.replyAudio, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + $root.google.cloud.dialogflow.v2.OutputAudio.encode(message.replyAudio, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); if (message.automatedAgentReply != null && Object.hasOwnProperty.call(message, "automatedAgentReply")) - $root.google.cloud.dialogflow.v2.AutomatedAgentReply.encode(message.automatedAgentReply, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + $root.google.cloud.dialogflow.v2.AutomatedAgentReply.encode(message.automatedAgentReply, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.message != null && Object.hasOwnProperty.call(message, "message")) - $root.google.cloud.dialogflow.v2.Message.encode(message.message, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + $root.google.cloud.dialogflow.v2.Message.encode(message.message, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); if (message.humanAgentSuggestionResults != null && message.humanAgentSuggestionResults.length) for (var i = 0; i < message.humanAgentSuggestionResults.length; ++i) - $root.google.cloud.dialogflow.v2.SuggestionResult.encode(message.humanAgentSuggestionResults[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + $root.google.cloud.dialogflow.v2.SuggestionResult.encode(message.humanAgentSuggestionResults[i], writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); if (message.endUserSuggestionResults != null && message.endUserSuggestionResults.length) for (var i = 0; i < message.endUserSuggestionResults.length; ++i) - $root.google.cloud.dialogflow.v2.SuggestionResult.encode(message.endUserSuggestionResults[i], writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + $root.google.cloud.dialogflow.v2.SuggestionResult.encode(message.endUserSuggestionResults[i], writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); if (message.dtmfParameters != null && Object.hasOwnProperty.call(message, "dtmfParameters")) - $root.google.cloud.dialogflow.v2.DtmfParameters.encode(message.dtmfParameters, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + $root.google.cloud.dialogflow.v2.DtmfParameters.encode(message.dtmfParameters, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); return writer; }; /** - * Encodes the specified AnalyzeContentResponse message, length delimited. Does not implicitly {@link google.cloud.dialogflow.v2.AnalyzeContentResponse.verify|verify} messages. + * Encodes the specified StreamingAnalyzeContentResponse message, length delimited. Does not implicitly {@link google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.verify|verify} messages. * @function encodeDelimited - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @static - * @param {google.cloud.dialogflow.v2.IAnalyzeContentResponse} message AnalyzeContentResponse message or plain object to encode + * @param {google.cloud.dialogflow.v2.IStreamingAnalyzeContentResponse} message StreamingAnalyzeContentResponse message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - AnalyzeContentResponse.encodeDelimited = function encodeDelimited(message, writer) { + StreamingAnalyzeContentResponse.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes an AnalyzeContentResponse message from the specified reader or buffer. + * Decodes a StreamingAnalyzeContentResponse message from the specified reader or buffer. * @function decode - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {google.cloud.dialogflow.v2.AnalyzeContentResponse} AnalyzeContentResponse + * @returns {google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse} StreamingAnalyzeContentResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - AnalyzeContentResponse.decode = function decode(reader, length) { + StreamingAnalyzeContentResponse.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.dialogflow.v2.AnalyzeContentResponse(); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse(); while (reader.pos < end) { var tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.replyText = reader.string(); + message.recognitionResult = $root.google.cloud.dialogflow.v2.StreamingRecognitionResult.decode(reader, reader.uint32()); break; } case 2: { - message.replyAudio = $root.google.cloud.dialogflow.v2.OutputAudio.decode(reader, reader.uint32()); + message.replyText = reader.string(); break; } case 3: { + message.replyAudio = $root.google.cloud.dialogflow.v2.OutputAudio.decode(reader, reader.uint32()); + break; + } + case 4: { message.automatedAgentReply = $root.google.cloud.dialogflow.v2.AutomatedAgentReply.decode(reader, reader.uint32()); break; } - case 5: { + case 6: { message.message = $root.google.cloud.dialogflow.v2.Message.decode(reader, reader.uint32()); break; } - case 6: { + case 7: { if (!(message.humanAgentSuggestionResults && message.humanAgentSuggestionResults.length)) message.humanAgentSuggestionResults = []; message.humanAgentSuggestionResults.push($root.google.cloud.dialogflow.v2.SuggestionResult.decode(reader, reader.uint32())); break; } - case 7: { + case 8: { if (!(message.endUserSuggestionResults && message.endUserSuggestionResults.length)) message.endUserSuggestionResults = []; message.endUserSuggestionResults.push($root.google.cloud.dialogflow.v2.SuggestionResult.decode(reader, reader.uint32())); break; } - case 9: { + case 10: { message.dtmfParameters = $root.google.cloud.dialogflow.v2.DtmfParameters.decode(reader, reader.uint32()); break; } @@ -9418,32 +10422,37 @@ }; /** - * Decodes an AnalyzeContentResponse message from the specified reader or buffer, length delimited. + * Decodes a StreamingAnalyzeContentResponse message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.cloud.dialogflow.v2.AnalyzeContentResponse} AnalyzeContentResponse + * @returns {google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse} StreamingAnalyzeContentResponse * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - AnalyzeContentResponse.decodeDelimited = function decodeDelimited(reader) { + StreamingAnalyzeContentResponse.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies an AnalyzeContentResponse message. + * Verifies a StreamingAnalyzeContentResponse message. * @function verify - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - AnalyzeContentResponse.verify = function verify(message) { + StreamingAnalyzeContentResponse.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; + if (message.recognitionResult != null && message.hasOwnProperty("recognitionResult")) { + var error = $root.google.cloud.dialogflow.v2.StreamingRecognitionResult.verify(message.recognitionResult); + if (error) + return "recognitionResult." + error; + } if (message.replyText != null && message.hasOwnProperty("replyText")) if (!$util.isString(message.replyText)) return "replyText: string expected"; @@ -9489,72 +10498,77 @@ }; /** - * Creates an AnalyzeContentResponse message from a plain object. Also converts values to their respective internal types. + * Creates a StreamingAnalyzeContentResponse message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @static * @param {Object.} object Plain object - * @returns {google.cloud.dialogflow.v2.AnalyzeContentResponse} AnalyzeContentResponse + * @returns {google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse} StreamingAnalyzeContentResponse */ - AnalyzeContentResponse.fromObject = function fromObject(object) { - if (object instanceof $root.google.cloud.dialogflow.v2.AnalyzeContentResponse) + StreamingAnalyzeContentResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse) return object; - var message = new $root.google.cloud.dialogflow.v2.AnalyzeContentResponse(); + var message = new $root.google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse(); + if (object.recognitionResult != null) { + if (typeof object.recognitionResult !== "object") + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.recognitionResult: object expected"); + message.recognitionResult = $root.google.cloud.dialogflow.v2.StreamingRecognitionResult.fromObject(object.recognitionResult); + } if (object.replyText != null) message.replyText = String(object.replyText); if (object.replyAudio != null) { if (typeof object.replyAudio !== "object") - throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.replyAudio: object expected"); + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.replyAudio: object expected"); message.replyAudio = $root.google.cloud.dialogflow.v2.OutputAudio.fromObject(object.replyAudio); } if (object.automatedAgentReply != null) { if (typeof object.automatedAgentReply !== "object") - throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.automatedAgentReply: object expected"); + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.automatedAgentReply: object expected"); message.automatedAgentReply = $root.google.cloud.dialogflow.v2.AutomatedAgentReply.fromObject(object.automatedAgentReply); } if (object.message != null) { if (typeof object.message !== "object") - throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.message: object expected"); + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.message: object expected"); message.message = $root.google.cloud.dialogflow.v2.Message.fromObject(object.message); } if (object.humanAgentSuggestionResults) { if (!Array.isArray(object.humanAgentSuggestionResults)) - throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.humanAgentSuggestionResults: array expected"); + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.humanAgentSuggestionResults: array expected"); message.humanAgentSuggestionResults = []; for (var i = 0; i < object.humanAgentSuggestionResults.length; ++i) { if (typeof object.humanAgentSuggestionResults[i] !== "object") - throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.humanAgentSuggestionResults: object expected"); + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.humanAgentSuggestionResults: object expected"); message.humanAgentSuggestionResults[i] = $root.google.cloud.dialogflow.v2.SuggestionResult.fromObject(object.humanAgentSuggestionResults[i]); } } if (object.endUserSuggestionResults) { if (!Array.isArray(object.endUserSuggestionResults)) - throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.endUserSuggestionResults: array expected"); + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.endUserSuggestionResults: array expected"); message.endUserSuggestionResults = []; for (var i = 0; i < object.endUserSuggestionResults.length; ++i) { if (typeof object.endUserSuggestionResults[i] !== "object") - throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.endUserSuggestionResults: object expected"); + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.endUserSuggestionResults: object expected"); message.endUserSuggestionResults[i] = $root.google.cloud.dialogflow.v2.SuggestionResult.fromObject(object.endUserSuggestionResults[i]); } } if (object.dtmfParameters != null) { if (typeof object.dtmfParameters !== "object") - throw TypeError(".google.cloud.dialogflow.v2.AnalyzeContentResponse.dtmfParameters: object expected"); + throw TypeError(".google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse.dtmfParameters: object expected"); message.dtmfParameters = $root.google.cloud.dialogflow.v2.DtmfParameters.fromObject(object.dtmfParameters); } return message; }; /** - * Creates a plain object from an AnalyzeContentResponse message. Also converts values to other types if specified. + * Creates a plain object from a StreamingAnalyzeContentResponse message. Also converts values to other types if specified. * @function toObject - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @static - * @param {google.cloud.dialogflow.v2.AnalyzeContentResponse} message AnalyzeContentResponse + * @param {google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse} message StreamingAnalyzeContentResponse * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - AnalyzeContentResponse.toObject = function toObject(message, options) { + StreamingAnalyzeContentResponse.toObject = function toObject(message, options) { if (!options) options = {}; var object = {}; @@ -9563,12 +10577,15 @@ object.endUserSuggestionResults = []; } if (options.defaults) { + object.recognitionResult = null; object.replyText = ""; object.replyAudio = null; object.automatedAgentReply = null; object.message = null; object.dtmfParameters = null; } + if (message.recognitionResult != null && message.hasOwnProperty("recognitionResult")) + object.recognitionResult = $root.google.cloud.dialogflow.v2.StreamingRecognitionResult.toObject(message.recognitionResult, options); if (message.replyText != null && message.hasOwnProperty("replyText")) object.replyText = message.replyText; if (message.replyAudio != null && message.hasOwnProperty("replyAudio")) @@ -9593,32 +10610,32 @@ }; /** - * Converts this AnalyzeContentResponse to JSON. + * Converts this StreamingAnalyzeContentResponse to JSON. * @function toJSON - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @instance * @returns {Object.} JSON object */ - AnalyzeContentResponse.prototype.toJSON = function toJSON() { + StreamingAnalyzeContentResponse.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for AnalyzeContentResponse + * Gets the default type url for StreamingAnalyzeContentResponse * @function getTypeUrl - * @memberof google.cloud.dialogflow.v2.AnalyzeContentResponse + * @memberof google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - AnalyzeContentResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + StreamingAnalyzeContentResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/google.cloud.dialogflow.v2.AnalyzeContentResponse"; + return typeUrlPrefix + "/google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse"; }; - return AnalyzeContentResponse; + return StreamingAnalyzeContentResponse; })(); v2.SuggestArticlesRequest = (function() { @@ -13116,6 +14133,209 @@ return SuggestionResult; })(); + v2.InputTextConfig = (function() { + + /** + * Properties of an InputTextConfig. + * @memberof google.cloud.dialogflow.v2 + * @interface IInputTextConfig + * @property {string|null} [languageCode] InputTextConfig languageCode + */ + + /** + * Constructs a new InputTextConfig. + * @memberof google.cloud.dialogflow.v2 + * @classdesc Represents an InputTextConfig. + * @implements IInputTextConfig + * @constructor + * @param {google.cloud.dialogflow.v2.IInputTextConfig=} [properties] Properties to set + */ + function InputTextConfig(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]]; + } + + /** + * InputTextConfig languageCode. + * @member {string} languageCode + * @memberof google.cloud.dialogflow.v2.InputTextConfig + * @instance + */ + InputTextConfig.prototype.languageCode = ""; + + /** + * Creates a new InputTextConfig instance using the specified properties. + * @function create + * @memberof google.cloud.dialogflow.v2.InputTextConfig + * @static + * @param {google.cloud.dialogflow.v2.IInputTextConfig=} [properties] Properties to set + * @returns {google.cloud.dialogflow.v2.InputTextConfig} InputTextConfig instance + */ + InputTextConfig.create = function create(properties) { + return new InputTextConfig(properties); + }; + + /** + * Encodes the specified InputTextConfig message. Does not implicitly {@link google.cloud.dialogflow.v2.InputTextConfig.verify|verify} messages. + * @function encode + * @memberof google.cloud.dialogflow.v2.InputTextConfig + * @static + * @param {google.cloud.dialogflow.v2.IInputTextConfig} message InputTextConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + InputTextConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.languageCode != null && Object.hasOwnProperty.call(message, "languageCode")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.languageCode); + return writer; + }; + + /** + * Encodes the specified InputTextConfig message, length delimited. Does not implicitly {@link google.cloud.dialogflow.v2.InputTextConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.dialogflow.v2.InputTextConfig + * @static + * @param {google.cloud.dialogflow.v2.IInputTextConfig} message InputTextConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + InputTextConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an InputTextConfig message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.dialogflow.v2.InputTextConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.dialogflow.v2.InputTextConfig} InputTextConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + InputTextConfig.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.dialogflow.v2.InputTextConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.languageCode = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an InputTextConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.dialogflow.v2.InputTextConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.dialogflow.v2.InputTextConfig} InputTextConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + InputTextConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an InputTextConfig message. + * @function verify + * @memberof google.cloud.dialogflow.v2.InputTextConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + InputTextConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + if (!$util.isString(message.languageCode)) + return "languageCode: string expected"; + return null; + }; + + /** + * Creates an InputTextConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.dialogflow.v2.InputTextConfig + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.dialogflow.v2.InputTextConfig} InputTextConfig + */ + InputTextConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.dialogflow.v2.InputTextConfig) + return object; + var message = new $root.google.cloud.dialogflow.v2.InputTextConfig(); + if (object.languageCode != null) + message.languageCode = String(object.languageCode); + return message; + }; + + /** + * Creates a plain object from an InputTextConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.dialogflow.v2.InputTextConfig + * @static + * @param {google.cloud.dialogflow.v2.InputTextConfig} message InputTextConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + InputTextConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.languageCode = ""; + if (message.languageCode != null && message.hasOwnProperty("languageCode")) + object.languageCode = message.languageCode; + return object; + }; + + /** + * Converts this InputTextConfig to JSON. + * @function toJSON + * @memberof google.cloud.dialogflow.v2.InputTextConfig + * @instance + * @returns {Object.} JSON object + */ + InputTextConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for InputTextConfig + * @function getTypeUrl + * @memberof google.cloud.dialogflow.v2.InputTextConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + InputTextConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.dialogflow.v2.InputTextConfig"; + }; + + return InputTextConfig; + })(); + v2.AnnotatedMessagePart = (function() { /** @@ -15863,6 +17083,371 @@ return OutputAudioConfig; })(); + /** + * TelephonyDtmf enum. + * @name google.cloud.dialogflow.v2.TelephonyDtmf + * @enum {number} + * @property {number} TELEPHONY_DTMF_UNSPECIFIED=0 TELEPHONY_DTMF_UNSPECIFIED value + * @property {number} DTMF_ONE=1 DTMF_ONE value + * @property {number} DTMF_TWO=2 DTMF_TWO value + * @property {number} DTMF_THREE=3 DTMF_THREE value + * @property {number} DTMF_FOUR=4 DTMF_FOUR value + * @property {number} DTMF_FIVE=5 DTMF_FIVE value + * @property {number} DTMF_SIX=6 DTMF_SIX value + * @property {number} DTMF_SEVEN=7 DTMF_SEVEN value + * @property {number} DTMF_EIGHT=8 DTMF_EIGHT value + * @property {number} DTMF_NINE=9 DTMF_NINE value + * @property {number} DTMF_ZERO=10 DTMF_ZERO value + * @property {number} DTMF_A=11 DTMF_A value + * @property {number} DTMF_B=12 DTMF_B value + * @property {number} DTMF_C=13 DTMF_C value + * @property {number} DTMF_D=14 DTMF_D value + * @property {number} DTMF_STAR=15 DTMF_STAR value + * @property {number} DTMF_POUND=16 DTMF_POUND value + */ + v2.TelephonyDtmf = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "TELEPHONY_DTMF_UNSPECIFIED"] = 0; + values[valuesById[1] = "DTMF_ONE"] = 1; + values[valuesById[2] = "DTMF_TWO"] = 2; + values[valuesById[3] = "DTMF_THREE"] = 3; + values[valuesById[4] = "DTMF_FOUR"] = 4; + values[valuesById[5] = "DTMF_FIVE"] = 5; + values[valuesById[6] = "DTMF_SIX"] = 6; + values[valuesById[7] = "DTMF_SEVEN"] = 7; + values[valuesById[8] = "DTMF_EIGHT"] = 8; + values[valuesById[9] = "DTMF_NINE"] = 9; + values[valuesById[10] = "DTMF_ZERO"] = 10; + values[valuesById[11] = "DTMF_A"] = 11; + values[valuesById[12] = "DTMF_B"] = 12; + values[valuesById[13] = "DTMF_C"] = 13; + values[valuesById[14] = "DTMF_D"] = 14; + values[valuesById[15] = "DTMF_STAR"] = 15; + values[valuesById[16] = "DTMF_POUND"] = 16; + return values; + })(); + + v2.TelephonyDtmfEvents = (function() { + + /** + * Properties of a TelephonyDtmfEvents. + * @memberof google.cloud.dialogflow.v2 + * @interface ITelephonyDtmfEvents + * @property {Array.|null} [dtmfEvents] TelephonyDtmfEvents dtmfEvents + */ + + /** + * Constructs a new TelephonyDtmfEvents. + * @memberof google.cloud.dialogflow.v2 + * @classdesc Represents a TelephonyDtmfEvents. + * @implements ITelephonyDtmfEvents + * @constructor + * @param {google.cloud.dialogflow.v2.ITelephonyDtmfEvents=} [properties] Properties to set + */ + function TelephonyDtmfEvents(properties) { + this.dtmfEvents = []; + 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]]; + } + + /** + * TelephonyDtmfEvents dtmfEvents. + * @member {Array.} dtmfEvents + * @memberof google.cloud.dialogflow.v2.TelephonyDtmfEvents + * @instance + */ + TelephonyDtmfEvents.prototype.dtmfEvents = $util.emptyArray; + + /** + * Creates a new TelephonyDtmfEvents instance using the specified properties. + * @function create + * @memberof google.cloud.dialogflow.v2.TelephonyDtmfEvents + * @static + * @param {google.cloud.dialogflow.v2.ITelephonyDtmfEvents=} [properties] Properties to set + * @returns {google.cloud.dialogflow.v2.TelephonyDtmfEvents} TelephonyDtmfEvents instance + */ + TelephonyDtmfEvents.create = function create(properties) { + return new TelephonyDtmfEvents(properties); + }; + + /** + * Encodes the specified TelephonyDtmfEvents message. Does not implicitly {@link google.cloud.dialogflow.v2.TelephonyDtmfEvents.verify|verify} messages. + * @function encode + * @memberof google.cloud.dialogflow.v2.TelephonyDtmfEvents + * @static + * @param {google.cloud.dialogflow.v2.ITelephonyDtmfEvents} message TelephonyDtmfEvents message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TelephonyDtmfEvents.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.dtmfEvents != null && message.dtmfEvents.length) { + writer.uint32(/* id 1, wireType 2 =*/10).fork(); + for (var i = 0; i < message.dtmfEvents.length; ++i) + writer.int32(message.dtmfEvents[i]); + writer.ldelim(); + } + return writer; + }; + + /** + * Encodes the specified TelephonyDtmfEvents message, length delimited. Does not implicitly {@link google.cloud.dialogflow.v2.TelephonyDtmfEvents.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.dialogflow.v2.TelephonyDtmfEvents + * @static + * @param {google.cloud.dialogflow.v2.ITelephonyDtmfEvents} message TelephonyDtmfEvents message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TelephonyDtmfEvents.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TelephonyDtmfEvents message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.dialogflow.v2.TelephonyDtmfEvents + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.dialogflow.v2.TelephonyDtmfEvents} TelephonyDtmfEvents + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TelephonyDtmfEvents.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.dialogflow.v2.TelephonyDtmfEvents(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.dtmfEvents && message.dtmfEvents.length)) + message.dtmfEvents = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.dtmfEvents.push(reader.int32()); + } else + message.dtmfEvents.push(reader.int32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TelephonyDtmfEvents message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.dialogflow.v2.TelephonyDtmfEvents + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.dialogflow.v2.TelephonyDtmfEvents} TelephonyDtmfEvents + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TelephonyDtmfEvents.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TelephonyDtmfEvents message. + * @function verify + * @memberof google.cloud.dialogflow.v2.TelephonyDtmfEvents + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TelephonyDtmfEvents.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.dtmfEvents != null && message.hasOwnProperty("dtmfEvents")) { + if (!Array.isArray(message.dtmfEvents)) + return "dtmfEvents: array expected"; + for (var i = 0; i < message.dtmfEvents.length; ++i) + switch (message.dtmfEvents[i]) { + default: + return "dtmfEvents: enum value[] expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + break; + } + } + return null; + }; + + /** + * Creates a TelephonyDtmfEvents message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.dialogflow.v2.TelephonyDtmfEvents + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.dialogflow.v2.TelephonyDtmfEvents} TelephonyDtmfEvents + */ + TelephonyDtmfEvents.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.dialogflow.v2.TelephonyDtmfEvents) + return object; + var message = new $root.google.cloud.dialogflow.v2.TelephonyDtmfEvents(); + if (object.dtmfEvents) { + if (!Array.isArray(object.dtmfEvents)) + throw TypeError(".google.cloud.dialogflow.v2.TelephonyDtmfEvents.dtmfEvents: array expected"); + message.dtmfEvents = []; + for (var i = 0; i < object.dtmfEvents.length; ++i) + switch (object.dtmfEvents[i]) { + default: + if (typeof object.dtmfEvents[i] === "number") { + message.dtmfEvents[i] = object.dtmfEvents[i]; + break; + } + case "TELEPHONY_DTMF_UNSPECIFIED": + case 0: + message.dtmfEvents[i] = 0; + break; + case "DTMF_ONE": + case 1: + message.dtmfEvents[i] = 1; + break; + case "DTMF_TWO": + case 2: + message.dtmfEvents[i] = 2; + break; + case "DTMF_THREE": + case 3: + message.dtmfEvents[i] = 3; + break; + case "DTMF_FOUR": + case 4: + message.dtmfEvents[i] = 4; + break; + case "DTMF_FIVE": + case 5: + message.dtmfEvents[i] = 5; + break; + case "DTMF_SIX": + case 6: + message.dtmfEvents[i] = 6; + break; + case "DTMF_SEVEN": + case 7: + message.dtmfEvents[i] = 7; + break; + case "DTMF_EIGHT": + case 8: + message.dtmfEvents[i] = 8; + break; + case "DTMF_NINE": + case 9: + message.dtmfEvents[i] = 9; + break; + case "DTMF_ZERO": + case 10: + message.dtmfEvents[i] = 10; + break; + case "DTMF_A": + case 11: + message.dtmfEvents[i] = 11; + break; + case "DTMF_B": + case 12: + message.dtmfEvents[i] = 12; + break; + case "DTMF_C": + case 13: + message.dtmfEvents[i] = 13; + break; + case "DTMF_D": + case 14: + message.dtmfEvents[i] = 14; + break; + case "DTMF_STAR": + case 15: + message.dtmfEvents[i] = 15; + break; + case "DTMF_POUND": + case 16: + message.dtmfEvents[i] = 16; + break; + } + } + return message; + }; + + /** + * Creates a plain object from a TelephonyDtmfEvents message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.dialogflow.v2.TelephonyDtmfEvents + * @static + * @param {google.cloud.dialogflow.v2.TelephonyDtmfEvents} message TelephonyDtmfEvents + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TelephonyDtmfEvents.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.dtmfEvents = []; + if (message.dtmfEvents && message.dtmfEvents.length) { + object.dtmfEvents = []; + for (var j = 0; j < message.dtmfEvents.length; ++j) + object.dtmfEvents[j] = options.enums === String ? $root.google.cloud.dialogflow.v2.TelephonyDtmf[message.dtmfEvents[j]] === undefined ? message.dtmfEvents[j] : $root.google.cloud.dialogflow.v2.TelephonyDtmf[message.dtmfEvents[j]] : message.dtmfEvents[j]; + } + return object; + }; + + /** + * Converts this TelephonyDtmfEvents to JSON. + * @function toJSON + * @memberof google.cloud.dialogflow.v2.TelephonyDtmfEvents + * @instance + * @returns {Object.} JSON object + */ + TelephonyDtmfEvents.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TelephonyDtmfEvents + * @function getTypeUrl + * @memberof google.cloud.dialogflow.v2.TelephonyDtmfEvents + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TelephonyDtmfEvents.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.dialogflow.v2.TelephonyDtmfEvents"; + }; + + return TelephonyDtmfEvents; + })(); + v2.SpeechToTextConfig = (function() { /** @@ -15870,6 +17455,7 @@ * @memberof google.cloud.dialogflow.v2 * @interface ISpeechToTextConfig * @property {google.cloud.dialogflow.v2.SpeechModelVariant|null} [speechModelVariant] SpeechToTextConfig speechModelVariant + * @property {string|null} [model] SpeechToTextConfig model */ /** @@ -15895,6 +17481,14 @@ */ SpeechToTextConfig.prototype.speechModelVariant = 0; + /** + * SpeechToTextConfig model. + * @member {string} model + * @memberof google.cloud.dialogflow.v2.SpeechToTextConfig + * @instance + */ + SpeechToTextConfig.prototype.model = ""; + /** * Creates a new SpeechToTextConfig instance using the specified properties. * @function create @@ -15921,6 +17515,8 @@ writer = $Writer.create(); if (message.speechModelVariant != null && Object.hasOwnProperty.call(message, "speechModelVariant")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.speechModelVariant); + if (message.model != null && Object.hasOwnProperty.call(message, "model")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.model); return writer; }; @@ -15959,6 +17555,10 @@ message.speechModelVariant = reader.int32(); break; } + case 2: { + message.model = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -16004,6 +17604,9 @@ case 3: break; } + if (message.model != null && message.hasOwnProperty("model")) + if (!$util.isString(message.model)) + return "model: string expected"; return null; }; @@ -16043,6 +17646,8 @@ message.speechModelVariant = 3; break; } + if (object.model != null) + message.model = String(object.model); return message; }; @@ -16059,10 +17664,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.speechModelVariant = options.enums === String ? "SPEECH_MODEL_VARIANT_UNSPECIFIED" : 0; + object.model = ""; + } if (message.speechModelVariant != null && message.hasOwnProperty("speechModelVariant")) object.speechModelVariant = options.enums === String ? $root.google.cloud.dialogflow.v2.SpeechModelVariant[message.speechModelVariant] === undefined ? message.speechModelVariant : $root.google.cloud.dialogflow.v2.SpeechModelVariant[message.speechModelVariant] : message.speechModelVariant; + if (message.model != null && message.hasOwnProperty("model")) + object.model = message.model; return object; }; @@ -100373,6 +101982,7 @@ * @memberof google.cloud.dialogflow.v2beta1 * @interface ISpeechToTextConfig * @property {google.cloud.dialogflow.v2beta1.SpeechModelVariant|null} [speechModelVariant] SpeechToTextConfig speechModelVariant + * @property {string|null} [model] SpeechToTextConfig model */ /** @@ -100398,6 +102008,14 @@ */ SpeechToTextConfig.prototype.speechModelVariant = 0; + /** + * SpeechToTextConfig model. + * @member {string} model + * @memberof google.cloud.dialogflow.v2beta1.SpeechToTextConfig + * @instance + */ + SpeechToTextConfig.prototype.model = ""; + /** * Creates a new SpeechToTextConfig instance using the specified properties. * @function create @@ -100424,6 +102042,8 @@ writer = $Writer.create(); if (message.speechModelVariant != null && Object.hasOwnProperty.call(message, "speechModelVariant")) writer.uint32(/* id 1, wireType 0 =*/8).int32(message.speechModelVariant); + if (message.model != null && Object.hasOwnProperty.call(message, "model")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.model); return writer; }; @@ -100462,6 +102082,10 @@ message.speechModelVariant = reader.int32(); break; } + case 2: { + message.model = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -100507,6 +102131,9 @@ case 3: break; } + if (message.model != null && message.hasOwnProperty("model")) + if (!$util.isString(message.model)) + return "model: string expected"; return null; }; @@ -100546,6 +102173,8 @@ message.speechModelVariant = 3; break; } + if (object.model != null) + message.model = String(object.model); return message; }; @@ -100562,10 +102191,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.speechModelVariant = options.enums === String ? "SPEECH_MODEL_VARIANT_UNSPECIFIED" : 0; + object.model = ""; + } if (message.speechModelVariant != null && message.hasOwnProperty("speechModelVariant")) object.speechModelVariant = options.enums === String ? $root.google.cloud.dialogflow.v2beta1.SpeechModelVariant[message.speechModelVariant] === undefined ? message.speechModelVariant : $root.google.cloud.dialogflow.v2beta1.SpeechModelVariant[message.speechModelVariant] : message.speechModelVariant; + if (message.model != null && message.hasOwnProperty("model")) + object.model = message.model; return object; }; diff --git a/protos/protos.json b/protos/protos.json index a776eca3..fbdc8f83 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -1035,6 +1035,12 @@ } ] }, + "StreamingAnalyzeContent": { + "requestType": "StreamingAnalyzeContentRequest", + "requestStream": true, + "responseType": "StreamingAnalyzeContentResponse", + "responseStream": true + }, "SuggestArticles": { "requestType": "SuggestArticlesRequest", "responseType": "SuggestArticlesResponse", @@ -1142,6 +1148,13 @@ "(google.api.field_behavior)": "OPTIONAL" } }, + "obfuscatedExternalUserId": { + "type": "string", + "id": 7, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, "documentsMetadataFilters": { "keyType": "string", "type": "string", @@ -1411,6 +1424,111 @@ } } }, + "StreamingAnalyzeContentRequest": { + "oneofs": { + "config": { + "oneof": [ + "audioConfig", + "textConfig" + ] + }, + "input": { + "oneof": [ + "inputAudio", + "inputText", + "inputDtmf" + ] + } + }, + "fields": { + "participant": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).type": "dialogflow.googleapis.com/Participant" + } + }, + "audioConfig": { + "type": "InputAudioConfig", + "id": 2 + }, + "textConfig": { + "type": "InputTextConfig", + "id": 3 + }, + "replyAudioConfig": { + "type": "OutputAudioConfig", + "id": 4 + }, + "inputAudio": { + "type": "bytes", + "id": 5 + }, + "inputText": { + "type": "string", + "id": 6 + }, + "inputDtmf": { + "type": "TelephonyDtmfEvents", + "id": 9 + }, + "queryParams": { + "type": "QueryParameters", + "id": 7 + }, + "assistQueryParams": { + "type": "AssistQueryParameters", + "id": 8 + }, + "cxParameters": { + "type": "google.protobuf.Struct", + "id": 13 + }, + "enablePartialAutomatedAgentReply": { + "type": "bool", + "id": 12 + } + } + }, + "StreamingAnalyzeContentResponse": { + "fields": { + "recognitionResult": { + "type": "StreamingRecognitionResult", + "id": 1 + }, + "replyText": { + "type": "string", + "id": 2 + }, + "replyAudio": { + "type": "OutputAudio", + "id": 3 + }, + "automatedAgentReply": { + "type": "AutomatedAgentReply", + "id": 4 + }, + "message": { + "type": "Message", + "id": 6 + }, + "humanAgentSuggestionResults": { + "rule": "repeated", + "type": "SuggestionResult", + "id": 7 + }, + "endUserSuggestionResults": { + "rule": "repeated", + "type": "SuggestionResult", + "id": 8 + }, + "dtmfParameters": { + "type": "DtmfParameters", + "id": 10 + } + } + }, "SuggestArticlesRequest": { "fields": { "parent": { @@ -1702,6 +1820,17 @@ } } }, + "InputTextConfig": { + "fields": { + "languageCode": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, "AnnotatedMessagePart": { "fields": { "text": { @@ -1916,11 +2045,45 @@ } } }, + "TelephonyDtmf": { + "values": { + "TELEPHONY_DTMF_UNSPECIFIED": 0, + "DTMF_ONE": 1, + "DTMF_TWO": 2, + "DTMF_THREE": 3, + "DTMF_FOUR": 4, + "DTMF_FIVE": 5, + "DTMF_SIX": 6, + "DTMF_SEVEN": 7, + "DTMF_EIGHT": 8, + "DTMF_NINE": 9, + "DTMF_ZERO": 10, + "DTMF_A": 11, + "DTMF_B": 12, + "DTMF_C": 13, + "DTMF_D": 14, + "DTMF_STAR": 15, + "DTMF_POUND": 16 + } + }, + "TelephonyDtmfEvents": { + "fields": { + "dtmfEvents": { + "rule": "repeated", + "type": "TelephonyDtmf", + "id": 1 + } + } + }, "SpeechToTextConfig": { "fields": { "speechModelVariant": { "type": "SpeechModelVariant", "id": 1 + }, + "model": { + "type": "string", + "id": 2 } } }, @@ -11910,6 +12073,10 @@ "speechModelVariant": { "type": "SpeechModelVariant", "id": 1 + }, + "model": { + "type": "string", + "id": 2 } } }, diff --git a/samples/generated/v2/participants.streaming_analyze_content.js b/samples/generated/v2/participants.streaming_analyze_content.js new file mode 100644 index 00000000..5077043f --- /dev/null +++ b/samples/generated/v2/participants.streaming_analyze_content.js @@ -0,0 +1,125 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(participant) { + // [START dialogflow_v2_generated_Participants_StreamingAnalyzeContent_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the participant this text comes from. + * Format: `projects//locations//conversations//participants/`. + */ + // const participant = 'abc123' + /** + * Instructs the speech recognizer how to process the speech audio. + */ + // const audioConfig = {} + /** + * The natural language text to be processed. + */ + // const textConfig = {} + /** + * Speech synthesis configuration. + * The speech synthesis settings for a virtual agent that may be configured + * for the associated conversation profile are not used when calling + * StreamingAnalyzeContent. If this configuration is not supplied, speech + * synthesis is disabled. + */ + // const replyAudioConfig = {} + /** + * The input audio content to be recognized. Must be sent if `audio_config` + * is set in the first message. The complete audio over all streaming + * messages must not exceed 1 minute. + */ + // const inputAudio = 'Buffer.from('string')' + /** + * The UTF-8 encoded natural language text to be processed. Must be sent if + * `text_config` is set in the first message. Text length must not exceed + * 256 bytes for virtual agent interactions. The `input_text` field can be + * only sent once. + */ + // const inputText = 'abc123' + /** + * The DTMF digits used to invoke intent and fill in parameter value. + * This input is ignored if the previous response indicated that DTMF input + * is not accepted. + */ + // const inputDtmf = {} + /** + * Parameters for a Dialogflow virtual-agent query. + */ + // const queryParams = {} + /** + * Parameters for a human assist query. + */ + // const assistQueryParams = {} + /** + * Additional parameters to be put into Dialogflow CX session parameters. To + * remove a parameter from the session, clients should explicitly set the + * parameter value to null. + * Note: this field should only be used if you are connecting to a Dialogflow + * CX agent. + */ + // const cxParameters = {} + /** + * Enable partial virtual agent responses. If this flag is not enabled, + * response stream still contains only one final response even if some + * `Fulfillment`s in Dialogflow virtual agent have been configured to return + * partial responses. + */ + // const enablePartialAutomatedAgentReply = true + + // Imports the Dialogflow library + const {ParticipantsClient} = require('@google-cloud/dialogflow').v2; + + // Instantiates a client + const dialogflowClient = new ParticipantsClient(); + + async function callStreamingAnalyzeContent() { + // Construct request + const request = { + participant, + }; + + // Run request + const stream = await dialogflowClient.streamingAnalyzeContent(); + stream.on('data', (response) => { console.log(response) }); + stream.on('error', (err) => { throw(err) }); + stream.on('end', () => { /* API call completed */ }); + stream.write(request); + stream.end(); + } + + callStreamingAnalyzeContent(); + // [END dialogflow_v2_generated_Participants_StreamingAnalyzeContent_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/samples/generated/v2/snippet_metadata.google.cloud.dialogflow.v2.json b/samples/generated/v2/snippet_metadata.google.cloud.dialogflow.v2.json index 02c512fb..40db07c8 100644 --- a/samples/generated/v2/snippet_metadata.google.cloud.dialogflow.v2.json +++ b/samples/generated/v2/snippet_metadata.google.cloud.dialogflow.v2.json @@ -3935,6 +3935,86 @@ } } }, + { + "regionTag": "dialogflow_v2_generated_Participants_StreamingAnalyzeContent_async", + "title": "dialogflow streamingAnalyzeContent Sample", + "origin": "API_DEFINITION", + "description": " Adds a text (chat, for example), or audio (phone recording, for example) message from a participant into the conversation. Note: This method is only available through the gRPC API (not REST). The top-level message sent to the client by the server is `StreamingAnalyzeContentResponse`. Multiple response messages can be returned in order. The first one or more messages contain the `recognition_result` field. Each result represents a more complete transcript of what the user said. The next message contains the `reply_text` field and potentially the `reply_audio` field. The message can also contain the `automated_agent_reply` field. Note: Always use agent versions for production traffic sent to virtual agents. See [Versions and environments](https://cloud.google.com/dialogflow/es/docs/agents-versions).", + "canonical": true, + "file": "participants.streaming_analyze_content.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 117, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "StreamingAnalyzeContent", + "fullName": "google.cloud.dialogflow.v2.Participants.StreamingAnalyzeContent", + "async": true, + "parameters": [ + { + "name": "participant", + "type": "TYPE_STRING" + }, + { + "name": "audio_config", + "type": ".google.cloud.dialogflow.v2.InputAudioConfig" + }, + { + "name": "text_config", + "type": ".google.cloud.dialogflow.v2.InputTextConfig" + }, + { + "name": "reply_audio_config", + "type": ".google.cloud.dialogflow.v2.OutputAudioConfig" + }, + { + "name": "input_audio", + "type": "TYPE_BYTES" + }, + { + "name": "input_text", + "type": "TYPE_STRING" + }, + { + "name": "input_dtmf", + "type": ".google.cloud.dialogflow.v2.TelephonyDtmfEvents" + }, + { + "name": "query_params", + "type": ".google.cloud.dialogflow.v2.QueryParameters" + }, + { + "name": "assist_query_params", + "type": ".google.cloud.dialogflow.v2.AssistQueryParameters" + }, + { + "name": "cx_parameters", + "type": ".google.protobuf.Struct" + }, + { + "name": "enable_partial_automated_agent_reply", + "type": "TYPE_BOOL" + } + ], + "resultType": ".google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse", + "client": { + "shortName": "ParticipantsClient", + "fullName": "google.cloud.dialogflow.v2.ParticipantsClient" + }, + "method": { + "shortName": "StreamingAnalyzeContent", + "fullName": "google.cloud.dialogflow.v2.Participants.StreamingAnalyzeContent", + "service": { + "shortName": "Participants", + "fullName": "google.cloud.dialogflow.v2.Participants" + } + } + } + }, { "regionTag": "dialogflow_v2_generated_Participants_SuggestArticles_async", "title": "dialogflow suggestArticles Sample", diff --git a/src/v2/answer_records_client.ts b/src/v2/answer_records_client.ts index 5e196c87..a5f35b2f 100644 --- a/src/v2/answer_records_client.ts +++ b/src/v2/answer_records_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class AnswerRecordsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; answerRecordsStub?: Promise<{[name: string]: Function}>; /** @@ -337,54 +335,6 @@ export class AnswerRecordsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - {post: '/v2/{name=projects/*/locations/*/operations/*}:cancel'}, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2.AnswerRecords', @@ -929,183 +879,6 @@ export class AnswerRecordsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -3670,7 +3443,6 @@ export class AnswerRecordsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2/contexts_client.ts b/src/v2/contexts_client.ts index 546be298..687fbee9 100644 --- a/src/v2/contexts_client.ts +++ b/src/v2/contexts_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class ContextsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; contextsStub?: Promise<{[name: string]: Function}>; /** @@ -340,54 +338,6 @@ export class ContextsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - {post: '/v2/{name=projects/*/locations/*/operations/*}:cancel'}, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2.Contexts', @@ -1293,183 +1243,6 @@ export class ContextsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -4074,7 +3847,6 @@ export class ContextsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2/conversations_client.ts b/src/v2/conversations_client.ts index 4133a0ca..5419f6de 100644 --- a/src/v2/conversations_client.ts +++ b/src/v2/conversations_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class ConversationsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; conversationsStub?: Promise<{[name: string]: Function}>; /** @@ -342,54 +340,6 @@ export class ConversationsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - {post: '/v2/{name=projects/*/locations/*/operations/*}:cancel'}, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2.Conversations', @@ -1405,183 +1355,6 @@ export class ConversationsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -4146,7 +3919,6 @@ export class ConversationsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2/environments_client.ts b/src/v2/environments_client.ts index 2b45db8b..1458e367 100644 --- a/src/v2/environments_client.ts +++ b/src/v2/environments_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class EnvironmentsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; environmentsStub?: Promise<{[name: string]: Function}>; /** @@ -342,54 +340,6 @@ export class EnvironmentsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - {post: '/v2/{name=projects/*/locations/*/operations/*}:cancel'}, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2.Environments', @@ -1428,183 +1378,6 @@ export class EnvironmentsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -4169,7 +3942,6 @@ export class EnvironmentsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2/fulfillments_client.ts b/src/v2/fulfillments_client.ts index 2c97e323..0033cc54 100644 --- a/src/v2/fulfillments_client.ts +++ b/src/v2/fulfillments_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, LocationsClient, LocationProtos, } from 'google-gax'; @@ -62,7 +61,6 @@ export class FulfillmentsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; fulfillmentsStub?: Promise<{[name: string]: Function}>; /** @@ -321,54 +319,6 @@ export class FulfillmentsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - {post: '/v2/{name=projects/*/locations/*/operations/*}:cancel'}, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2.Fulfillments', @@ -771,183 +721,6 @@ export class FulfillmentsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -3489,7 +3262,6 @@ export class FulfillmentsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2/gapic_metadata.json b/src/v2/gapic_metadata.json index 3856337b..7065b593 100644 --- a/src/v2/gapic_metadata.json +++ b/src/v2/gapic_metadata.json @@ -1097,6 +1097,11 @@ "suggestSmartReplies" ] }, + "StreamingAnalyzeContent": { + "methods": [ + "streamingAnalyzeContent" + ] + }, "ListParticipants": { "methods": [ "listParticipants", diff --git a/src/v2/knowledge_bases_client.ts b/src/v2/knowledge_bases_client.ts index 35c130bd..103a7f76 100644 --- a/src/v2/knowledge_bases_client.ts +++ b/src/v2/knowledge_bases_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class KnowledgeBasesClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; knowledgeBasesStub?: Promise<{[name: string]: Function}>; /** @@ -337,54 +335,6 @@ export class KnowledgeBasesClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - {post: '/v2/{name=projects/*/locations/*/operations/*}:cancel'}, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2.KnowledgeBases', @@ -1261,183 +1211,6 @@ export class KnowledgeBasesClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -4002,7 +3775,6 @@ export class KnowledgeBasesClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2/participants_client.ts b/src/v2/participants_client.ts index e1f0db5d..e51a395b 100644 --- a/src/v2/participants_client.ts +++ b/src/v2/participants_client.ts @@ -23,13 +23,12 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, LocationProtos, } from 'google-gax'; -import {Transform} from 'stream'; +import {Transform, PassThrough} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -64,7 +63,6 @@ export class ParticipantsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; participantsStub?: Promise<{[name: string]: Function}>; /** @@ -337,53 +335,14 @@ export class ParticipantsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, + // Some of the methods on this service provide streaming responses. + // Provide descriptors for these. + this.descriptors.stream = { + streamingAnalyzeContent: new this._gaxModule.StreamDescriptor( + this._gaxModule.StreamType.BIDI_STREAMING, + opts.fallback === 'rest' + ), }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - {post: '/v2/{name=projects/*/locations/*/operations/*}:cancel'}, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( @@ -440,6 +399,7 @@ export class ParticipantsClient { 'listParticipants', 'updateParticipant', 'analyzeContent', + 'streamingAnalyzeContent', 'suggestArticles', 'suggestFaqAnswers', 'suggestSmartReplies', @@ -449,6 +409,18 @@ export class ParticipantsClient { stub => (...args: Array<{}>) => { if (this._terminated) { + if (methodName in this.descriptors.stream) { + const stream = new PassThrough(); + setImmediate(() => { + stream.emit( + 'error', + new this._gaxModule.GoogleError( + 'The client has already been closed.' + ) + ); + }); + return stream; + } return Promise.reject('The client has already been closed.'); } const func = stub[methodName]; @@ -459,7 +431,10 @@ export class ParticipantsClient { } ); - const descriptor = this.descriptors.page[methodName] || undefined; + const descriptor = + this.descriptors.page[methodName] || + this.descriptors.stream[methodName] || + undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], @@ -1254,6 +1229,40 @@ export class ParticipantsClient { return this.innerApiCalls.suggestSmartReplies(request, options, callback); } + /** + * Adds a text (chat, for example), or audio (phone recording, for example) + * message from a participant into the conversation. + * Note: This method is only available through the gRPC API (not REST). + * + * The top-level message sent to the client by the server is + * `StreamingAnalyzeContentResponse`. Multiple response messages can be + * returned in order. The first one or more messages contain the + * `recognition_result` field. Each result represents a more complete + * transcript of what the user said. The next message contains the + * `reply_text` field and potentially the `reply_audio` field. The message can + * also contain the `automated_agent_reply` field. + * + * Note: Always use agent versions for production traffic + * sent to virtual agents. See [Versions and + * environments](https://cloud.google.com/dialogflow/es/docs/agents-versions). + * + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which is both readable and writable. It accepts objects + * representing [StreamingAnalyzeContentRequest]{@link google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest} for write() method, and + * will emit objects representing [StreamingAnalyzeContentResponse]{@link google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse} on 'data' event asynchronously. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#bi-directional-streaming) + * for more details and examples. + * @example include:samples/generated/v2/participants.streaming_analyze_content.js + * region_tag:dialogflow_v2_generated_Participants_StreamingAnalyzeContent_async + */ + streamingAnalyzeContent(options?: CallOptions): gax.CancellableStream { + this.initialize(); + return this.innerApiCalls.streamingAnalyzeContent(null, options); + } + /** * Returns the list of all participants in the specified conversation. * @@ -1532,183 +1541,6 @@ export class ParticipantsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -4273,7 +4105,6 @@ export class ParticipantsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2/participants_client_config.json b/src/v2/participants_client_config.json index e82473b2..e81ecec6 100644 --- a/src/v2/participants_client_config.json +++ b/src/v2/participants_client_config.json @@ -48,6 +48,11 @@ "retry_codes_name": "unavailable", "retry_params_name": "default" }, + "StreamingAnalyzeContent": { + "timeout_millis": 220000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "SuggestArticles": { "timeout_millis": 60000, "retry_codes_name": "unavailable", diff --git a/src/v2/session_entity_types_client.ts b/src/v2/session_entity_types_client.ts index d1236dbc..3fb414e4 100644 --- a/src/v2/session_entity_types_client.ts +++ b/src/v2/session_entity_types_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class SessionEntityTypesClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; sessionEntityTypesStub?: Promise<{[name: string]: Function}>; /** @@ -340,54 +338,6 @@ export class SessionEntityTypesClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - {post: '/v2/{name=projects/*/locations/*/operations/*}:cancel'}, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2.SessionEntityTypes', @@ -1265,183 +1215,6 @@ export class SessionEntityTypesClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -4046,7 +3819,6 @@ export class SessionEntityTypesClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2/sessions_client.ts b/src/v2/sessions_client.ts index 2ec967d0..d250a856 100644 --- a/src/v2/sessions_client.ts +++ b/src/v2/sessions_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, LocationsClient, LocationProtos, } from 'google-gax'; @@ -65,7 +64,6 @@ export class SessionsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; sessionsStub?: Promise<{[name: string]: Function}>; /** @@ -347,54 +345,6 @@ export class SessionsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - {post: '/v2/{name=projects/*/locations/*/operations/*}:cancel'}, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2.Sessions', @@ -797,183 +747,6 @@ export class SessionsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -3808,7 +3581,6 @@ export class SessionsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2/versions_client.ts b/src/v2/versions_client.ts index f95636a2..c93bf0f8 100644 --- a/src/v2/versions_client.ts +++ b/src/v2/versions_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class VersionsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; versionsStub?: Promise<{[name: string]: Function}>; /** @@ -337,54 +335,6 @@ export class VersionsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - {post: '/v2/{name=projects/*/locations/*/operations/*}:cancel'}, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2.Versions', @@ -1198,183 +1148,6 @@ export class VersionsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -3939,7 +3712,6 @@ export class VersionsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2beta1/answer_records_client.ts b/src/v2beta1/answer_records_client.ts index 138d1153..a51e56d4 100644 --- a/src/v2beta1/answer_records_client.ts +++ b/src/v2beta1/answer_records_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class AnswerRecordsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; answerRecordsStub?: Promise<{[name: string]: Function}>; /** @@ -319,56 +317,6 @@ export class AnswerRecordsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2beta1/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2beta1/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2beta1/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - { - post: '/v2beta1/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2beta1/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2beta1/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2beta1.AnswerRecords', @@ -1020,183 +968,6 @@ export class AnswerRecordsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -3437,7 +3208,6 @@ export class AnswerRecordsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2beta1/contexts_client.ts b/src/v2beta1/contexts_client.ts index b391788c..4656ee99 100644 --- a/src/v2beta1/contexts_client.ts +++ b/src/v2beta1/contexts_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class ContextsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; contextsStub?: Promise<{[name: string]: Function}>; /** @@ -322,56 +320,6 @@ export class ContextsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2beta1/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2beta1/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2beta1/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - { - post: '/v2beta1/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2beta1/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2beta1/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2beta1.Contexts', @@ -1340,183 +1288,6 @@ export class ContextsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -3797,7 +3568,6 @@ export class ContextsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2beta1/conversations_client.ts b/src/v2beta1/conversations_client.ts index d7d553b6..1d8b57c7 100644 --- a/src/v2beta1/conversations_client.ts +++ b/src/v2beta1/conversations_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class ConversationsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; conversationsStub?: Promise<{[name: string]: Function}>; /** @@ -324,56 +322,6 @@ export class ConversationsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2beta1/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2beta1/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2beta1/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - { - post: '/v2beta1/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2beta1/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2beta1/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2beta1.Conversations', @@ -1623,183 +1571,6 @@ export class ConversationsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -4040,7 +3811,6 @@ export class ConversationsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2beta1/environments_client.ts b/src/v2beta1/environments_client.ts index 3fce7a21..4902ef7d 100644 --- a/src/v2beta1/environments_client.ts +++ b/src/v2beta1/environments_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class EnvironmentsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; environmentsStub?: Promise<{[name: string]: Function}>; /** @@ -324,56 +322,6 @@ export class EnvironmentsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2beta1/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2beta1/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2beta1/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - { - post: '/v2beta1/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2beta1/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2beta1/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2beta1.Environments', @@ -1417,183 +1365,6 @@ export class EnvironmentsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -3834,7 +3605,6 @@ export class EnvironmentsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2beta1/fulfillments_client.ts b/src/v2beta1/fulfillments_client.ts index 2c0e022d..99a40bdf 100644 --- a/src/v2beta1/fulfillments_client.ts +++ b/src/v2beta1/fulfillments_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, LocationsClient, LocationProtos, } from 'google-gax'; @@ -62,7 +61,6 @@ export class FulfillmentsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; fulfillmentsStub?: Promise<{[name: string]: Function}>; /** @@ -303,56 +301,6 @@ export class FulfillmentsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2beta1/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2beta1/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2beta1/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - { - post: '/v2beta1/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2beta1/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2beta1/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2beta1.Fulfillments', @@ -764,183 +712,6 @@ export class FulfillmentsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -3158,7 +2929,6 @@ export class FulfillmentsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2beta1/knowledge_bases_client.ts b/src/v2beta1/knowledge_bases_client.ts index 35dd7814..0c2db375 100644 --- a/src/v2beta1/knowledge_bases_client.ts +++ b/src/v2beta1/knowledge_bases_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class KnowledgeBasesClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; knowledgeBasesStub?: Promise<{[name: string]: Function}>; /** @@ -319,56 +317,6 @@ export class KnowledgeBasesClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2beta1/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2beta1/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2beta1/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - { - post: '/v2beta1/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2beta1/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2beta1/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2beta1.KnowledgeBases', @@ -1284,183 +1232,6 @@ export class KnowledgeBasesClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -3701,7 +3472,6 @@ export class KnowledgeBasesClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2beta1/participants_client.ts b/src/v2beta1/participants_client.ts index 736310d5..c95e41a6 100644 --- a/src/v2beta1/participants_client.ts +++ b/src/v2beta1/participants_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class ParticipantsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; participantsStub?: Promise<{[name: string]: Function}>; /** @@ -333,56 +331,6 @@ export class ParticipantsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2beta1/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2beta1/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2beta1/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - { - post: '/v2beta1/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2beta1/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2beta1/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2beta1.Participants', @@ -2032,183 +1980,6 @@ export class ParticipantsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -4449,7 +4220,6 @@ export class ParticipantsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2beta1/session_entity_types_client.ts b/src/v2beta1/session_entity_types_client.ts index 4f1c7d8c..6d314c24 100644 --- a/src/v2beta1/session_entity_types_client.ts +++ b/src/v2beta1/session_entity_types_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class SessionEntityTypesClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; sessionEntityTypesStub?: Promise<{[name: string]: Function}>; /** @@ -322,56 +320,6 @@ export class SessionEntityTypesClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2beta1/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2beta1/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2beta1/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - { - post: '/v2beta1/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2beta1/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2beta1/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2beta1.SessionEntityTypes', @@ -1297,183 +1245,6 @@ export class SessionEntityTypesClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -3754,7 +3525,6 @@ export class SessionEntityTypesClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2beta1/sessions_client.ts b/src/v2beta1/sessions_client.ts index 8a346b5d..f3b75cdc 100644 --- a/src/v2beta1/sessions_client.ts +++ b/src/v2beta1/sessions_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, LocationsClient, LocationProtos, } from 'google-gax'; @@ -65,7 +64,6 @@ export class SessionsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; sessionsStub?: Promise<{[name: string]: Function}>; /** @@ -329,56 +327,6 @@ export class SessionsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2beta1/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2beta1/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2beta1/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - { - post: '/v2beta1/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2beta1/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2beta1/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2beta1.Sessions', @@ -793,183 +741,6 @@ export class SessionsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -3480,7 +3251,6 @@ export class SessionsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/src/v2beta1/versions_client.ts b/src/v2beta1/versions_client.ts index 9075d4b2..bd04cbf5 100644 --- a/src/v2beta1/versions_client.ts +++ b/src/v2beta1/versions_client.ts @@ -23,7 +23,6 @@ import type { CallOptions, Descriptors, ClientOptions, - GrpcClientOptions, PaginationCallback, GaxCall, LocationsClient, @@ -64,7 +63,6 @@ export class VersionsClient { innerApiCalls: {[name: string]: Function}; locationsClient: LocationsClient; pathTemplates: {[name: string]: gax.PathTemplate}; - operationsClient: gax.OperationsClient; versionsStub?: Promise<{[name: string]: Function}>; /** @@ -319,56 +317,6 @@ export class VersionsClient { ), }; - const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); - // This API contains "long-running operations", which return a - // an Operation object that allows for tracking of the operation, - // rather than holding a request open. - const lroOptions: GrpcClientOptions = { - auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, - }; - if (opts.fallback === 'rest') { - lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.cloud.location.Locations.GetLocation', - get: '/v2beta1/{name=projects/*/locations/*}', - }, - { - selector: 'google.cloud.location.Locations.ListLocations', - get: '/v2beta1/{name=projects/*}/locations', - }, - { - selector: 'google.longrunning.Operations.CancelOperation', - post: '/v2beta1/{name=projects/*/operations/*}:cancel', - additional_bindings: [ - { - post: '/v2beta1/{name=projects/*/locations/*/operations/*}:cancel', - }, - ], - }, - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v2beta1/{name=projects/*/operations/*}', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*/operations/*}'}, - ], - }, - { - selector: 'google.longrunning.Operations.ListOperations', - get: '/v2beta1/{name=projects/*}/operations', - additional_bindings: [ - {get: '/v2beta1/{name=projects/*/locations/*}/operations'}, - ], - }, - ]; - } - this.operationsClient = this._gaxModule - .lro(lroOptions) - .operationsClient(opts); - - this.descriptors.longrunning = {}; - // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( 'google.cloud.dialogflow.v2beta1.Versions', @@ -1181,183 +1129,6 @@ export class VersionsClient { return this.locationsClient.listLocationsAsync(request, options); } - /** - * 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 -- // -------------------- @@ -3598,7 +3369,6 @@ export class VersionsClient { this._terminated = true; stub.close(); this.locationsClient.close(); - this.operationsClient.close(); }); } return Promise.resolve(); diff --git a/test/gapic_answer_records_v2.ts b/test/gapic_answer_records_v2.ts index 304eef87..add55604 100644 --- a/test/gapic_answer_records_v2.ts +++ b/test/gapic_answer_records_v2.ts @@ -25,7 +25,7 @@ import * as answerrecordsModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -884,311 +884,6 @@ describe('v2.AnswerRecordsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new answerrecordsModule.v2.AnswerRecordsClient({ - 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 answerrecordsModule.v2.AnswerRecordsClient({ - 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 answerrecordsModule.v2.AnswerRecordsClient({ - 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 answerrecordsModule.v2.AnswerRecordsClient({ - 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 answerrecordsModule.v2.AnswerRecordsClient({ - 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 answerrecordsModule.v2.AnswerRecordsClient({ - 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 answerrecordsModule.v2.AnswerRecordsClient({ - 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 answerrecordsModule.v2.AnswerRecordsClient({ - 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 answerrecordsModule.v2.AnswerRecordsClient({ - 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 answerrecordsModule.v2.AnswerRecordsClient({ - 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 answerrecordsModule.v2.AnswerRecordsClient({ - 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('conversationDataset', () => { diff --git a/test/gapic_answer_records_v2beta1.ts b/test/gapic_answer_records_v2beta1.ts index f7cf36ee..0426fd09 100644 --- a/test/gapic_answer_records_v2beta1.ts +++ b/test/gapic_answer_records_v2beta1.ts @@ -25,7 +25,7 @@ import * as answerrecordsModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -1028,311 +1028,6 @@ describe('v2beta1.AnswerRecordsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new answerrecordsModule.v2beta1.AnswerRecordsClient({ - 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 answerrecordsModule.v2beta1.AnswerRecordsClient({ - 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 answerrecordsModule.v2beta1.AnswerRecordsClient({ - 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 answerrecordsModule.v2beta1.AnswerRecordsClient({ - 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 answerrecordsModule.v2beta1.AnswerRecordsClient({ - 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 answerrecordsModule.v2beta1.AnswerRecordsClient({ - 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 answerrecordsModule.v2beta1.AnswerRecordsClient({ - 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 answerrecordsModule.v2beta1.AnswerRecordsClient({ - 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 answerrecordsModule.v2beta1.AnswerRecordsClient({ - 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 answerrecordsModule.v2beta1.AnswerRecordsClient({ - 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 answerrecordsModule.v2beta1.AnswerRecordsClient({ - 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('project', () => { diff --git a/test/gapic_contexts_v2.ts b/test/gapic_contexts_v2.ts index 801b7ca3..c20139bf 100644 --- a/test/gapic_contexts_v2.ts +++ b/test/gapic_contexts_v2.ts @@ -25,7 +25,7 @@ import * as contextsModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -1379,311 +1379,6 @@ describe('v2.ContextsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new contextsModule.v2.ContextsClient({ - 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 contextsModule.v2.ContextsClient({ - 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 contextsModule.v2.ContextsClient({ - 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 contextsModule.v2.ContextsClient({ - 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 contextsModule.v2.ContextsClient({ - 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 contextsModule.v2.ContextsClient({ - 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 contextsModule.v2.ContextsClient({ - 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 contextsModule.v2.ContextsClient({ - 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 contextsModule.v2.ContextsClient({ - 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 contextsModule.v2.ContextsClient({ - 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 contextsModule.v2.ContextsClient({ - 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('conversationDataset', () => { diff --git a/test/gapic_contexts_v2beta1.ts b/test/gapic_contexts_v2beta1.ts index 3b5c8e46..1004a112 100644 --- a/test/gapic_contexts_v2beta1.ts +++ b/test/gapic_contexts_v2beta1.ts @@ -25,7 +25,7 @@ import * as contextsModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -1403,311 +1403,6 @@ describe('v2beta1.ContextsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new contextsModule.v2beta1.ContextsClient({ - 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 contextsModule.v2beta1.ContextsClient({ - 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 contextsModule.v2beta1.ContextsClient({ - 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 contextsModule.v2beta1.ContextsClient({ - 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 contextsModule.v2beta1.ContextsClient({ - 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 contextsModule.v2beta1.ContextsClient({ - 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 contextsModule.v2beta1.ContextsClient({ - 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 contextsModule.v2beta1.ContextsClient({ - 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 contextsModule.v2beta1.ContextsClient({ - 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 contextsModule.v2beta1.ContextsClient({ - 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 contextsModule.v2beta1.ContextsClient({ - 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('project', () => { diff --git a/test/gapic_conversations_v2.ts b/test/gapic_conversations_v2.ts index 1645c5b3..541a7772 100644 --- a/test/gapic_conversations_v2.ts +++ b/test/gapic_conversations_v2.ts @@ -25,7 +25,7 @@ import * as conversationsModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -1444,311 +1444,6 @@ describe('v2.ConversationsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new conversationsModule.v2.ConversationsClient({ - 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 conversationsModule.v2.ConversationsClient({ - 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 conversationsModule.v2.ConversationsClient({ - 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 conversationsModule.v2.ConversationsClient({ - 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 conversationsModule.v2.ConversationsClient({ - 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 conversationsModule.v2.ConversationsClient({ - 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 conversationsModule.v2.ConversationsClient({ - 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 conversationsModule.v2.ConversationsClient({ - 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 conversationsModule.v2.ConversationsClient({ - 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 conversationsModule.v2.ConversationsClient({ - 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 conversationsModule.v2.ConversationsClient({ - 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('conversationDataset', () => { diff --git a/test/gapic_conversations_v2beta1.ts b/test/gapic_conversations_v2beta1.ts index 95d8a109..645e6507 100644 --- a/test/gapic_conversations_v2beta1.ts +++ b/test/gapic_conversations_v2beta1.ts @@ -25,7 +25,7 @@ import * as conversationsModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -1742,311 +1742,6 @@ describe('v2beta1.ConversationsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new conversationsModule.v2beta1.ConversationsClient({ - 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 conversationsModule.v2beta1.ConversationsClient({ - 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 conversationsModule.v2beta1.ConversationsClient({ - 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 conversationsModule.v2beta1.ConversationsClient({ - 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 conversationsModule.v2beta1.ConversationsClient({ - 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 conversationsModule.v2beta1.ConversationsClient({ - 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 conversationsModule.v2beta1.ConversationsClient({ - 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 conversationsModule.v2beta1.ConversationsClient({ - 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 conversationsModule.v2beta1.ConversationsClient({ - 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 conversationsModule.v2beta1.ConversationsClient({ - 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 conversationsModule.v2beta1.ConversationsClient({ - 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('project', () => { diff --git a/test/gapic_environments_v2.ts b/test/gapic_environments_v2.ts index 0d02c4b7..1b78f23d 100644 --- a/test/gapic_environments_v2.ts +++ b/test/gapic_environments_v2.ts @@ -25,7 +25,7 @@ import * as environmentsModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -1630,311 +1630,6 @@ describe('v2.EnvironmentsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new environmentsModule.v2.EnvironmentsClient({ - 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 environmentsModule.v2.EnvironmentsClient({ - 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 environmentsModule.v2.EnvironmentsClient({ - 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 environmentsModule.v2.EnvironmentsClient({ - 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 environmentsModule.v2.EnvironmentsClient({ - 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 environmentsModule.v2.EnvironmentsClient({ - 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 environmentsModule.v2.EnvironmentsClient({ - 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 environmentsModule.v2.EnvironmentsClient({ - 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 environmentsModule.v2.EnvironmentsClient({ - 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 environmentsModule.v2.EnvironmentsClient({ - 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 environmentsModule.v2.EnvironmentsClient({ - 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('conversationDataset', () => { diff --git a/test/gapic_environments_v2beta1.ts b/test/gapic_environments_v2beta1.ts index 71a8967d..d2e73e31 100644 --- a/test/gapic_environments_v2beta1.ts +++ b/test/gapic_environments_v2beta1.ts @@ -25,7 +25,7 @@ import * as environmentsModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -1638,311 +1638,6 @@ describe('v2beta1.EnvironmentsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new environmentsModule.v2beta1.EnvironmentsClient({ - 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 environmentsModule.v2beta1.EnvironmentsClient({ - 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 environmentsModule.v2beta1.EnvironmentsClient({ - 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 environmentsModule.v2beta1.EnvironmentsClient({ - 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 environmentsModule.v2beta1.EnvironmentsClient({ - 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 environmentsModule.v2beta1.EnvironmentsClient({ - 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 environmentsModule.v2beta1.EnvironmentsClient({ - 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 environmentsModule.v2beta1.EnvironmentsClient({ - 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 environmentsModule.v2beta1.EnvironmentsClient({ - 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 environmentsModule.v2beta1.EnvironmentsClient({ - 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 environmentsModule.v2beta1.EnvironmentsClient({ - 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('project', () => { diff --git a/test/gapic_fulfillments_v2.ts b/test/gapic_fulfillments_v2.ts index 5fbdaf18..5f7c1576 100644 --- a/test/gapic_fulfillments_v2.ts +++ b/test/gapic_fulfillments_v2.ts @@ -23,7 +23,7 @@ import {SinonStub} from 'sinon'; import {describe, it} from 'mocha'; import * as fulfillmentsModule from '../src'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -646,311 +646,6 @@ describe('v2.FulfillmentsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new fulfillmentsModule.v2.FulfillmentsClient({ - 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 fulfillmentsModule.v2.FulfillmentsClient({ - 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 fulfillmentsModule.v2.FulfillmentsClient({ - 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 fulfillmentsModule.v2.FulfillmentsClient({ - 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 fulfillmentsModule.v2.FulfillmentsClient({ - 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 fulfillmentsModule.v2.FulfillmentsClient({ - 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 fulfillmentsModule.v2.FulfillmentsClient({ - 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 fulfillmentsModule.v2.FulfillmentsClient({ - 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 fulfillmentsModule.v2.FulfillmentsClient({ - 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 fulfillmentsModule.v2.FulfillmentsClient({ - 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 fulfillmentsModule.v2.FulfillmentsClient({ - 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('conversationDataset', () => { diff --git a/test/gapic_fulfillments_v2beta1.ts b/test/gapic_fulfillments_v2beta1.ts index 95aa6d03..ab05ae45 100644 --- a/test/gapic_fulfillments_v2beta1.ts +++ b/test/gapic_fulfillments_v2beta1.ts @@ -23,7 +23,7 @@ import {SinonStub} from 'sinon'; import {describe, it} from 'mocha'; import * as fulfillmentsModule from '../src'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -648,311 +648,6 @@ describe('v2beta1.FulfillmentsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new fulfillmentsModule.v2beta1.FulfillmentsClient({ - 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 fulfillmentsModule.v2beta1.FulfillmentsClient({ - 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 fulfillmentsModule.v2beta1.FulfillmentsClient({ - 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 fulfillmentsModule.v2beta1.FulfillmentsClient({ - 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 fulfillmentsModule.v2beta1.FulfillmentsClient({ - 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 fulfillmentsModule.v2beta1.FulfillmentsClient({ - 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 fulfillmentsModule.v2beta1.FulfillmentsClient({ - 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 fulfillmentsModule.v2beta1.FulfillmentsClient({ - 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 fulfillmentsModule.v2beta1.FulfillmentsClient({ - 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 fulfillmentsModule.v2beta1.FulfillmentsClient({ - 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 fulfillmentsModule.v2beta1.FulfillmentsClient({ - 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('projectAgent', () => { diff --git a/test/gapic_knowledge_bases_v2.ts b/test/gapic_knowledge_bases_v2.ts index 71327f51..ccf54c46 100644 --- a/test/gapic_knowledge_bases_v2.ts +++ b/test/gapic_knowledge_bases_v2.ts @@ -25,7 +25,7 @@ import * as knowledgebasesModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -1278,311 +1278,6 @@ describe('v2.KnowledgeBasesClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new knowledgebasesModule.v2.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2.KnowledgeBasesClient({ - 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('conversationDataset', () => { diff --git a/test/gapic_knowledge_bases_v2beta1.ts b/test/gapic_knowledge_bases_v2beta1.ts index e9d3c836..d293127d 100644 --- a/test/gapic_knowledge_bases_v2beta1.ts +++ b/test/gapic_knowledge_bases_v2beta1.ts @@ -25,7 +25,7 @@ import * as knowledgebasesModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -1283,311 +1283,6 @@ describe('v2beta1.KnowledgeBasesClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new knowledgebasesModule.v2beta1.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2beta1.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2beta1.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2beta1.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2beta1.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2beta1.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2beta1.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2beta1.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2beta1.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2beta1.KnowledgeBasesClient({ - 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 knowledgebasesModule.v2beta1.KnowledgeBasesClient({ - 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('project', () => { diff --git a/test/gapic_participants_v2.ts b/test/gapic_participants_v2.ts index 4b9417fc..69998313 100644 --- a/test/gapic_participants_v2.ts +++ b/test/gapic_participants_v2.ts @@ -25,7 +25,7 @@ import * as participantsModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -66,6 +66,20 @@ function stubSimpleCallWithCallback( : sinon.stub().callsArgWith(2, null, response); } +function stubBidiStreamingCall( + response?: ResponseType, + error?: Error +) { + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + return sinon.stub().returns(mockStream); +} + function stubPageStreamingCall( responses?: ResponseType[], error?: Error @@ -1140,6 +1154,96 @@ describe('v2.ParticipantsClient', () => { }); }); + describe('streamingAnalyzeContent', () => { + it('invokes streamingAnalyzeContent without error', async () => { + const client = new participantsModule.v2.ParticipantsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest() + ); + + const expectedResponse = generateSampleMessage( + new protos.google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse() + ); + client.innerApiCalls.streamingAnalyzeContent = + stubBidiStreamingCall(expectedResponse); + const stream = client.streamingAnalyzeContent(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.streamingAnalyzeContent as SinonStub) + .getCall(0) + .calledWith(null) + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request + ); + }); + + it('invokes streamingAnalyzeContent with error', async () => { + const client = new participantsModule.v2.ParticipantsClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.dialogflow.v2.StreamingAnalyzeContentRequest() + ); + const expectedError = new Error('expected'); + client.innerApiCalls.streamingAnalyzeContent = stubBidiStreamingCall( + undefined, + expectedError + ); + const stream = client.streamingAnalyzeContent(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.dialogflow.v2.StreamingAnalyzeContentResponse + ) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.streamingAnalyzeContent as SinonStub) + .getCall(0) + .calledWith(null) + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request + ); + }); + }); + describe('listParticipants', () => { it('invokes listParticipants without error', async () => { const client = new participantsModule.v2.ParticipantsClient({ @@ -1662,311 +1766,6 @@ describe('v2.ParticipantsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new participantsModule.v2.ParticipantsClient({ - 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 participantsModule.v2.ParticipantsClient({ - 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 participantsModule.v2.ParticipantsClient({ - 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 participantsModule.v2.ParticipantsClient({ - 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 participantsModule.v2.ParticipantsClient({ - 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 participantsModule.v2.ParticipantsClient({ - 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 participantsModule.v2.ParticipantsClient({ - 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 participantsModule.v2.ParticipantsClient({ - 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 participantsModule.v2.ParticipantsClient({ - 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 participantsModule.v2.ParticipantsClient({ - 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 participantsModule.v2.ParticipantsClient({ - 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('conversationDataset', () => { diff --git a/test/gapic_participants_v2beta1.ts b/test/gapic_participants_v2beta1.ts index dc1e25e0..8c9a4a7e 100644 --- a/test/gapic_participants_v2beta1.ts +++ b/test/gapic_participants_v2beta1.ts @@ -25,7 +25,7 @@ import * as participantsModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -2255,311 +2255,6 @@ describe('v2beta1.ParticipantsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new participantsModule.v2beta1.ParticipantsClient({ - 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 participantsModule.v2beta1.ParticipantsClient({ - 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 participantsModule.v2beta1.ParticipantsClient({ - 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 participantsModule.v2beta1.ParticipantsClient({ - 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 participantsModule.v2beta1.ParticipantsClient({ - 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 participantsModule.v2beta1.ParticipantsClient({ - 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 participantsModule.v2beta1.ParticipantsClient({ - 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 participantsModule.v2beta1.ParticipantsClient({ - 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 participantsModule.v2beta1.ParticipantsClient({ - 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 participantsModule.v2beta1.ParticipantsClient({ - 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 participantsModule.v2beta1.ParticipantsClient({ - 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('project', () => { diff --git a/test/gapic_session_entity_types_v2.ts b/test/gapic_session_entity_types_v2.ts index 95f0176a..22cb7015 100644 --- a/test/gapic_session_entity_types_v2.ts +++ b/test/gapic_session_entity_types_v2.ts @@ -25,7 +25,7 @@ import * as sessionentitytypesModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -1325,311 +1325,6 @@ describe('v2.SessionEntityTypesClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new sessionentitytypesModule.v2.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2.SessionEntityTypesClient({ - 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('conversationDataset', () => { diff --git a/test/gapic_session_entity_types_v2beta1.ts b/test/gapic_session_entity_types_v2beta1.ts index e7a92f09..89eb1ded 100644 --- a/test/gapic_session_entity_types_v2beta1.ts +++ b/test/gapic_session_entity_types_v2beta1.ts @@ -25,7 +25,7 @@ import * as sessionentitytypesModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -1365,322 +1365,6 @@ describe('v2beta1.SessionEntityTypesClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = - new sessionentitytypesModule.v2beta1.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2beta1.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2beta1.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2beta1.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2beta1.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2beta1.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2beta1.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2beta1.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2beta1.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2beta1.SessionEntityTypesClient({ - 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 sessionentitytypesModule.v2beta1.SessionEntityTypesClient({ - 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('project', () => { diff --git a/test/gapic_sessions_v2.ts b/test/gapic_sessions_v2.ts index efa77015..2ef47007 100644 --- a/test/gapic_sessions_v2.ts +++ b/test/gapic_sessions_v2.ts @@ -25,7 +25,7 @@ import * as sessionsModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -618,311 +618,6 @@ describe('v2.SessionsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new sessionsModule.v2.SessionsClient({ - 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 sessionsModule.v2.SessionsClient({ - 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 sessionsModule.v2.SessionsClient({ - 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 sessionsModule.v2.SessionsClient({ - 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 sessionsModule.v2.SessionsClient({ - 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 sessionsModule.v2.SessionsClient({ - 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 sessionsModule.v2.SessionsClient({ - 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 sessionsModule.v2.SessionsClient({ - 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 sessionsModule.v2.SessionsClient({ - 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 sessionsModule.v2.SessionsClient({ - 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 sessionsModule.v2.SessionsClient({ - 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('conversationDataset', () => { diff --git a/test/gapic_sessions_v2beta1.ts b/test/gapic_sessions_v2beta1.ts index 2b0cd66a..afe209f9 100644 --- a/test/gapic_sessions_v2beta1.ts +++ b/test/gapic_sessions_v2beta1.ts @@ -25,7 +25,7 @@ import * as sessionsModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -618,311 +618,6 @@ describe('v2beta1.SessionsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new sessionsModule.v2beta1.SessionsClient({ - 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 sessionsModule.v2beta1.SessionsClient({ - 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 sessionsModule.v2beta1.SessionsClient({ - 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 sessionsModule.v2beta1.SessionsClient({ - 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 sessionsModule.v2beta1.SessionsClient({ - 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 sessionsModule.v2beta1.SessionsClient({ - 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 sessionsModule.v2beta1.SessionsClient({ - 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 sessionsModule.v2beta1.SessionsClient({ - 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 sessionsModule.v2beta1.SessionsClient({ - 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 sessionsModule.v2beta1.SessionsClient({ - 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 sessionsModule.v2beta1.SessionsClient({ - 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('projectAgent', () => { diff --git a/test/gapic_versions_v2.ts b/test/gapic_versions_v2.ts index 5e4cc90b..c23dd451 100644 --- a/test/gapic_versions_v2.ts +++ b/test/gapic_versions_v2.ts @@ -25,7 +25,7 @@ import * as versionsModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -1249,311 +1249,6 @@ describe('v2.VersionsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new versionsModule.v2.VersionsClient({ - 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 versionsModule.v2.VersionsClient({ - 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 versionsModule.v2.VersionsClient({ - 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 versionsModule.v2.VersionsClient({ - 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 versionsModule.v2.VersionsClient({ - 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 versionsModule.v2.VersionsClient({ - 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 versionsModule.v2.VersionsClient({ - 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 versionsModule.v2.VersionsClient({ - 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 versionsModule.v2.VersionsClient({ - 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 versionsModule.v2.VersionsClient({ - 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 versionsModule.v2.VersionsClient({ - 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('conversationDataset', () => { diff --git a/test/gapic_versions_v2beta1.ts b/test/gapic_versions_v2beta1.ts index 1ae77022..dcc811fd 100644 --- a/test/gapic_versions_v2beta1.ts +++ b/test/gapic_versions_v2beta1.ts @@ -25,7 +25,7 @@ import * as versionsModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, operationsProtos, LocationProtos} from 'google-gax'; +import {protobuf, LocationProtos} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects @@ -1273,311 +1273,6 @@ describe('v2beta1.VersionsClient', () => { ); }); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new versionsModule.v2beta1.VersionsClient({ - 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 versionsModule.v2beta1.VersionsClient({ - 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 versionsModule.v2beta1.VersionsClient({ - 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 versionsModule.v2beta1.VersionsClient({ - 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 versionsModule.v2beta1.VersionsClient({ - 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 versionsModule.v2beta1.VersionsClient({ - 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 versionsModule.v2beta1.VersionsClient({ - 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 versionsModule.v2beta1.VersionsClient({ - 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 versionsModule.v2beta1.VersionsClient({ - 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 versionsModule.v2beta1.VersionsClient({ - 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 versionsModule.v2beta1.VersionsClient({ - 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('project', () => {