diff --git a/packages/google-cloud-dialogflow-cx/README.md b/packages/google-cloud-dialogflow-cx/README.md index fb1b9dc03fe..fb9732c014c 100644 --- a/packages/google-cloud-dialogflow-cx/README.md +++ b/packages/google-cloud-dialogflow-cx/README.md @@ -44,7 +44,7 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained]. 1. [Select or create a Cloud Platform project][projects]. 1. [Enable billing for your project][billing]. 1. [Enable the Dialogflow CX API API][enable_api]. -1. [Set up authentication][auth] so you can access the +1. [Set up authentication with a service account][auth] so you can access the API from your local workstation. ### Installing the client library @@ -456,4 +456,4 @@ See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/LICENSE) [projects]: https://console.cloud.google.com/project [billing]: https://support.google.com/cloud/answer/6293499#enable-billing [enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=dialogflow.googleapis.com -[auth]: https://cloud.google.com/docs/authentication/external/set-up-adc-local +[auth]: https://cloud.google.com/docs/authentication/getting-started diff --git a/packages/google-cloud-dialogflow-cx/protos/google/cloud/dialogflow/cx/v3beta1/tool.proto b/packages/google-cloud-dialogflow-cx/protos/google/cloud/dialogflow/cx/v3beta1/tool.proto index 0d52864492a..4f28d424dd6 100644 --- a/packages/google-cloud-dialogflow-cx/protos/google/cloud/dialogflow/cx/v3beta1/tool.proto +++ b/packages/google-cloud-dialogflow-cx/protos/google/cloud/dialogflow/cx/v3beta1/tool.proto @@ -437,7 +437,7 @@ message Tool { } // Required. The full resource name of the referenced Integration Connectors - // Connection. Format: 'projects/*/locations/*/connections/*' + // Connection. Format: `projects/*/locations/*/connections/*` string name = 1 [(google.api.field_behavior) = REQUIRED]; // Required. Actions for the tool to use. @@ -593,11 +593,14 @@ message Tool { // is empty or unspecified, Dialogflow will use Google's default trust // store to verify certificates. N.B. Make sure the HTTPS server // certificates are signed with "subject alt name". For instance a - // certificate can be self-signed using the following command, + // certificate can be self-signed using the following command: + // + // ``` // openssl x509 -req -days 200 -in example.com.csr \ // -signkey example.com.key \ // -out example.com.crt \ // -extfile <(printf "\nsubjectAltName='DNS:www.example.com'") + // ``` bytes cert = 2 [(google.api.field_behavior) = REQUIRED]; } diff --git a/packages/google-cloud-dialogflow-cx/protos/protos.json b/packages/google-cloud-dialogflow-cx/protos/protos.json index c044995d71c..097ce47314d 100644 --- a/packages/google-cloud-dialogflow-cx/protos/protos.json +++ b/packages/google-cloud-dialogflow-cx/protos/protos.json @@ -1,7 +1,4 @@ { - "options": { - "syntax": "proto3" - }, "nested": { "google": { "nested": { diff --git a/packages/google-cloud-dialogflow-cx/src/v3/agents_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/agents_client.ts index be34d312358..c8ba8f81ce3 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/agents_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/agents_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -57,6 +58,8 @@ export class AgentsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -93,7 +96,7 @@ export class AgentsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -636,7 +639,33 @@ export class AgentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getAgent(request, options, callback); + this._log.info('getAgent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IAgent, + | protos.google.cloud.dialogflow.cx.v3.IGetAgentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getAgent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getAgent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IAgent, + protos.google.cloud.dialogflow.cx.v3.IGetAgentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getAgent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates an agent in the specified location. @@ -733,7 +762,33 @@ export class AgentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createAgent(request, options, callback); + this._log.info('createAgent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IAgent, + | protos.google.cloud.dialogflow.cx.v3.ICreateAgentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createAgent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createAgent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IAgent, + protos.google.cloud.dialogflow.cx.v3.ICreateAgentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createAgent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified agent. @@ -830,7 +885,33 @@ export class AgentsClient { 'agent.name': request.agent!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateAgent(request, options, callback); + this._log.info('updateAgent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IAgent, + | protos.google.cloud.dialogflow.cx.v3.IUpdateAgentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateAgent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateAgent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IAgent, + protos.google.cloud.dialogflow.cx.v3.IUpdateAgentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateAgent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified agent. @@ -921,7 +1002,33 @@ export class AgentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteAgent(request, options, callback); + this._log.info('deleteAgent request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3.IDeleteAgentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteAgent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteAgent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.dialogflow.cx.v3.IDeleteAgentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteAgent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Validates the specified agent and creates or updates validation results. @@ -1016,7 +1123,36 @@ export class AgentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.validateAgent(request, options, callback); + this._log.info('validateAgent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IAgentValidationResult, + | protos.google.cloud.dialogflow.cx.v3.IValidateAgentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('validateAgent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .validateAgent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IAgentValidationResult, + ( + | protos.google.cloud.dialogflow.cx.v3.IValidateAgentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('validateAgent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Gets the latest agent validation result. Agent validation is performed @@ -1117,11 +1253,36 @@ export class AgentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getAgentValidationResult( - request, - options, - callback - ); + this._log.info('getAgentValidationResult request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IAgentValidationResult, + | protos.google.cloud.dialogflow.cx.v3.IGetAgentValidationResultRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getAgentValidationResult response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getAgentValidationResult(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IAgentValidationResult, + ( + | protos.google.cloud.dialogflow.cx.v3.IGetAgentValidationResultRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAgentValidationResult response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Gets the generative settings for the agent. @@ -1220,7 +1381,36 @@ export class AgentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getGenerativeSettings(request, options, callback); + this._log.info('getGenerativeSettings request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IGenerativeSettings, + | protos.google.cloud.dialogflow.cx.v3.IGetGenerativeSettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getGenerativeSettings response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getGenerativeSettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IGenerativeSettings, + ( + | protos.google.cloud.dialogflow.cx.v3.IGetGenerativeSettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getGenerativeSettings response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the generative settings for the agent. @@ -1319,11 +1509,36 @@ export class AgentsClient { 'generative_settings.name': request.generativeSettings!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateGenerativeSettings( - request, - options, - callback - ); + this._log.info('updateGenerativeSettings request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IGenerativeSettings, + | protos.google.cloud.dialogflow.cx.v3.IUpdateGenerativeSettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateGenerativeSettings response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateGenerativeSettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IGenerativeSettings, + ( + | protos.google.cloud.dialogflow.cx.v3.IUpdateGenerativeSettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateGenerativeSettings response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1458,7 +1673,37 @@ export class AgentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.exportAgent(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IExportAgentResponse, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('exportAgent response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('exportAgent request %j', request); + return this.innerApiCalls + .exportAgent(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IExportAgentResponse, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportAgent response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `exportAgent()`. @@ -1479,6 +1724,7 @@ export class AgentsClient { protos.google.protobuf.Struct > > { + this._log.info('exportAgent long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1627,7 +1873,37 @@ export class AgentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.restoreAgent(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('restoreAgent response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('restoreAgent request %j', request); + return this.innerApiCalls + .restoreAgent(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('restoreAgent response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `restoreAgent()`. @@ -1645,6 +1921,7 @@ export class AgentsClient { ): Promise< LROperation > { + this._log.info('restoreAgent long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1757,7 +2034,33 @@ export class AgentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listAgents(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListAgentsRequest, + | protos.google.cloud.dialogflow.cx.v3.IListAgentsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.IAgent + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listAgents values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listAgents request %j', request); + return this.innerApiCalls + .listAgents(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.IAgent[], + protos.google.cloud.dialogflow.cx.v3.IListAgentsRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListAgentsResponse, + ]) => { + this._log.info('listAgents values %j', response); + return [response, input, output]; + } + ); } /** @@ -1798,6 +2101,7 @@ export class AgentsClient { const defaultCallSettings = this._defaults['listAgents']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listAgents stream %j', request); return this.descriptors.page.listAgents.createStream( this.innerApiCalls.listAgents as GaxCall, request, @@ -1846,6 +2150,7 @@ export class AgentsClient { const defaultCallSettings = this._defaults['listAgents']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listAgents iterate %j', request); return this.descriptors.page.listAgents.asyncIterate( this.innerApiCalls['listAgents'] as GaxCall, request as {}, @@ -4004,6 +4309,7 @@ export class AgentsClient { close(): Promise { if (this.agentsStub && !this._terminated) { return this.agentsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/changelogs_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/changelogs_client.ts index 2059e626123..227973a6272 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/changelogs_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/changelogs_client.ts @@ -32,6 +32,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class ChangelogsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -92,7 +95,7 @@ export class ChangelogsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -604,7 +607,33 @@ export class ChangelogsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getChangelog(request, options, callback); + this._log.info('getChangelog request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IChangelog, + | protos.google.cloud.dialogflow.cx.v3.IGetChangelogRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getChangelog response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getChangelog(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IChangelog, + protos.google.cloud.dialogflow.cx.v3.IGetChangelogRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getChangelog response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -725,7 +754,33 @@ export class ChangelogsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listChangelogs(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListChangelogsRequest, + | protos.google.cloud.dialogflow.cx.v3.IListChangelogsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.IChangelog + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listChangelogs values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listChangelogs request %j', request); + return this.innerApiCalls + .listChangelogs(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.IChangelog[], + protos.google.cloud.dialogflow.cx.v3.IListChangelogsRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListChangelogsResponse, + ]) => { + this._log.info('listChangelogs values %j', response); + return [response, input, output]; + } + ); } /** @@ -787,6 +842,7 @@ export class ChangelogsClient { const defaultCallSettings = this._defaults['listChangelogs']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listChangelogs stream %j', request); return this.descriptors.page.listChangelogs.createStream( this.innerApiCalls.listChangelogs as GaxCall, request, @@ -856,6 +912,7 @@ export class ChangelogsClient { const defaultCallSettings = this._defaults['listChangelogs']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listChangelogs iterate %j', request); return this.descriptors.page.listChangelogs.asyncIterate( this.innerApiCalls['listChangelogs'] as GaxCall, request as {}, @@ -3014,6 +3071,7 @@ export class ChangelogsClient { close(): Promise { if (this.changelogsStub && !this._terminated) { return this.changelogsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/deployments_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/deployments_client.ts index 291d0e9770b..5a2a1db899a 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/deployments_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/deployments_client.ts @@ -32,6 +32,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class DeploymentsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -92,7 +95,7 @@ export class DeploymentsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -605,7 +608,36 @@ export class DeploymentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getDeployment(request, options, callback); + this._log.info('getDeployment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IDeployment, + | protos.google.cloud.dialogflow.cx.v3.IGetDeploymentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getDeployment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getDeployment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IDeployment, + ( + | protos.google.cloud.dialogflow.cx.v3.IGetDeploymentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getDeployment response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -707,7 +739,33 @@ export class DeploymentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listDeployments(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListDeploymentsRequest, + | protos.google.cloud.dialogflow.cx.v3.IListDeploymentsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.IDeployment + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listDeployments values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listDeployments request %j', request); + return this.innerApiCalls + .listDeployments(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.IDeployment[], + protos.google.cloud.dialogflow.cx.v3.IListDeploymentsRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListDeploymentsResponse, + ]) => { + this._log.info('listDeployments values %j', response); + return [response, input, output]; + } + ); } /** @@ -749,6 +807,7 @@ export class DeploymentsClient { const defaultCallSettings = this._defaults['listDeployments']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listDeployments stream %j', request); return this.descriptors.page.listDeployments.createStream( this.innerApiCalls.listDeployments as GaxCall, request, @@ -798,6 +857,7 @@ export class DeploymentsClient { const defaultCallSettings = this._defaults['listDeployments']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listDeployments iterate %j', request); return this.descriptors.page.listDeployments.asyncIterate( this.innerApiCalls['listDeployments'] as GaxCall, request as {}, @@ -2956,6 +3016,7 @@ export class DeploymentsClient { close(): Promise { if (this.deploymentsStub && !this._terminated) { return this.deploymentsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/entity_types_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/entity_types_client.ts index 9f8b04768c3..47cb69da6d7 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/entity_types_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/entity_types_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -57,6 +58,8 @@ export class EntityTypesClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -93,7 +96,7 @@ export class EntityTypesClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -652,7 +655,36 @@ export class EntityTypesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getEntityType(request, options, callback); + this._log.info('getEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IEntityType, + | protos.google.cloud.dialogflow.cx.v3.IGetEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IEntityType, + ( + | protos.google.cloud.dialogflow.cx.v3.IGetEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates an entity type in the specified agent. @@ -761,7 +793,36 @@ export class EntityTypesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createEntityType(request, options, callback); + this._log.info('createEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IEntityType, + | protos.google.cloud.dialogflow.cx.v3.ICreateEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IEntityType, + ( + | protos.google.cloud.dialogflow.cx.v3.ICreateEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified entity type. @@ -869,7 +930,36 @@ export class EntityTypesClient { 'entity_type.name': request.entityType!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateEntityType(request, options, callback); + this._log.info('updateEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IEntityType, + | protos.google.cloud.dialogflow.cx.v3.IUpdateEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IEntityType, + ( + | protos.google.cloud.dialogflow.cx.v3.IUpdateEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified entity type. @@ -978,7 +1068,36 @@ export class EntityTypesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteEntityType(request, options, callback); + this._log.info('deleteEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3.IDeleteEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3.IDeleteEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1115,7 +1234,37 @@ export class EntityTypesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.exportEntityTypes(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IExportEntityTypesResponse, + protos.google.cloud.dialogflow.cx.v3.IExportEntityTypesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('exportEntityTypes response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('exportEntityTypes request %j', request); + return this.innerApiCalls + .exportEntityTypes(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IExportEntityTypesResponse, + protos.google.cloud.dialogflow.cx.v3.IExportEntityTypesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportEntityTypes response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `exportEntityTypes()`. @@ -1136,6 +1285,7 @@ export class EntityTypesClient { protos.google.cloud.dialogflow.cx.v3.ExportEntityTypesMetadata > > { + this._log.info('exportEntityTypes long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1275,7 +1425,37 @@ export class EntityTypesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.importEntityTypes(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IImportEntityTypesResponse, + protos.google.cloud.dialogflow.cx.v3.IImportEntityTypesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('importEntityTypes response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('importEntityTypes request %j', request); + return this.innerApiCalls + .importEntityTypes(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IImportEntityTypesResponse, + protos.google.cloud.dialogflow.cx.v3.IImportEntityTypesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('importEntityTypes response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `importEntityTypes()`. @@ -1296,6 +1476,7 @@ export class EntityTypesClient { protos.google.cloud.dialogflow.cx.v3.ImportEntityTypesMetadata > > { + this._log.info('importEntityTypes long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1421,7 +1602,33 @@ export class EntityTypesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listEntityTypes(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListEntityTypesRequest, + | protos.google.cloud.dialogflow.cx.v3.IListEntityTypesResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.IEntityType + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listEntityTypes values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listEntityTypes request %j', request); + return this.innerApiCalls + .listEntityTypes(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.IEntityType[], + protos.google.cloud.dialogflow.cx.v3.IListEntityTypesRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListEntityTypesResponse, + ]) => { + this._log.info('listEntityTypes values %j', response); + return [response, input, output]; + } + ); } /** @@ -1475,6 +1682,7 @@ export class EntityTypesClient { const defaultCallSettings = this._defaults['listEntityTypes']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listEntityTypes stream %j', request); return this.descriptors.page.listEntityTypes.createStream( this.innerApiCalls.listEntityTypes as GaxCall, request, @@ -1536,6 +1744,7 @@ export class EntityTypesClient { const defaultCallSettings = this._defaults['listEntityTypes']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listEntityTypes iterate %j', request); return this.descriptors.page.listEntityTypes.asyncIterate( this.innerApiCalls['listEntityTypes'] as GaxCall, request as {}, @@ -3694,6 +3903,7 @@ export class EntityTypesClient { close(): Promise { if (this.entityTypesStub && !this._terminated) { return this.entityTypesStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/environments_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/environments_client.ts index d31c6e0e48b..1e953f6d102 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/environments_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/environments_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -58,6 +59,8 @@ export class EnvironmentsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -94,7 +97,7 @@ export class EnvironmentsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -675,7 +678,36 @@ export class EnvironmentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getEnvironment(request, options, callback); + this._log.info('getEnvironment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IEnvironment, + | protos.google.cloud.dialogflow.cx.v3.IGetEnvironmentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getEnvironment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getEnvironment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IEnvironment, + ( + | protos.google.cloud.dialogflow.cx.v3.IGetEnvironmentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getEnvironment response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified @@ -774,7 +806,36 @@ export class EnvironmentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteEnvironment(request, options, callback); + this._log.info('deleteEnvironment request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3.IDeleteEnvironmentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteEnvironment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteEnvironment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3.IDeleteEnvironmentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteEnvironment response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -890,7 +951,37 @@ export class EnvironmentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createEnvironment(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IEnvironment, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('createEnvironment response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('createEnvironment request %j', request); + return this.innerApiCalls + .createEnvironment(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IEnvironment, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createEnvironment response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `createEnvironment()`. @@ -911,6 +1002,7 @@ export class EnvironmentsClient { protos.google.protobuf.Struct > > { + this._log.info('createEnvironment long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1037,7 +1129,37 @@ export class EnvironmentsClient { 'environment.name': request.environment!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateEnvironment(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IEnvironment, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('updateEnvironment response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('updateEnvironment request %j', request); + return this.innerApiCalls + .updateEnvironment(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IEnvironment, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateEnvironment response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `updateEnvironment()`. @@ -1058,6 +1180,7 @@ export class EnvironmentsClient { protos.google.protobuf.Struct > > { + this._log.info('updateEnvironment long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1184,7 +1307,37 @@ export class EnvironmentsClient { environment: request.environment ?? '', }); this.initialize(); - return this.innerApiCalls.runContinuousTest(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IRunContinuousTestResponse, + protos.google.cloud.dialogflow.cx.v3.IRunContinuousTestMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('runContinuousTest response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('runContinuousTest request %j', request); + return this.innerApiCalls + .runContinuousTest(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IRunContinuousTestResponse, + protos.google.cloud.dialogflow.cx.v3.IRunContinuousTestMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('runContinuousTest response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `runContinuousTest()`. @@ -1205,6 +1358,7 @@ export class EnvironmentsClient { protos.google.cloud.dialogflow.cx.v3.RunContinuousTestMetadata > > { + this._log.info('runContinuousTest long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1336,7 +1490,37 @@ export class EnvironmentsClient { environment: request.environment ?? '', }); this.initialize(); - return this.innerApiCalls.deployFlow(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IDeployFlowResponse, + protos.google.cloud.dialogflow.cx.v3.IDeployFlowMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('deployFlow response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('deployFlow request %j', request); + return this.innerApiCalls + .deployFlow(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IDeployFlowResponse, + protos.google.cloud.dialogflow.cx.v3.IDeployFlowMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deployFlow response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `deployFlow()`. @@ -1357,6 +1541,7 @@ export class EnvironmentsClient { protos.google.cloud.dialogflow.cx.v3.DeployFlowMetadata > > { + this._log.info('deployFlow long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1471,7 +1656,33 @@ export class EnvironmentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listEnvironments(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListEnvironmentsRequest, + | protos.google.cloud.dialogflow.cx.v3.IListEnvironmentsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.IEnvironment + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listEnvironments values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listEnvironments request %j', request); + return this.innerApiCalls + .listEnvironments(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.IEnvironment[], + protos.google.cloud.dialogflow.cx.v3.IListEnvironmentsRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListEnvironmentsResponse, + ]) => { + this._log.info('listEnvironments values %j', response); + return [response, input, output]; + } + ); } /** @@ -1513,6 +1724,7 @@ export class EnvironmentsClient { const defaultCallSettings = this._defaults['listEnvironments']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listEnvironments stream %j', request); return this.descriptors.page.listEnvironments.createStream( this.innerApiCalls.listEnvironments as GaxCall, request, @@ -1562,6 +1774,7 @@ export class EnvironmentsClient { const defaultCallSettings = this._defaults['listEnvironments']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listEnvironments iterate %j', request); return this.descriptors.page.listEnvironments.asyncIterate( this.innerApiCalls['listEnvironments'] as GaxCall, request as {}, @@ -1667,11 +1880,33 @@ export class EnvironmentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.lookupEnvironmentHistory( - request, - options, - callback - ); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.ILookupEnvironmentHistoryRequest, + | protos.google.cloud.dialogflow.cx.v3.ILookupEnvironmentHistoryResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.IEnvironment + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('lookupEnvironmentHistory values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('lookupEnvironmentHistory request %j', request); + return this.innerApiCalls + .lookupEnvironmentHistory(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.IEnvironment[], + protos.google.cloud.dialogflow.cx.v3.ILookupEnvironmentHistoryRequest | null, + protos.google.cloud.dialogflow.cx.v3.ILookupEnvironmentHistoryResponse, + ]) => { + this._log.info('lookupEnvironmentHistory values %j', response); + return [response, input, output]; + } + ); } /** @@ -1713,6 +1948,7 @@ export class EnvironmentsClient { const defaultCallSettings = this._defaults['lookupEnvironmentHistory']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('lookupEnvironmentHistory stream %j', request); return this.descriptors.page.lookupEnvironmentHistory.createStream( this.innerApiCalls.lookupEnvironmentHistory as GaxCall, request, @@ -1762,6 +1998,7 @@ export class EnvironmentsClient { const defaultCallSettings = this._defaults['lookupEnvironmentHistory']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('lookupEnvironmentHistory iterate %j', request); return this.descriptors.page.lookupEnvironmentHistory.asyncIterate( this.innerApiCalls['lookupEnvironmentHistory'] as GaxCall, request as {}, @@ -1866,11 +2103,33 @@ export class EnvironmentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listContinuousTestResults( - request, - options, - callback - ); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListContinuousTestResultsRequest, + | protos.google.cloud.dialogflow.cx.v3.IListContinuousTestResultsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.IContinuousTestResult + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listContinuousTestResults values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listContinuousTestResults request %j', request); + return this.innerApiCalls + .listContinuousTestResults(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.IContinuousTestResult[], + protos.google.cloud.dialogflow.cx.v3.IListContinuousTestResultsRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListContinuousTestResultsResponse, + ]) => { + this._log.info('listContinuousTestResults values %j', response); + return [response, input, output]; + } + ); } /** @@ -1912,6 +2171,7 @@ export class EnvironmentsClient { const defaultCallSettings = this._defaults['listContinuousTestResults']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listContinuousTestResults stream %j', request); return this.descriptors.page.listContinuousTestResults.createStream( this.innerApiCalls.listContinuousTestResults as GaxCall, request, @@ -1961,6 +2221,7 @@ export class EnvironmentsClient { const defaultCallSettings = this._defaults['listContinuousTestResults']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listContinuousTestResults iterate %j', request); return this.descriptors.page.listContinuousTestResults.asyncIterate( this.innerApiCalls['listContinuousTestResults'] as GaxCall, request as {}, @@ -4119,6 +4380,7 @@ export class EnvironmentsClient { close(): Promise { if (this.environmentsStub && !this._terminated) { return this.environmentsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/experiments_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/experiments_client.ts index 18ff72f6da3..c6f9b05d83b 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/experiments_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/experiments_client.ts @@ -32,6 +32,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class ExperimentsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -92,7 +95,7 @@ export class ExperimentsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -613,7 +616,36 @@ export class ExperimentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getExperiment(request, options, callback); + this._log.info('getExperiment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IExperiment, + | protos.google.cloud.dialogflow.cx.v3.IGetExperimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getExperiment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getExperiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IExperiment, + ( + | protos.google.cloud.dialogflow.cx.v3.IGetExperimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getExperiment response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates an {@link protos.google.cloud.dialogflow.cx.v3.Experiment|Experiment} in the @@ -708,7 +740,36 @@ export class ExperimentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createExperiment(request, options, callback); + this._log.info('createExperiment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IExperiment, + | protos.google.cloud.dialogflow.cx.v3.ICreateExperimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createExperiment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createExperiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IExperiment, + ( + | protos.google.cloud.dialogflow.cx.v3.ICreateExperimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createExperiment response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified @@ -801,7 +862,36 @@ export class ExperimentsClient { 'experiment.name': request.experiment!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateExperiment(request, options, callback); + this._log.info('updateExperiment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IExperiment, + | protos.google.cloud.dialogflow.cx.v3.IUpdateExperimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateExperiment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateExperiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IExperiment, + ( + | protos.google.cloud.dialogflow.cx.v3.IUpdateExperimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateExperiment response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified @@ -894,7 +984,36 @@ export class ExperimentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteExperiment(request, options, callback); + this._log.info('deleteExperiment request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3.IDeleteExperimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteExperiment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteExperiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3.IDeleteExperimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteExperiment response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Starts the specified @@ -988,7 +1107,36 @@ export class ExperimentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.startExperiment(request, options, callback); + this._log.info('startExperiment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IExperiment, + | protos.google.cloud.dialogflow.cx.v3.IStartExperimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('startExperiment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .startExperiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IExperiment, + ( + | protos.google.cloud.dialogflow.cx.v3.IStartExperimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('startExperiment response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Stops the specified {@link protos.google.cloud.dialogflow.cx.v3.Experiment|Experiment}. @@ -1081,7 +1229,36 @@ export class ExperimentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.stopExperiment(request, options, callback); + this._log.info('stopExperiment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IExperiment, + | protos.google.cloud.dialogflow.cx.v3.IStopExperimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('stopExperiment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .stopExperiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IExperiment, + ( + | protos.google.cloud.dialogflow.cx.v3.IStopExperimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('stopExperiment response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1183,7 +1360,33 @@ export class ExperimentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listExperiments(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListExperimentsRequest, + | protos.google.cloud.dialogflow.cx.v3.IListExperimentsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.IExperiment + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listExperiments values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listExperiments request %j', request); + return this.innerApiCalls + .listExperiments(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.IExperiment[], + protos.google.cloud.dialogflow.cx.v3.IListExperimentsRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListExperimentsResponse, + ]) => { + this._log.info('listExperiments values %j', response); + return [response, input, output]; + } + ); } /** @@ -1225,6 +1428,7 @@ export class ExperimentsClient { const defaultCallSettings = this._defaults['listExperiments']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listExperiments stream %j', request); return this.descriptors.page.listExperiments.createStream( this.innerApiCalls.listExperiments as GaxCall, request, @@ -1274,6 +1478,7 @@ export class ExperimentsClient { const defaultCallSettings = this._defaults['listExperiments']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listExperiments iterate %j', request); return this.descriptors.page.listExperiments.asyncIterate( this.innerApiCalls['listExperiments'] as GaxCall, request as {}, @@ -3432,6 +3637,7 @@ export class ExperimentsClient { close(): Promise { if (this.experimentsStub && !this._terminated) { return this.experimentsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/flows_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/flows_client.ts index 19dcd872a6c..31500edf14e 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/flows_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/flows_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -57,6 +58,8 @@ export class FlowsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -93,7 +96,7 @@ export class FlowsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -671,7 +674,33 @@ export class FlowsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createFlow(request, options, callback); + this._log.info('createFlow request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IFlow, + | protos.google.cloud.dialogflow.cx.v3.ICreateFlowRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createFlow response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createFlow(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IFlow, + protos.google.cloud.dialogflow.cx.v3.ICreateFlowRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createFlow response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes a specified flow. @@ -774,7 +803,33 @@ export class FlowsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteFlow(request, options, callback); + this._log.info('deleteFlow request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3.IDeleteFlowRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteFlow response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteFlow(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.dialogflow.cx.v3.IDeleteFlowRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteFlow response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Retrieves the specified flow. @@ -874,7 +929,33 @@ export class FlowsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getFlow(request, options, callback); + this._log.info('getFlow request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IFlow, + | protos.google.cloud.dialogflow.cx.v3.IGetFlowRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getFlow response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getFlow(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IFlow, + protos.google.cloud.dialogflow.cx.v3.IGetFlowRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getFlow response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified flow. @@ -984,7 +1065,33 @@ export class FlowsClient { 'flow.name': request.flow!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateFlow(request, options, callback); + this._log.info('updateFlow request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IFlow, + | protos.google.cloud.dialogflow.cx.v3.IUpdateFlowRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateFlow response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateFlow(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IFlow, + protos.google.cloud.dialogflow.cx.v3.IUpdateFlowRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateFlow response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Validates the specified flow and creates or updates validation results. @@ -1080,7 +1187,33 @@ export class FlowsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.validateFlow(request, options, callback); + this._log.info('validateFlow request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IFlowValidationResult, + | protos.google.cloud.dialogflow.cx.v3.IValidateFlowRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('validateFlow response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .validateFlow(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IFlowValidationResult, + protos.google.cloud.dialogflow.cx.v3.IValidateFlowRequest | undefined, + {} | undefined, + ]) => { + this._log.info('validateFlow response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Gets the latest flow validation result. Flow validation is performed @@ -1181,11 +1314,36 @@ export class FlowsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getFlowValidationResult( - request, - options, - callback - ); + this._log.info('getFlowValidationResult request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IFlowValidationResult, + | protos.google.cloud.dialogflow.cx.v3.IGetFlowValidationResultRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getFlowValidationResult response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getFlowValidationResult(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IFlowValidationResult, + ( + | protos.google.cloud.dialogflow.cx.v3.IGetFlowValidationResultRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getFlowValidationResult response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1304,7 +1462,37 @@ export class FlowsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.trainFlow(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('trainFlow response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('trainFlow request %j', request); + return this.innerApiCalls + .trainFlow(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('trainFlow response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `trainFlow()`. @@ -1322,6 +1510,7 @@ export class FlowsClient { ): Promise< LROperation > { + this._log.info('trainFlow long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1468,7 +1657,37 @@ export class FlowsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.importFlow(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IImportFlowResponse, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('importFlow response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('importFlow request %j', request); + return this.innerApiCalls + .importFlow(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IImportFlowResponse, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('importFlow response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `importFlow()`. @@ -1489,6 +1708,7 @@ export class FlowsClient { protos.google.protobuf.Struct > > { + this._log.info('importFlow long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1631,7 +1851,37 @@ export class FlowsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.exportFlow(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IExportFlowResponse, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('exportFlow response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('exportFlow request %j', request); + return this.innerApiCalls + .exportFlow(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IExportFlowResponse, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportFlow response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `exportFlow()`. @@ -1652,6 +1902,7 @@ export class FlowsClient { protos.google.protobuf.Struct > > { + this._log.info('exportFlow long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1778,7 +2029,33 @@ export class FlowsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listFlows(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListFlowsRequest, + | protos.google.cloud.dialogflow.cx.v3.IListFlowsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.IFlow + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listFlows values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listFlows request %j', request); + return this.innerApiCalls + .listFlows(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.IFlow[], + protos.google.cloud.dialogflow.cx.v3.IListFlowsRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListFlowsResponse, + ]) => { + this._log.info('listFlows values %j', response); + return [response, input, output]; + } + ); } /** @@ -1833,6 +2110,7 @@ export class FlowsClient { const defaultCallSettings = this._defaults['listFlows']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listFlows stream %j', request); return this.descriptors.page.listFlows.createStream( this.innerApiCalls.listFlows as GaxCall, request, @@ -1895,6 +2173,7 @@ export class FlowsClient { const defaultCallSettings = this._defaults['listFlows']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listFlows iterate %j', request); return this.descriptors.page.listFlows.asyncIterate( this.innerApiCalls['listFlows'] as GaxCall, request as {}, @@ -4053,6 +4332,7 @@ export class FlowsClient { close(): Promise { if (this.flowsStub && !this._terminated) { return this.flowsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/generators_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/generators_client.ts index 572f454a51b..0ee99aefeb9 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/generators_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/generators_client.ts @@ -32,6 +32,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class GeneratorsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -92,7 +95,7 @@ export class GeneratorsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -612,7 +615,33 @@ export class GeneratorsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getGenerator(request, options, callback); + this._log.info('getGenerator request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IGenerator, + | protos.google.cloud.dialogflow.cx.v3.IGetGeneratorRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getGenerator response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getGenerator(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IGenerator, + protos.google.cloud.dialogflow.cx.v3.IGetGeneratorRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getGenerator response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates a generator in the specified agent. @@ -709,7 +738,36 @@ export class GeneratorsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createGenerator(request, options, callback); + this._log.info('createGenerator request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IGenerator, + | protos.google.cloud.dialogflow.cx.v3.ICreateGeneratorRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createGenerator response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createGenerator(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IGenerator, + ( + | protos.google.cloud.dialogflow.cx.v3.ICreateGeneratorRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createGenerator response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Update the specified generator. @@ -804,7 +862,36 @@ export class GeneratorsClient { 'generator.name': request.generator!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateGenerator(request, options, callback); + this._log.info('updateGenerator request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IGenerator, + | protos.google.cloud.dialogflow.cx.v3.IUpdateGeneratorRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateGenerator response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateGenerator(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IGenerator, + ( + | protos.google.cloud.dialogflow.cx.v3.IUpdateGeneratorRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateGenerator response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified generators. @@ -905,7 +992,36 @@ export class GeneratorsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteGenerator(request, options, callback); + this._log.info('deleteGenerator request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3.IDeleteGeneratorRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteGenerator response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteGenerator(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3.IDeleteGeneratorRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteGenerator response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1007,7 +1123,33 @@ export class GeneratorsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listGenerators(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListGeneratorsRequest, + | protos.google.cloud.dialogflow.cx.v3.IListGeneratorsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.IGenerator + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listGenerators values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listGenerators request %j', request); + return this.innerApiCalls + .listGenerators(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.IGenerator[], + protos.google.cloud.dialogflow.cx.v3.IListGeneratorsRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListGeneratorsResponse, + ]) => { + this._log.info('listGenerators values %j', response); + return [response, input, output]; + } + ); } /** @@ -1050,6 +1192,7 @@ export class GeneratorsClient { const defaultCallSettings = this._defaults['listGenerators']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listGenerators stream %j', request); return this.descriptors.page.listGenerators.createStream( this.innerApiCalls.listGenerators as GaxCall, request, @@ -1100,6 +1243,7 @@ export class GeneratorsClient { const defaultCallSettings = this._defaults['listGenerators']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listGenerators iterate %j', request); return this.descriptors.page.listGenerators.asyncIterate( this.innerApiCalls['listGenerators'] as GaxCall, request as {}, @@ -3258,6 +3402,7 @@ export class GeneratorsClient { close(): Promise { if (this.generatorsStub && !this._terminated) { return this.generatorsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/intents_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/intents_client.ts index 4ba3c367e1e..a66bd695b4f 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/intents_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/intents_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -57,6 +58,8 @@ export class IntentsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -93,7 +96,7 @@ export class IntentsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -644,7 +647,33 @@ export class IntentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getIntent(request, options, callback); + this._log.info('getIntent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IIntent, + | protos.google.cloud.dialogflow.cx.v3.IGetIntentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getIntent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getIntent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IIntent, + protos.google.cloud.dialogflow.cx.v3.IGetIntentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getIntent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates an intent in the specified agent. @@ -751,7 +780,33 @@ export class IntentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createIntent(request, options, callback); + this._log.info('createIntent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IIntent, + | protos.google.cloud.dialogflow.cx.v3.ICreateIntentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createIntent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createIntent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IIntent, + protos.google.cloud.dialogflow.cx.v3.ICreateIntentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createIntent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified intent. @@ -858,7 +913,33 @@ export class IntentsClient { 'intent.name': request.intent!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateIntent(request, options, callback); + this._log.info('updateIntent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IIntent, + | protos.google.cloud.dialogflow.cx.v3.IUpdateIntentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateIntent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateIntent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IIntent, + protos.google.cloud.dialogflow.cx.v3.IUpdateIntentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateIntent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified intent. @@ -954,7 +1035,33 @@ export class IntentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteIntent(request, options, callback); + this._log.info('deleteIntent request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3.IDeleteIntentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteIntent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteIntent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.dialogflow.cx.v3.IDeleteIntentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteIntent response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1081,7 +1188,37 @@ export class IntentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.importIntents(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IImportIntentsResponse, + protos.google.cloud.dialogflow.cx.v3.IImportIntentsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('importIntents response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('importIntents request %j', request); + return this.innerApiCalls + .importIntents(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IImportIntentsResponse, + protos.google.cloud.dialogflow.cx.v3.IImportIntentsMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('importIntents response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `importIntents()`. @@ -1102,6 +1239,7 @@ export class IntentsClient { protos.google.cloud.dialogflow.cx.v3.ImportIntentsMetadata > > { + this._log.info('importIntents long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1247,7 +1385,37 @@ export class IntentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.exportIntents(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IExportIntentsResponse, + protos.google.cloud.dialogflow.cx.v3.IExportIntentsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('exportIntents response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('exportIntents request %j', request); + return this.innerApiCalls + .exportIntents(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IExportIntentsResponse, + protos.google.cloud.dialogflow.cx.v3.IExportIntentsMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportIntents response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `exportIntents()`. @@ -1268,6 +1436,7 @@ export class IntentsClient { protos.google.cloud.dialogflow.cx.v3.ExportIntentsMetadata > > { + this._log.info('exportIntents long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1393,7 +1562,33 @@ export class IntentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listIntents(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListIntentsRequest, + | protos.google.cloud.dialogflow.cx.v3.IListIntentsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.IIntent + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listIntents values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listIntents request %j', request); + return this.innerApiCalls + .listIntents(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.IIntent[], + protos.google.cloud.dialogflow.cx.v3.IListIntentsRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListIntentsResponse, + ]) => { + this._log.info('listIntents values %j', response); + return [response, input, output]; + } + ); } /** @@ -1447,6 +1642,7 @@ export class IntentsClient { const defaultCallSettings = this._defaults['listIntents']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listIntents stream %j', request); return this.descriptors.page.listIntents.createStream( this.innerApiCalls.listIntents as GaxCall, request, @@ -1508,6 +1704,7 @@ export class IntentsClient { const defaultCallSettings = this._defaults['listIntents']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listIntents iterate %j', request); return this.descriptors.page.listIntents.asyncIterate( this.innerApiCalls['listIntents'] as GaxCall, request as {}, @@ -3666,6 +3863,7 @@ export class IntentsClient { close(): Promise { if (this.intentsStub && !this._terminated) { return this.intentsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/pages_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/pages_client.ts index 3d61d439d78..3122abfe47f 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/pages_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/pages_client.ts @@ -32,6 +32,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class PagesClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -92,7 +95,7 @@ export class PagesClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -626,7 +629,33 @@ export class PagesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getPage(request, options, callback); + this._log.info('getPage request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IPage, + | protos.google.cloud.dialogflow.cx.v3.IGetPageRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getPage response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getPage(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IPage, + protos.google.cloud.dialogflow.cx.v3.IGetPageRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getPage response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates a page in the specified flow. @@ -745,7 +774,33 @@ export class PagesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createPage(request, options, callback); + this._log.info('createPage request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IPage, + | protos.google.cloud.dialogflow.cx.v3.ICreatePageRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createPage response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createPage(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IPage, + protos.google.cloud.dialogflow.cx.v3.ICreatePageRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createPage response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified page. @@ -863,7 +918,33 @@ export class PagesClient { 'page.name': request.page!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updatePage(request, options, callback); + this._log.info('updatePage request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IPage, + | protos.google.cloud.dialogflow.cx.v3.IUpdatePageRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updatePage response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updatePage(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IPage, + protos.google.cloud.dialogflow.cx.v3.IUpdatePageRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updatePage response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified page. @@ -970,7 +1051,33 @@ export class PagesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deletePage(request, options, callback); + this._log.info('deletePage request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3.IDeletePageRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deletePage response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deletePage(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.dialogflow.cx.v3.IDeletePageRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deletePage response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1093,7 +1200,33 @@ export class PagesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listPages(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListPagesRequest, + | protos.google.cloud.dialogflow.cx.v3.IListPagesResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.IPage + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listPages values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listPages request %j', request); + return this.innerApiCalls + .listPages(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.IPage[], + protos.google.cloud.dialogflow.cx.v3.IListPagesRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListPagesResponse, + ]) => { + this._log.info('listPages values %j', response); + return [response, input, output]; + } + ); } /** @@ -1157,6 +1290,7 @@ export class PagesClient { const defaultCallSettings = this._defaults['listPages']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listPages stream %j', request); return this.descriptors.page.listPages.createStream( this.innerApiCalls.listPages as GaxCall, request, @@ -1228,6 +1362,7 @@ export class PagesClient { const defaultCallSettings = this._defaults['listPages']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listPages iterate %j', request); return this.descriptors.page.listPages.asyncIterate( this.innerApiCalls['listPages'] as GaxCall, request as {}, @@ -3386,6 +3521,7 @@ export class PagesClient { close(): Promise { if (this.pagesStub && !this._terminated) { return this.pagesStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/security_settings_service_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/security_settings_service_client.ts index b95fced82db..484aae066ef 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/security_settings_service_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/security_settings_service_client.ts @@ -32,6 +32,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class SecuritySettingsServiceClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -92,7 +95,7 @@ export class SecuritySettingsServiceClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -636,11 +639,36 @@ export class SecuritySettingsServiceClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createSecuritySettings( - request, - options, - callback - ); + this._log.info('createSecuritySettings request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ISecuritySettings, + | protos.google.cloud.dialogflow.cx.v3.ICreateSecuritySettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createSecuritySettings response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createSecuritySettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ISecuritySettings, + ( + | protos.google.cloud.dialogflow.cx.v3.ICreateSecuritySettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createSecuritySettings response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Retrieves the specified @@ -740,7 +768,36 @@ export class SecuritySettingsServiceClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getSecuritySettings(request, options, callback); + this._log.info('getSecuritySettings request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ISecuritySettings, + | protos.google.cloud.dialogflow.cx.v3.IGetSecuritySettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getSecuritySettings response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getSecuritySettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ISecuritySettings, + ( + | protos.google.cloud.dialogflow.cx.v3.IGetSecuritySettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getSecuritySettings response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified @@ -841,11 +898,36 @@ export class SecuritySettingsServiceClient { 'security_settings.name': request.securitySettings!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateSecuritySettings( - request, - options, - callback - ); + this._log.info('updateSecuritySettings request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ISecuritySettings, + | protos.google.cloud.dialogflow.cx.v3.IUpdateSecuritySettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateSecuritySettings response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateSecuritySettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ISecuritySettings, + ( + | protos.google.cloud.dialogflow.cx.v3.IUpdateSecuritySettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateSecuritySettings response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified @@ -945,11 +1027,36 @@ export class SecuritySettingsServiceClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteSecuritySettings( - request, - options, - callback - ); + this._log.info('deleteSecuritySettings request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3.IDeleteSecuritySettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteSecuritySettings response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteSecuritySettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3.IDeleteSecuritySettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteSecuritySettings response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1049,7 +1156,33 @@ export class SecuritySettingsServiceClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listSecuritySettings(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListSecuritySettingsRequest, + | protos.google.cloud.dialogflow.cx.v3.IListSecuritySettingsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.ISecuritySettings + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listSecuritySettings values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listSecuritySettings request %j', request); + return this.innerApiCalls + .listSecuritySettings(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.ISecuritySettings[], + protos.google.cloud.dialogflow.cx.v3.IListSecuritySettingsRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListSecuritySettingsResponse, + ]) => { + this._log.info('listSecuritySettings values %j', response); + return [response, input, output]; + } + ); } /** @@ -1090,6 +1223,7 @@ export class SecuritySettingsServiceClient { const defaultCallSettings = this._defaults['listSecuritySettings']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listSecuritySettings stream %j', request); return this.descriptors.page.listSecuritySettings.createStream( this.innerApiCalls.listSecuritySettings as GaxCall, request, @@ -1138,6 +1272,7 @@ export class SecuritySettingsServiceClient { const defaultCallSettings = this._defaults['listSecuritySettings']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listSecuritySettings iterate %j', request); return this.descriptors.page.listSecuritySettings.asyncIterate( this.innerApiCalls['listSecuritySettings'] as GaxCall, request as {}, @@ -3564,6 +3699,7 @@ export class SecuritySettingsServiceClient { close(): Promise { if (this.securitySettingsServiceStub && !this._terminated) { return this.securitySettingsServiceStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/session_entity_types_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/session_entity_types_client.ts index 392d3e42d17..35fbdef8ef3 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/session_entity_types_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/session_entity_types_client.ts @@ -32,6 +32,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -57,6 +58,8 @@ export class SessionEntityTypesClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -93,7 +96,7 @@ export class SessionEntityTypesClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -625,7 +628,36 @@ export class SessionEntityTypesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getSessionEntityType(request, options, callback); + this._log.info('getSessionEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ISessionEntityType, + | protos.google.cloud.dialogflow.cx.v3.IGetSessionEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getSessionEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getSessionEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ISessionEntityType, + ( + | protos.google.cloud.dialogflow.cx.v3.IGetSessionEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getSessionEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates a session entity type. @@ -729,11 +761,36 @@ export class SessionEntityTypesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createSessionEntityType( - request, - options, - callback - ); + this._log.info('createSessionEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ISessionEntityType, + | protos.google.cloud.dialogflow.cx.v3.ICreateSessionEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createSessionEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createSessionEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ISessionEntityType, + ( + | protos.google.cloud.dialogflow.cx.v3.ICreateSessionEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createSessionEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified session entity type. @@ -837,11 +894,36 @@ export class SessionEntityTypesClient { 'session_entity_type.name': request.sessionEntityType!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateSessionEntityType( - request, - options, - callback - ); + this._log.info('updateSessionEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ISessionEntityType, + | protos.google.cloud.dialogflow.cx.v3.IUpdateSessionEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateSessionEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateSessionEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ISessionEntityType, + ( + | protos.google.cloud.dialogflow.cx.v3.IUpdateSessionEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateSessionEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified session entity type. @@ -943,11 +1025,36 @@ export class SessionEntityTypesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteSessionEntityType( - request, - options, - callback - ); + this._log.info('deleteSessionEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3.IDeleteSessionEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteSessionEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteSessionEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3.IDeleteSessionEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteSessionEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1052,11 +1159,33 @@ export class SessionEntityTypesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listSessionEntityTypes( - request, - options, - callback - ); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListSessionEntityTypesRequest, + | protos.google.cloud.dialogflow.cx.v3.IListSessionEntityTypesResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.ISessionEntityType + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listSessionEntityTypes values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listSessionEntityTypes request %j', request); + return this.innerApiCalls + .listSessionEntityTypes(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.ISessionEntityType[], + protos.google.cloud.dialogflow.cx.v3.IListSessionEntityTypesRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListSessionEntityTypesResponse, + ]) => { + this._log.info('listSessionEntityTypes values %j', response); + return [response, input, output]; + } + ); } /** @@ -1102,6 +1231,7 @@ export class SessionEntityTypesClient { const defaultCallSettings = this._defaults['listSessionEntityTypes']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listSessionEntityTypes stream %j', request); return this.descriptors.page.listSessionEntityTypes.createStream( this.innerApiCalls.listSessionEntityTypes as GaxCall, request, @@ -1155,6 +1285,7 @@ export class SessionEntityTypesClient { const defaultCallSettings = this._defaults['listSessionEntityTypes']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listSessionEntityTypes iterate %j', request); return this.descriptors.page.listSessionEntityTypes.asyncIterate( this.innerApiCalls['listSessionEntityTypes'] as GaxCall, request as {}, @@ -3396,6 +3527,7 @@ export class SessionEntityTypesClient { close(): Promise { if (this.sessionEntityTypesStub && !this._terminated) { return this.sessionEntityTypesStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/sessions_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/sessions_client.ts index 66f92ea81dd..7e332a02034 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/sessions_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/sessions_client.ts @@ -30,6 +30,7 @@ import type { import {PassThrough} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -57,6 +58,8 @@ export class SessionsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -93,7 +96,7 @@ export class SessionsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -663,7 +666,33 @@ export class SessionsClient { session: request.session ?? '', }); this.initialize(); - return this.innerApiCalls.detectIntent(request, options, callback); + this._log.info('detectIntent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IDetectIntentResponse, + | protos.google.cloud.dialogflow.cx.v3.IDetectIntentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('detectIntent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .detectIntent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IDetectIntentResponse, + protos.google.cloud.dialogflow.cx.v3.IDetectIntentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('detectIntent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Returns preliminary intent match results, doesn't change the session @@ -772,7 +801,33 @@ export class SessionsClient { session: request.session ?? '', }); this.initialize(); - return this.innerApiCalls.matchIntent(request, options, callback); + this._log.info('matchIntent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IMatchIntentResponse, + | protos.google.cloud.dialogflow.cx.v3.IMatchIntentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('matchIntent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .matchIntent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IMatchIntentResponse, + protos.google.cloud.dialogflow.cx.v3.IMatchIntentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('matchIntent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Fulfills a matched intent returned by @@ -874,7 +929,36 @@ export class SessionsClient { request.matchIntentRequest!.session ?? '', }); this.initialize(); - return this.innerApiCalls.fulfillIntent(request, options, callback); + this._log.info('fulfillIntent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IFulfillIntentResponse, + | protos.google.cloud.dialogflow.cx.v3.IFulfillIntentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('fulfillIntent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .fulfillIntent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IFulfillIntentResponse, + ( + | protos.google.cloud.dialogflow.cx.v3.IFulfillIntentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('fulfillIntent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the feedback received from the user for a single turn of the bot @@ -979,7 +1063,36 @@ export class SessionsClient { session: request.session ?? '', }); this.initialize(); - return this.innerApiCalls.submitAnswerFeedback(request, options, callback); + this._log.info('submitAnswerFeedback request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IAnswerFeedback, + | protos.google.cloud.dialogflow.cx.v3.ISubmitAnswerFeedbackRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('submitAnswerFeedback response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .submitAnswerFeedback(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IAnswerFeedback, + ( + | protos.google.cloud.dialogflow.cx.v3.ISubmitAnswerFeedbackRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('submitAnswerFeedback response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1037,6 +1150,7 @@ export class SessionsClient { session: request.session ?? '', }); this.initialize(); + this._log.info('serverStreamingDetectIntent stream %j', options); return this.innerApiCalls.serverStreamingDetectIntent(request, options); } @@ -1062,6 +1176,7 @@ export class SessionsClient { */ streamingDetectIntent(options?: CallOptions): gax.CancellableStream { this.initialize(); + this._log.info('streamingDetectIntent stream %j', options); return this.innerApiCalls.streamingDetectIntent(null, options); } @@ -3494,6 +3609,7 @@ export class SessionsClient { close(): Promise { if (this.sessionsStub && !this._terminated) { return this.sessionsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/test_cases_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/test_cases_client.ts index 7361b95d3df..4f133fd4484 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/test_cases_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/test_cases_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -58,6 +59,8 @@ export class TestCasesClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -94,7 +97,7 @@ export class TestCasesClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -680,7 +683,36 @@ export class TestCasesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.batchDeleteTestCases(request, options, callback); + this._log.info('batchDeleteTestCases request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3.IBatchDeleteTestCasesRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('batchDeleteTestCases response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .batchDeleteTestCases(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3.IBatchDeleteTestCasesRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('batchDeleteTestCases response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Gets a test case. @@ -772,7 +804,33 @@ export class TestCasesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getTestCase(request, options, callback); + this._log.info('getTestCase request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ITestCase, + | protos.google.cloud.dialogflow.cx.v3.IGetTestCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getTestCase response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getTestCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ITestCase, + protos.google.cloud.dialogflow.cx.v3.IGetTestCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getTestCase response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates a test case for the given agent. @@ -865,7 +923,36 @@ export class TestCasesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createTestCase(request, options, callback); + this._log.info('createTestCase request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ITestCase, + | protos.google.cloud.dialogflow.cx.v3.ICreateTestCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createTestCase response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createTestCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ITestCase, + ( + | protos.google.cloud.dialogflow.cx.v3.ICreateTestCaseRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createTestCase response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified test case. @@ -960,7 +1047,36 @@ export class TestCasesClient { 'test_case.name': request.testCase!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateTestCase(request, options, callback); + this._log.info('updateTestCase request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ITestCase, + | protos.google.cloud.dialogflow.cx.v3.IUpdateTestCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateTestCase response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateTestCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ITestCase, + ( + | protos.google.cloud.dialogflow.cx.v3.IUpdateTestCaseRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateTestCase response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Calculates the test coverage for an agent. @@ -1059,7 +1175,36 @@ export class TestCasesClient { agent: request.agent ?? '', }); this.initialize(); - return this.innerApiCalls.calculateCoverage(request, options, callback); + this._log.info('calculateCoverage request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ICalculateCoverageResponse, + | protos.google.cloud.dialogflow.cx.v3.ICalculateCoverageRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('calculateCoverage response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .calculateCoverage(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ICalculateCoverageResponse, + ( + | protos.google.cloud.dialogflow.cx.v3.ICalculateCoverageRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('calculateCoverage response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Gets a test case result. @@ -1157,7 +1302,36 @@ export class TestCasesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getTestCaseResult(request, options, callback); + this._log.info('getTestCaseResult request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ITestCaseResult, + | protos.google.cloud.dialogflow.cx.v3.IGetTestCaseResultRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getTestCaseResult response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getTestCaseResult(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ITestCaseResult, + ( + | protos.google.cloud.dialogflow.cx.v3.IGetTestCaseResultRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getTestCaseResult response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1274,7 +1448,37 @@ export class TestCasesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.runTestCase(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IRunTestCaseResponse, + protos.google.cloud.dialogflow.cx.v3.IRunTestCaseMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('runTestCase response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('runTestCase request %j', request); + return this.innerApiCalls + .runTestCase(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IRunTestCaseResponse, + protos.google.cloud.dialogflow.cx.v3.IRunTestCaseMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('runTestCase response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `runTestCase()`. @@ -1295,6 +1499,7 @@ export class TestCasesClient { protos.google.cloud.dialogflow.cx.v3.RunTestCaseMetadata > > { + this._log.info('runTestCase long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1426,7 +1631,37 @@ export class TestCasesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.batchRunTestCases(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IBatchRunTestCasesResponse, + protos.google.cloud.dialogflow.cx.v3.IBatchRunTestCasesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('batchRunTestCases response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('batchRunTestCases request %j', request); + return this.innerApiCalls + .batchRunTestCases(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IBatchRunTestCasesResponse, + protos.google.cloud.dialogflow.cx.v3.IBatchRunTestCasesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('batchRunTestCases response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `batchRunTestCases()`. @@ -1447,6 +1682,7 @@ export class TestCasesClient { protos.google.cloud.dialogflow.cx.v3.BatchRunTestCasesMetadata > > { + this._log.info('batchRunTestCases long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1586,7 +1822,37 @@ export class TestCasesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.importTestCases(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IImportTestCasesResponse, + protos.google.cloud.dialogflow.cx.v3.IImportTestCasesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('importTestCases response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('importTestCases request %j', request); + return this.innerApiCalls + .importTestCases(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IImportTestCasesResponse, + protos.google.cloud.dialogflow.cx.v3.IImportTestCasesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('importTestCases response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `importTestCases()`. @@ -1607,6 +1873,7 @@ export class TestCasesClient { protos.google.cloud.dialogflow.cx.v3.ImportTestCasesMetadata > > { + this._log.info('importTestCases long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1758,7 +2025,37 @@ export class TestCasesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.exportTestCases(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IExportTestCasesResponse, + protos.google.cloud.dialogflow.cx.v3.IExportTestCasesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('exportTestCases response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('exportTestCases request %j', request); + return this.innerApiCalls + .exportTestCases(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IExportTestCasesResponse, + protos.google.cloud.dialogflow.cx.v3.IExportTestCasesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportTestCases response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `exportTestCases()`. @@ -1779,6 +2076,7 @@ export class TestCasesClient { protos.google.cloud.dialogflow.cx.v3.ExportTestCasesMetadata > > { + this._log.info('exportTestCases long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1894,7 +2192,33 @@ export class TestCasesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listTestCases(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListTestCasesRequest, + | protos.google.cloud.dialogflow.cx.v3.IListTestCasesResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.ITestCase + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listTestCases values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listTestCases request %j', request); + return this.innerApiCalls + .listTestCases(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.ITestCase[], + protos.google.cloud.dialogflow.cx.v3.IListTestCasesRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListTestCasesResponse, + ]) => { + this._log.info('listTestCases values %j', response); + return [response, input, output]; + } + ); } /** @@ -1938,6 +2262,7 @@ export class TestCasesClient { const defaultCallSettings = this._defaults['listTestCases']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listTestCases stream %j', request); return this.descriptors.page.listTestCases.createStream( this.innerApiCalls.listTestCases as GaxCall, request, @@ -1989,6 +2314,7 @@ export class TestCasesClient { const defaultCallSettings = this._defaults['listTestCases']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listTestCases iterate %j', request); return this.descriptors.page.listTestCases.asyncIterate( this.innerApiCalls['listTestCases'] as GaxCall, request as {}, @@ -2121,7 +2447,33 @@ export class TestCasesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listTestCaseResults(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListTestCaseResultsRequest, + | protos.google.cloud.dialogflow.cx.v3.IListTestCaseResultsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.ITestCaseResult + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listTestCaseResults values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listTestCaseResults request %j', request); + return this.innerApiCalls + .listTestCaseResults(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.ITestCaseResult[], + protos.google.cloud.dialogflow.cx.v3.IListTestCaseResultsRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListTestCaseResultsResponse, + ]) => { + this._log.info('listTestCaseResults values %j', response); + return [response, input, output]; + } + ); } /** @@ -2190,6 +2542,7 @@ export class TestCasesClient { const defaultCallSettings = this._defaults['listTestCaseResults']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listTestCaseResults stream %j', request); return this.descriptors.page.listTestCaseResults.createStream( this.innerApiCalls.listTestCaseResults as GaxCall, request, @@ -2266,6 +2619,7 @@ export class TestCasesClient { const defaultCallSettings = this._defaults['listTestCaseResults']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listTestCaseResults iterate %j', request); return this.descriptors.page.listTestCaseResults.asyncIterate( this.innerApiCalls['listTestCaseResults'] as GaxCall, request as {}, @@ -4424,6 +4778,7 @@ export class TestCasesClient { close(): Promise { if (this.testCasesStub && !this._terminated) { return this.testCasesStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/transition_route_groups_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/transition_route_groups_client.ts index bf802ebf798..7e22edb1d90 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/transition_route_groups_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/transition_route_groups_client.ts @@ -32,6 +32,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -57,6 +58,8 @@ export class TransitionRouteGroupsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -93,7 +96,7 @@ export class TransitionRouteGroupsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -636,11 +639,36 @@ export class TransitionRouteGroupsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getTransitionRouteGroup( - request, - options, - callback - ); + this._log.info('getTransitionRouteGroup request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ITransitionRouteGroup, + | protos.google.cloud.dialogflow.cx.v3.IGetTransitionRouteGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getTransitionRouteGroup response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getTransitionRouteGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ITransitionRouteGroup, + ( + | protos.google.cloud.dialogflow.cx.v3.IGetTransitionRouteGroupRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getTransitionRouteGroup response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates an @@ -761,11 +789,36 @@ export class TransitionRouteGroupsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createTransitionRouteGroup( - request, - options, - callback - ); + this._log.info('createTransitionRouteGroup request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ITransitionRouteGroup, + | protos.google.cloud.dialogflow.cx.v3.ICreateTransitionRouteGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createTransitionRouteGroup response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createTransitionRouteGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ITransitionRouteGroup, + ( + | protos.google.cloud.dialogflow.cx.v3.ICreateTransitionRouteGroupRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createTransitionRouteGroup response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified @@ -880,11 +933,36 @@ export class TransitionRouteGroupsClient { 'transition_route_group.name': request.transitionRouteGroup!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateTransitionRouteGroup( - request, - options, - callback - ); + this._log.info('updateTransitionRouteGroup request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ITransitionRouteGroup, + | protos.google.cloud.dialogflow.cx.v3.IUpdateTransitionRouteGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateTransitionRouteGroup response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateTransitionRouteGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ITransitionRouteGroup, + ( + | protos.google.cloud.dialogflow.cx.v3.IUpdateTransitionRouteGroupRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateTransitionRouteGroup response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified @@ -998,11 +1076,36 @@ export class TransitionRouteGroupsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteTransitionRouteGroup( - request, - options, - callback - ); + this._log.info('deleteTransitionRouteGroup request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3.IDeleteTransitionRouteGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteTransitionRouteGroup response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteTransitionRouteGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3.IDeleteTransitionRouteGroupRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteTransitionRouteGroup response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1117,11 +1220,33 @@ export class TransitionRouteGroupsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listTransitionRouteGroups( - request, - options, - callback - ); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListTransitionRouteGroupsRequest, + | protos.google.cloud.dialogflow.cx.v3.IListTransitionRouteGroupsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.ITransitionRouteGroup + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listTransitionRouteGroups values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listTransitionRouteGroups request %j', request); + return this.innerApiCalls + .listTransitionRouteGroups(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.ITransitionRouteGroup[], + protos.google.cloud.dialogflow.cx.v3.IListTransitionRouteGroupsRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListTransitionRouteGroupsResponse, + ]) => { + this._log.info('listTransitionRouteGroups values %j', response); + return [response, input, output]; + } + ); } /** @@ -1177,6 +1302,7 @@ export class TransitionRouteGroupsClient { const defaultCallSettings = this._defaults['listTransitionRouteGroups']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listTransitionRouteGroups stream %j', request); return this.descriptors.page.listTransitionRouteGroups.createStream( this.innerApiCalls.listTransitionRouteGroups as GaxCall, request, @@ -1240,6 +1366,7 @@ export class TransitionRouteGroupsClient { const defaultCallSettings = this._defaults['listTransitionRouteGroups']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listTransitionRouteGroups iterate %j', request); return this.descriptors.page.listTransitionRouteGroups.asyncIterate( this.innerApiCalls['listTransitionRouteGroups'] as GaxCall, request as {}, @@ -3398,6 +3525,7 @@ export class TransitionRouteGroupsClient { close(): Promise { if (this.transitionRouteGroupsStub && !this._terminated) { return this.transitionRouteGroupsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/versions_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/versions_client.ts index 281497070f7..fd056beb01b 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/versions_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/versions_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -57,6 +58,8 @@ export class VersionsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -93,7 +96,7 @@ export class VersionsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -639,7 +642,33 @@ export class VersionsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getVersion(request, options, callback); + this._log.info('getVersion request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IVersion, + | protos.google.cloud.dialogflow.cx.v3.IGetVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getVersion response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IVersion, + protos.google.cloud.dialogflow.cx.v3.IGetVersionRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getVersion response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified {@link protos.google.cloud.dialogflow.cx.v3.Version|Version}. @@ -732,7 +761,36 @@ export class VersionsClient { 'version.name': request.version!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateVersion(request, options, callback); + this._log.info('updateVersion request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IVersion, + | protos.google.cloud.dialogflow.cx.v3.IUpdateVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateVersion response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IVersion, + ( + | protos.google.cloud.dialogflow.cx.v3.IUpdateVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateVersion response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified {@link protos.google.cloud.dialogflow.cx.v3.Version|Version}. @@ -824,7 +882,36 @@ export class VersionsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteVersion(request, options, callback); + this._log.info('deleteVersion request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3.IDeleteVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteVersion response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3.IDeleteVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteVersion response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Compares the specified base version with target version. @@ -931,7 +1018,36 @@ export class VersionsClient { base_version: request.baseVersion ?? '', }); this.initialize(); - return this.innerApiCalls.compareVersions(request, options, callback); + this._log.info('compareVersions request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.ICompareVersionsResponse, + | protos.google.cloud.dialogflow.cx.v3.ICompareVersionsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('compareVersions response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .compareVersions(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.ICompareVersionsResponse, + ( + | protos.google.cloud.dialogflow.cx.v3.ICompareVersionsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('compareVersions response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1047,7 +1163,37 @@ export class VersionsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createVersion(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3.IVersion, + protos.google.cloud.dialogflow.cx.v3.ICreateVersionOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('createVersion response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('createVersion request %j', request); + return this.innerApiCalls + .createVersion(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3.IVersion, + protos.google.cloud.dialogflow.cx.v3.ICreateVersionOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createVersion response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `createVersion()`. @@ -1068,6 +1214,7 @@ export class VersionsClient { protos.google.cloud.dialogflow.cx.v3.CreateVersionOperationMetadata > > { + this._log.info('createVersion long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1199,7 +1346,37 @@ export class VersionsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.loadVersion(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('loadVersion response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('loadVersion request %j', request); + return this.innerApiCalls + .loadVersion(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('loadVersion response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `loadVersion()`. @@ -1217,6 +1394,7 @@ export class VersionsClient { ): Promise< LROperation > { + this._log.info('loadVersion long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1331,7 +1509,33 @@ export class VersionsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listVersions(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListVersionsRequest, + | protos.google.cloud.dialogflow.cx.v3.IListVersionsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.IVersion + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listVersions values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listVersions request %j', request); + return this.innerApiCalls + .listVersions(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.IVersion[], + protos.google.cloud.dialogflow.cx.v3.IListVersionsRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListVersionsResponse, + ]) => { + this._log.info('listVersions values %j', response); + return [response, input, output]; + } + ); } /** @@ -1373,6 +1577,7 @@ export class VersionsClient { const defaultCallSettings = this._defaults['listVersions']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listVersions stream %j', request); return this.descriptors.page.listVersions.createStream( this.innerApiCalls.listVersions as GaxCall, request, @@ -1422,6 +1627,7 @@ export class VersionsClient { const defaultCallSettings = this._defaults['listVersions']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listVersions iterate %j', request); return this.descriptors.page.listVersions.asyncIterate( this.innerApiCalls['listVersions'] as GaxCall, request as {}, @@ -3580,6 +3786,7 @@ export class VersionsClient { close(): Promise { if (this.versionsStub && !this._terminated) { return this.versionsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3/webhooks_client.ts b/packages/google-cloud-dialogflow-cx/src/v3/webhooks_client.ts index d185272c293..bdfb6b55d0d 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3/webhooks_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3/webhooks_client.ts @@ -32,6 +32,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class WebhooksClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -92,7 +95,7 @@ export class WebhooksClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -617,7 +620,33 @@ export class WebhooksClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getWebhook(request, options, callback); + this._log.info('getWebhook request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IWebhook, + | protos.google.cloud.dialogflow.cx.v3.IGetWebhookRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getWebhook response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getWebhook(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IWebhook, + protos.google.cloud.dialogflow.cx.v3.IGetWebhookRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getWebhook response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates a webhook in the specified agent. @@ -710,7 +739,36 @@ export class WebhooksClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createWebhook(request, options, callback); + this._log.info('createWebhook request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IWebhook, + | protos.google.cloud.dialogflow.cx.v3.ICreateWebhookRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createWebhook response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createWebhook(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IWebhook, + ( + | protos.google.cloud.dialogflow.cx.v3.ICreateWebhookRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createWebhook response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified webhook. @@ -803,7 +861,36 @@ export class WebhooksClient { 'webhook.name': request.webhook!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateWebhook(request, options, callback); + this._log.info('updateWebhook request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3.IWebhook, + | protos.google.cloud.dialogflow.cx.v3.IUpdateWebhookRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateWebhook response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateWebhook(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3.IWebhook, + ( + | protos.google.cloud.dialogflow.cx.v3.IUpdateWebhookRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateWebhook response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified webhook. @@ -906,7 +993,36 @@ export class WebhooksClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteWebhook(request, options, callback); + this._log.info('deleteWebhook request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3.IDeleteWebhookRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteWebhook response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteWebhook(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3.IDeleteWebhookRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteWebhook response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1006,7 +1122,33 @@ export class WebhooksClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listWebhooks(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3.IListWebhooksRequest, + | protos.google.cloud.dialogflow.cx.v3.IListWebhooksResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3.IWebhook + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listWebhooks values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listWebhooks request %j', request); + return this.innerApiCalls + .listWebhooks(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3.IWebhook[], + protos.google.cloud.dialogflow.cx.v3.IListWebhooksRequest | null, + protos.google.cloud.dialogflow.cx.v3.IListWebhooksResponse, + ]) => { + this._log.info('listWebhooks values %j', response); + return [response, input, output]; + } + ); } /** @@ -1047,6 +1189,7 @@ export class WebhooksClient { const defaultCallSettings = this._defaults['listWebhooks']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listWebhooks stream %j', request); return this.descriptors.page.listWebhooks.createStream( this.innerApiCalls.listWebhooks as GaxCall, request, @@ -1095,6 +1238,7 @@ export class WebhooksClient { const defaultCallSettings = this._defaults['listWebhooks']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listWebhooks iterate %j', request); return this.descriptors.page.listWebhooks.asyncIterate( this.innerApiCalls['listWebhooks'] as GaxCall, request as {}, @@ -3439,6 +3583,7 @@ export class WebhooksClient { close(): Promise { if (this.webhooksStub && !this._terminated) { return this.webhooksStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/agents_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/agents_client.ts index d571bae0ae0..be0957ef44b 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/agents_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/agents_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -57,6 +58,8 @@ export class AgentsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -93,7 +96,7 @@ export class AgentsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -662,7 +665,36 @@ export class AgentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getAgent(request, options, callback); + this._log.info('getAgent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IAgent, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetAgentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getAgent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getAgent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IAgent, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetAgentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAgent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates an agent in the specified location. @@ -759,7 +791,36 @@ export class AgentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createAgent(request, options, callback); + this._log.info('createAgent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IAgent, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateAgentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createAgent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createAgent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IAgent, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateAgentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createAgent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified agent. @@ -856,7 +917,36 @@ export class AgentsClient { 'agent.name': request.agent!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateAgent(request, options, callback); + this._log.info('updateAgent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IAgent, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateAgentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateAgent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateAgent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IAgent, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateAgentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateAgent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified agent. @@ -947,7 +1037,36 @@ export class AgentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteAgent(request, options, callback); + this._log.info('deleteAgent request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteAgentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteAgent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteAgent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteAgentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteAgent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Validates the specified agent and creates or updates validation results. @@ -1048,7 +1167,36 @@ export class AgentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.validateAgent(request, options, callback); + this._log.info('validateAgent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IAgentValidationResult, + | protos.google.cloud.dialogflow.cx.v3beta1.IValidateAgentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('validateAgent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .validateAgent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IAgentValidationResult, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IValidateAgentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('validateAgent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Gets the latest agent validation result. Agent validation is performed @@ -1149,11 +1297,36 @@ export class AgentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getAgentValidationResult( - request, - options, - callback - ); + this._log.info('getAgentValidationResult request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IAgentValidationResult, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetAgentValidationResultRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getAgentValidationResult response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getAgentValidationResult(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IAgentValidationResult, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetAgentValidationResultRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAgentValidationResult response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Gets the generative settings for the agent. @@ -1252,7 +1425,36 @@ export class AgentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getGenerativeSettings(request, options, callback); + this._log.info('getGenerativeSettings request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IGenerativeSettings, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetGenerativeSettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getGenerativeSettings response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getGenerativeSettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IGenerativeSettings, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetGenerativeSettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getGenerativeSettings response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the generative settings for the agent. @@ -1351,11 +1553,36 @@ export class AgentsClient { 'generative_settings.name': request.generativeSettings!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateGenerativeSettings( - request, - options, - callback - ); + this._log.info('updateGenerativeSettings request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IGenerativeSettings, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateGenerativeSettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateGenerativeSettings response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateGenerativeSettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IGenerativeSettings, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateGenerativeSettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateGenerativeSettings response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1490,7 +1717,37 @@ export class AgentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.exportAgent(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IExportAgentResponse, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('exportAgent response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('exportAgent request %j', request); + return this.innerApiCalls + .exportAgent(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IExportAgentResponse, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportAgent response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `exportAgent()`. @@ -1511,6 +1768,7 @@ export class AgentsClient { protos.google.protobuf.Struct > > { + this._log.info('exportAgent long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1659,7 +1917,37 @@ export class AgentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.restoreAgent(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('restoreAgent response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('restoreAgent request %j', request); + return this.innerApiCalls + .restoreAgent(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('restoreAgent response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `restoreAgent()`. @@ -1677,6 +1965,7 @@ export class AgentsClient { ): Promise< LROperation > { + this._log.info('restoreAgent long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1789,7 +2078,33 @@ export class AgentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listAgents(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListAgentsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListAgentsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IAgent + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listAgents values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listAgents request %j', request); + return this.innerApiCalls + .listAgents(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IAgent[], + protos.google.cloud.dialogflow.cx.v3beta1.IListAgentsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListAgentsResponse, + ]) => { + this._log.info('listAgents values %j', response); + return [response, input, output]; + } + ); } /** @@ -1830,6 +2145,7 @@ export class AgentsClient { const defaultCallSettings = this._defaults['listAgents']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listAgents stream %j', request); return this.descriptors.page.listAgents.createStream( this.innerApiCalls.listAgents as GaxCall, request, @@ -1878,6 +2194,7 @@ export class AgentsClient { const defaultCallSettings = this._defaults['listAgents']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listAgents iterate %j', request); return this.descriptors.page.listAgents.asyncIterate( this.innerApiCalls['listAgents'] as GaxCall, request as {}, @@ -4494,6 +4811,7 @@ export class AgentsClient { close(): Promise { if (this.agentsStub && !this._terminated) { return this.agentsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/changelogs_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/changelogs_client.ts index 4831282dcdb..685a8bb9194 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/changelogs_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/changelogs_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class ChangelogsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -91,7 +94,7 @@ export class ChangelogsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -579,7 +582,36 @@ export class ChangelogsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getChangelog(request, options, callback); + this._log.info('getChangelog request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IChangelog, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetChangelogRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getChangelog response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getChangelog(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IChangelog, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetChangelogRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getChangelog response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -700,7 +732,33 @@ export class ChangelogsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listChangelogs(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListChangelogsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListChangelogsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IChangelog + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listChangelogs values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listChangelogs request %j', request); + return this.innerApiCalls + .listChangelogs(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IChangelog[], + protos.google.cloud.dialogflow.cx.v3beta1.IListChangelogsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListChangelogsResponse, + ]) => { + this._log.info('listChangelogs values %j', response); + return [response, input, output]; + } + ); } /** @@ -762,6 +820,7 @@ export class ChangelogsClient { const defaultCallSettings = this._defaults['listChangelogs']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listChangelogs stream %j', request); return this.descriptors.page.listChangelogs.createStream( this.innerApiCalls.listChangelogs as GaxCall, request, @@ -831,6 +890,7 @@ export class ChangelogsClient { const defaultCallSettings = this._defaults['listChangelogs']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listChangelogs iterate %j', request); return this.descriptors.page.listChangelogs.asyncIterate( this.innerApiCalls['listChangelogs'] as GaxCall, request as {}, @@ -3223,6 +3283,7 @@ export class ChangelogsClient { close(): Promise { if (this.changelogsStub && !this._terminated) { return this.changelogsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/conversation_history_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/conversation_history_client.ts index 03a7313cf41..9975d1f57fc 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/conversation_history_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/conversation_history_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -55,6 +56,8 @@ export class ConversationHistoryClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -90,7 +93,7 @@ export class ConversationHistoryClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -583,7 +586,36 @@ export class ConversationHistoryClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getConversation(request, options, callback); + this._log.info('getConversation request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IConversation, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetConversationRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getConversation response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getConversation(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IConversation, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetConversationRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getConversation response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified conversation. @@ -681,7 +713,36 @@ export class ConversationHistoryClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteConversation(request, options, callback); + this._log.info('deleteConversation request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteConversationRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteConversation response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteConversation(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteConversationRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteConversation response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -794,7 +855,33 @@ export class ConversationHistoryClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listConversations(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListConversationsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListConversationsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IConversation + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listConversations values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listConversations request %j', request); + return this.innerApiCalls + .listConversations(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IConversation[], + protos.google.cloud.dialogflow.cx.v3beta1.IListConversationsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListConversationsResponse, + ]) => { + this._log.info('listConversations values %j', response); + return [response, input, output]; + } + ); } /** @@ -848,6 +935,7 @@ export class ConversationHistoryClient { const defaultCallSettings = this._defaults['listConversations']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listConversations stream %j', request); return this.descriptors.page.listConversations.createStream( this.innerApiCalls.listConversations as GaxCall, request, @@ -909,6 +997,7 @@ export class ConversationHistoryClient { const defaultCallSettings = this._defaults['listConversations']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listConversations iterate %j', request); return this.descriptors.page.listConversations.asyncIterate( this.innerApiCalls['listConversations'] as GaxCall, request as {}, @@ -3301,6 +3390,7 @@ export class ConversationHistoryClient { close(): Promise { if (this.conversationHistoryStub && !this._terminated) { return this.conversationHistoryStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/deployments_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/deployments_client.ts index 2f3f89fd38e..9f66a5c792f 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/deployments_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/deployments_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class DeploymentsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -91,7 +94,7 @@ export class DeploymentsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -580,7 +583,36 @@ export class DeploymentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getDeployment(request, options, callback); + this._log.info('getDeployment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IDeployment, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetDeploymentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getDeployment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getDeployment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IDeployment, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetDeploymentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getDeployment response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -682,7 +714,33 @@ export class DeploymentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listDeployments(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListDeploymentsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListDeploymentsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IDeployment + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listDeployments values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listDeployments request %j', request); + return this.innerApiCalls + .listDeployments(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IDeployment[], + protos.google.cloud.dialogflow.cx.v3beta1.IListDeploymentsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListDeploymentsResponse, + ]) => { + this._log.info('listDeployments values %j', response); + return [response, input, output]; + } + ); } /** @@ -724,6 +782,7 @@ export class DeploymentsClient { const defaultCallSettings = this._defaults['listDeployments']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listDeployments stream %j', request); return this.descriptors.page.listDeployments.createStream( this.innerApiCalls.listDeployments as GaxCall, request, @@ -773,6 +832,7 @@ export class DeploymentsClient { const defaultCallSettings = this._defaults['listDeployments']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listDeployments iterate %j', request); return this.descriptors.page.listDeployments.asyncIterate( this.innerApiCalls['listDeployments'] as GaxCall, request as {}, @@ -3165,6 +3225,7 @@ export class DeploymentsClient { close(): Promise { if (this.deploymentsStub && !this._terminated) { return this.deploymentsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/entity_types_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/entity_types_client.ts index b6f0ceb575f..9562ccdda90 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/entity_types_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/entity_types_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -58,6 +59,8 @@ export class EntityTypesClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -94,7 +97,7 @@ export class EntityTypesClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -679,7 +682,36 @@ export class EntityTypesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getEntityType(request, options, callback); + this._log.info('getEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IEntityType, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IEntityType, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates an entity type in the specified agent. @@ -790,7 +822,36 @@ export class EntityTypesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createEntityType(request, options, callback); + this._log.info('createEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IEntityType, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IEntityType, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified entity type. @@ -904,7 +965,36 @@ export class EntityTypesClient { 'entity_type.name': request.entityType!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateEntityType(request, options, callback); + this._log.info('updateEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IEntityType, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IEntityType, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified entity type. @@ -1019,7 +1109,36 @@ export class EntityTypesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteEntityType(request, options, callback); + this._log.info('deleteEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1156,7 +1275,37 @@ export class EntityTypesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.exportEntityTypes(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IExportEntityTypesResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IExportEntityTypesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('exportEntityTypes response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('exportEntityTypes request %j', request); + return this.innerApiCalls + .exportEntityTypes(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IExportEntityTypesResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IExportEntityTypesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportEntityTypes response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `exportEntityTypes()`. @@ -1177,6 +1326,7 @@ export class EntityTypesClient { protos.google.cloud.dialogflow.cx.v3beta1.ExportEntityTypesMetadata > > { + this._log.info('exportEntityTypes long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1316,7 +1466,37 @@ export class EntityTypesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.importEntityTypes(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IImportEntityTypesResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IImportEntityTypesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('importEntityTypes response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('importEntityTypes request %j', request); + return this.innerApiCalls + .importEntityTypes(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IImportEntityTypesResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IImportEntityTypesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('importEntityTypes response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `importEntityTypes()`. @@ -1337,6 +1517,7 @@ export class EntityTypesClient { protos.google.cloud.dialogflow.cx.v3beta1.ImportEntityTypesMetadata > > { + this._log.info('importEntityTypes long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1462,7 +1643,33 @@ export class EntityTypesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listEntityTypes(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListEntityTypesRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListEntityTypesResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IEntityType + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listEntityTypes values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listEntityTypes request %j', request); + return this.innerApiCalls + .listEntityTypes(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IEntityType[], + protos.google.cloud.dialogflow.cx.v3beta1.IListEntityTypesRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListEntityTypesResponse, + ]) => { + this._log.info('listEntityTypes values %j', response); + return [response, input, output]; + } + ); } /** @@ -1516,6 +1723,7 @@ export class EntityTypesClient { const defaultCallSettings = this._defaults['listEntityTypes']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listEntityTypes stream %j', request); return this.descriptors.page.listEntityTypes.createStream( this.innerApiCalls.listEntityTypes as GaxCall, request, @@ -1577,6 +1785,7 @@ export class EntityTypesClient { const defaultCallSettings = this._defaults['listEntityTypes']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listEntityTypes iterate %j', request); return this.descriptors.page.listEntityTypes.asyncIterate( this.innerApiCalls['listEntityTypes'] as GaxCall, request as {}, @@ -4193,6 +4402,7 @@ export class EntityTypesClient { close(): Promise { if (this.entityTypesStub && !this._terminated) { return this.entityTypesStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/environments_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/environments_client.ts index 55dd9a7dd67..06ec106bc79 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/environments_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/environments_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -58,6 +59,8 @@ export class EnvironmentsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -94,7 +97,7 @@ export class EnvironmentsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -701,7 +704,36 @@ export class EnvironmentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getEnvironment(request, options, callback); + this._log.info('getEnvironment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IEnvironment, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetEnvironmentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getEnvironment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getEnvironment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IEnvironment, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetEnvironmentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getEnvironment response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified @@ -801,7 +833,36 @@ export class EnvironmentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteEnvironment(request, options, callback); + this._log.info('deleteEnvironment request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteEnvironmentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteEnvironment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteEnvironment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteEnvironmentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteEnvironment response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -917,7 +978,37 @@ export class EnvironmentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createEnvironment(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IEnvironment, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('createEnvironment response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('createEnvironment request %j', request); + return this.innerApiCalls + .createEnvironment(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IEnvironment, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createEnvironment response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `createEnvironment()`. @@ -938,6 +1029,7 @@ export class EnvironmentsClient { protos.google.protobuf.Struct > > { + this._log.info('createEnvironment long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1064,7 +1156,37 @@ export class EnvironmentsClient { 'environment.name': request.environment!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateEnvironment(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IEnvironment, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('updateEnvironment response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('updateEnvironment request %j', request); + return this.innerApiCalls + .updateEnvironment(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IEnvironment, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateEnvironment response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `updateEnvironment()`. @@ -1085,6 +1207,7 @@ export class EnvironmentsClient { protos.google.protobuf.Struct > > { + this._log.info('updateEnvironment long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1211,7 +1334,37 @@ export class EnvironmentsClient { environment: request.environment ?? '', }); this.initialize(); - return this.innerApiCalls.runContinuousTest(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IRunContinuousTestResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IRunContinuousTestMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('runContinuousTest response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('runContinuousTest request %j', request); + return this.innerApiCalls + .runContinuousTest(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IRunContinuousTestResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IRunContinuousTestMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('runContinuousTest response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `runContinuousTest()`. @@ -1232,6 +1385,7 @@ export class EnvironmentsClient { protos.google.cloud.dialogflow.cx.v3beta1.RunContinuousTestMetadata > > { + this._log.info('runContinuousTest long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1363,7 +1517,37 @@ export class EnvironmentsClient { environment: request.environment ?? '', }); this.initialize(); - return this.innerApiCalls.deployFlow(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IDeployFlowResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IDeployFlowMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('deployFlow response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('deployFlow request %j', request); + return this.innerApiCalls + .deployFlow(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IDeployFlowResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IDeployFlowMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deployFlow response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `deployFlow()`. @@ -1384,6 +1568,7 @@ export class EnvironmentsClient { protos.google.cloud.dialogflow.cx.v3beta1.DeployFlowMetadata > > { + this._log.info('deployFlow long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1498,7 +1683,33 @@ export class EnvironmentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listEnvironments(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListEnvironmentsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListEnvironmentsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IEnvironment + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listEnvironments values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listEnvironments request %j', request); + return this.innerApiCalls + .listEnvironments(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IEnvironment[], + protos.google.cloud.dialogflow.cx.v3beta1.IListEnvironmentsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListEnvironmentsResponse, + ]) => { + this._log.info('listEnvironments values %j', response); + return [response, input, output]; + } + ); } /** @@ -1540,6 +1751,7 @@ export class EnvironmentsClient { const defaultCallSettings = this._defaults['listEnvironments']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listEnvironments stream %j', request); return this.descriptors.page.listEnvironments.createStream( this.innerApiCalls.listEnvironments as GaxCall, request, @@ -1589,6 +1801,7 @@ export class EnvironmentsClient { const defaultCallSettings = this._defaults['listEnvironments']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listEnvironments iterate %j', request); return this.descriptors.page.listEnvironments.asyncIterate( this.innerApiCalls['listEnvironments'] as GaxCall, request as {}, @@ -1694,11 +1907,33 @@ export class EnvironmentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.lookupEnvironmentHistory( - request, - options, - callback - ); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.ILookupEnvironmentHistoryRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.ILookupEnvironmentHistoryResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IEnvironment + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('lookupEnvironmentHistory values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('lookupEnvironmentHistory request %j', request); + return this.innerApiCalls + .lookupEnvironmentHistory(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IEnvironment[], + protos.google.cloud.dialogflow.cx.v3beta1.ILookupEnvironmentHistoryRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.ILookupEnvironmentHistoryResponse, + ]) => { + this._log.info('lookupEnvironmentHistory values %j', response); + return [response, input, output]; + } + ); } /** @@ -1740,6 +1975,7 @@ export class EnvironmentsClient { const defaultCallSettings = this._defaults['lookupEnvironmentHistory']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('lookupEnvironmentHistory stream %j', request); return this.descriptors.page.lookupEnvironmentHistory.createStream( this.innerApiCalls.lookupEnvironmentHistory as GaxCall, request, @@ -1789,6 +2025,7 @@ export class EnvironmentsClient { const defaultCallSettings = this._defaults['lookupEnvironmentHistory']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('lookupEnvironmentHistory iterate %j', request); return this.descriptors.page.lookupEnvironmentHistory.asyncIterate( this.innerApiCalls['lookupEnvironmentHistory'] as GaxCall, request as {}, @@ -1893,11 +2130,33 @@ export class EnvironmentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listContinuousTestResults( - request, - options, - callback - ); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListContinuousTestResultsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListContinuousTestResultsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IContinuousTestResult + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listContinuousTestResults values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listContinuousTestResults request %j', request); + return this.innerApiCalls + .listContinuousTestResults(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IContinuousTestResult[], + protos.google.cloud.dialogflow.cx.v3beta1.IListContinuousTestResultsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListContinuousTestResultsResponse, + ]) => { + this._log.info('listContinuousTestResults values %j', response); + return [response, input, output]; + } + ); } /** @@ -1939,6 +2198,7 @@ export class EnvironmentsClient { const defaultCallSettings = this._defaults['listContinuousTestResults']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listContinuousTestResults stream %j', request); return this.descriptors.page.listContinuousTestResults.createStream( this.innerApiCalls.listContinuousTestResults as GaxCall, request, @@ -1988,6 +2248,7 @@ export class EnvironmentsClient { const defaultCallSettings = this._defaults['listContinuousTestResults']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listContinuousTestResults iterate %j', request); return this.descriptors.page.listContinuousTestResults.asyncIterate( this.innerApiCalls['listContinuousTestResults'] as GaxCall, request as {}, @@ -4604,6 +4865,7 @@ export class EnvironmentsClient { close(): Promise { if (this.environmentsStub && !this._terminated) { return this.environmentsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/examples_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/examples_client.ts index 26b7db44ef8..5ca979d5e78 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/examples_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/examples_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -55,6 +56,8 @@ export class ExamplesClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -90,7 +93,7 @@ export class ExamplesClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -586,7 +589,36 @@ export class ExamplesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createExample(request, options, callback); + this._log.info('createExample request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IExample, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateExampleRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createExample response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createExample(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IExample, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateExampleRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createExample response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified example. @@ -684,7 +716,36 @@ export class ExamplesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteExample(request, options, callback); + this._log.info('deleteExample request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteExampleRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteExample response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteExample(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteExampleRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteExample response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Retrieves the specified example. @@ -776,7 +837,36 @@ export class ExamplesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getExample(request, options, callback); + this._log.info('getExample request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IExample, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetExampleRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getExample response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getExample(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IExample, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetExampleRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getExample response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Update the specified example. @@ -875,7 +965,36 @@ export class ExamplesClient { 'example.name': request.example!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateExample(request, options, callback); + this._log.info('updateExample request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IExample, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateExampleRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateExample response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateExample(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IExample, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateExampleRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateExample response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -981,7 +1100,33 @@ export class ExamplesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listExamples(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListExamplesRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListExamplesResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IExample + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listExamples values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listExamples request %j', request); + return this.innerApiCalls + .listExamples(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IExample[], + protos.google.cloud.dialogflow.cx.v3beta1.IListExamplesRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListExamplesResponse, + ]) => { + this._log.info('listExamples values %j', response); + return [response, input, output]; + } + ); } /** @@ -1028,6 +1173,7 @@ export class ExamplesClient { const defaultCallSettings = this._defaults['listExamples']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listExamples stream %j', request); return this.descriptors.page.listExamples.createStream( this.innerApiCalls.listExamples as GaxCall, request, @@ -1082,6 +1228,7 @@ export class ExamplesClient { const defaultCallSettings = this._defaults['listExamples']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listExamples iterate %j', request); return this.descriptors.page.listExamples.asyncIterate( this.innerApiCalls['listExamples'] as GaxCall, request as {}, @@ -3474,6 +3621,7 @@ export class ExamplesClient { close(): Promise { if (this.examplesStub && !this._terminated) { return this.examplesStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/experiments_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/experiments_client.ts index d5874346bf0..1dcc567ed9e 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/experiments_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/experiments_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class ExperimentsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -91,7 +94,7 @@ export class ExperimentsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -588,7 +591,36 @@ export class ExperimentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getExperiment(request, options, callback); + this._log.info('getExperiment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IExperiment, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetExperimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getExperiment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getExperiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IExperiment, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetExperimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getExperiment response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates an {@link protos.google.cloud.dialogflow.cx.v3beta1.Experiment|Experiment} in @@ -691,7 +723,36 @@ export class ExperimentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createExperiment(request, options, callback); + this._log.info('createExperiment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IExperiment, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateExperimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createExperiment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createExperiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IExperiment, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateExperimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createExperiment response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified @@ -790,7 +851,36 @@ export class ExperimentsClient { 'experiment.name': request.experiment!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateExperiment(request, options, callback); + this._log.info('updateExperiment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IExperiment, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateExperimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateExperiment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateExperiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IExperiment, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateExperimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateExperiment response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified @@ -890,7 +980,36 @@ export class ExperimentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteExperiment(request, options, callback); + this._log.info('deleteExperiment request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteExperimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteExperiment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteExperiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteExperimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteExperiment response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Starts the specified @@ -990,7 +1109,36 @@ export class ExperimentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.startExperiment(request, options, callback); + this._log.info('startExperiment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IExperiment, + | protos.google.cloud.dialogflow.cx.v3beta1.IStartExperimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('startExperiment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .startExperiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IExperiment, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IStartExperimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('startExperiment response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Stops the specified @@ -1090,7 +1238,36 @@ export class ExperimentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.stopExperiment(request, options, callback); + this._log.info('stopExperiment request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IExperiment, + | protos.google.cloud.dialogflow.cx.v3beta1.IStopExperimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('stopExperiment response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .stopExperiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IExperiment, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IStopExperimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('stopExperiment response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1192,7 +1369,33 @@ export class ExperimentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listExperiments(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListExperimentsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListExperimentsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IExperiment + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listExperiments values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listExperiments request %j', request); + return this.innerApiCalls + .listExperiments(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IExperiment[], + protos.google.cloud.dialogflow.cx.v3beta1.IListExperimentsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListExperimentsResponse, + ]) => { + this._log.info('listExperiments values %j', response); + return [response, input, output]; + } + ); } /** @@ -1234,6 +1437,7 @@ export class ExperimentsClient { const defaultCallSettings = this._defaults['listExperiments']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listExperiments stream %j', request); return this.descriptors.page.listExperiments.createStream( this.innerApiCalls.listExperiments as GaxCall, request, @@ -1283,6 +1487,7 @@ export class ExperimentsClient { const defaultCallSettings = this._defaults['listExperiments']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listExperiments iterate %j', request); return this.descriptors.page.listExperiments.asyncIterate( this.innerApiCalls['listExperiments'] as GaxCall, request as {}, @@ -3675,6 +3880,7 @@ export class ExperimentsClient { close(): Promise { if (this.experimentsStub && !this._terminated) { return this.experimentsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/flows_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/flows_client.ts index ae0b46bc953..2036e5919a9 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/flows_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/flows_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -57,6 +58,8 @@ export class FlowsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -93,7 +96,7 @@ export class FlowsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -691,7 +694,36 @@ export class FlowsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createFlow(request, options, callback); + this._log.info('createFlow request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IFlow, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateFlowRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createFlow response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createFlow(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IFlow, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateFlowRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createFlow response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes a specified flow. @@ -794,7 +826,36 @@ export class FlowsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteFlow(request, options, callback); + this._log.info('deleteFlow request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteFlowRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteFlow response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteFlow(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteFlowRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteFlow response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Retrieves the specified flow. @@ -900,7 +961,33 @@ export class FlowsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getFlow(request, options, callback); + this._log.info('getFlow request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IFlow, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetFlowRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getFlow response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getFlow(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IFlow, + protos.google.cloud.dialogflow.cx.v3beta1.IGetFlowRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getFlow response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified flow. @@ -1010,7 +1097,36 @@ export class FlowsClient { 'flow.name': request.flow!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateFlow(request, options, callback); + this._log.info('updateFlow request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IFlow, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateFlowRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateFlow response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateFlow(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IFlow, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateFlowRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateFlow response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Validates the specified flow and creates or updates validation results. @@ -1112,7 +1228,36 @@ export class FlowsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.validateFlow(request, options, callback); + this._log.info('validateFlow request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IFlowValidationResult, + | protos.google.cloud.dialogflow.cx.v3beta1.IValidateFlowRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('validateFlow response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .validateFlow(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IFlowValidationResult, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IValidateFlowRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('validateFlow response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Gets the latest flow validation result. Flow validation is performed @@ -1213,11 +1358,36 @@ export class FlowsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getFlowValidationResult( - request, - options, - callback - ); + this._log.info('getFlowValidationResult request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IFlowValidationResult, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetFlowValidationResultRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getFlowValidationResult response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getFlowValidationResult(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IFlowValidationResult, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetFlowValidationResultRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getFlowValidationResult response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1336,7 +1506,37 @@ export class FlowsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.trainFlow(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('trainFlow response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('trainFlow request %j', request); + return this.innerApiCalls + .trainFlow(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('trainFlow response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `trainFlow()`. @@ -1354,6 +1554,7 @@ export class FlowsClient { ): Promise< LROperation > { + this._log.info('trainFlow long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1500,7 +1701,37 @@ export class FlowsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.importFlow(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IImportFlowResponse, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('importFlow response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('importFlow request %j', request); + return this.innerApiCalls + .importFlow(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IImportFlowResponse, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('importFlow response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `importFlow()`. @@ -1521,6 +1752,7 @@ export class FlowsClient { protos.google.protobuf.Struct > > { + this._log.info('importFlow long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1663,7 +1895,37 @@ export class FlowsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.exportFlow(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IExportFlowResponse, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('exportFlow response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('exportFlow request %j', request); + return this.innerApiCalls + .exportFlow(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IExportFlowResponse, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportFlow response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `exportFlow()`. @@ -1684,6 +1946,7 @@ export class FlowsClient { protos.google.protobuf.Struct > > { + this._log.info('exportFlow long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1810,7 +2073,33 @@ export class FlowsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listFlows(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListFlowsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListFlowsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IFlow + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listFlows values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listFlows request %j', request); + return this.innerApiCalls + .listFlows(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IFlow[], + protos.google.cloud.dialogflow.cx.v3beta1.IListFlowsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListFlowsResponse, + ]) => { + this._log.info('listFlows values %j', response); + return [response, input, output]; + } + ); } /** @@ -1865,6 +2154,7 @@ export class FlowsClient { const defaultCallSettings = this._defaults['listFlows']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listFlows stream %j', request); return this.descriptors.page.listFlows.createStream( this.innerApiCalls.listFlows as GaxCall, request, @@ -1927,6 +2217,7 @@ export class FlowsClient { const defaultCallSettings = this._defaults['listFlows']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listFlows iterate %j', request); return this.descriptors.page.listFlows.asyncIterate( this.innerApiCalls['listFlows'] as GaxCall, request as {}, @@ -4543,6 +4834,7 @@ export class FlowsClient { close(): Promise { if (this.flowsStub && !this._terminated) { return this.flowsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/generators_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/generators_client.ts index 5d7ac4f7864..bc99f62b94f 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/generators_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/generators_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class GeneratorsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -91,7 +94,7 @@ export class GeneratorsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -587,7 +590,36 @@ export class GeneratorsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getGenerator(request, options, callback); + this._log.info('getGenerator request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IGenerator, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetGeneratorRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getGenerator response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getGenerator(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IGenerator, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetGeneratorRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getGenerator response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates a generator in the specified agent. @@ -690,7 +722,36 @@ export class GeneratorsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createGenerator(request, options, callback); + this._log.info('createGenerator request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IGenerator, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateGeneratorRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createGenerator response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createGenerator(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IGenerator, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateGeneratorRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createGenerator response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Update the specified generator. @@ -791,7 +852,36 @@ export class GeneratorsClient { 'generator.name': request.generator!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateGenerator(request, options, callback); + this._log.info('updateGenerator request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IGenerator, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateGeneratorRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateGenerator response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateGenerator(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IGenerator, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateGeneratorRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateGenerator response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified generators. @@ -898,7 +988,36 @@ export class GeneratorsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteGenerator(request, options, callback); + this._log.info('deleteGenerator request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteGeneratorRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteGenerator response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteGenerator(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteGeneratorRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteGenerator response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1000,7 +1119,33 @@ export class GeneratorsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listGenerators(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListGeneratorsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListGeneratorsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IGenerator + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listGenerators values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listGenerators request %j', request); + return this.innerApiCalls + .listGenerators(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IGenerator[], + protos.google.cloud.dialogflow.cx.v3beta1.IListGeneratorsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListGeneratorsResponse, + ]) => { + this._log.info('listGenerators values %j', response); + return [response, input, output]; + } + ); } /** @@ -1043,6 +1188,7 @@ export class GeneratorsClient { const defaultCallSettings = this._defaults['listGenerators']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listGenerators stream %j', request); return this.descriptors.page.listGenerators.createStream( this.innerApiCalls.listGenerators as GaxCall, request, @@ -1093,6 +1239,7 @@ export class GeneratorsClient { const defaultCallSettings = this._defaults['listGenerators']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listGenerators iterate %j', request); return this.descriptors.page.listGenerators.asyncIterate( this.innerApiCalls['listGenerators'] as GaxCall, request as {}, @@ -3485,6 +3632,7 @@ export class GeneratorsClient { close(): Promise { if (this.generatorsStub && !this._terminated) { return this.generatorsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/intents_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/intents_client.ts index 0aafd147a09..e923655c463 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/intents_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/intents_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -57,6 +58,8 @@ export class IntentsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -93,7 +96,7 @@ export class IntentsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -670,7 +673,36 @@ export class IntentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getIntent(request, options, callback); + this._log.info('getIntent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IIntent, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetIntentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getIntent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getIntent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IIntent, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetIntentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getIntent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates an intent in the specified agent. @@ -783,7 +815,36 @@ export class IntentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createIntent(request, options, callback); + this._log.info('createIntent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IIntent, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateIntentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createIntent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createIntent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IIntent, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateIntentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createIntent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified intent. @@ -896,7 +957,36 @@ export class IntentsClient { 'intent.name': request.intent!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateIntent(request, options, callback); + this._log.info('updateIntent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IIntent, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateIntentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateIntent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateIntent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IIntent, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateIntentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateIntent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified intent. @@ -998,7 +1088,36 @@ export class IntentsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteIntent(request, options, callback); + this._log.info('deleteIntent request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteIntentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteIntent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteIntent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteIntentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteIntent response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1125,7 +1244,37 @@ export class IntentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.importIntents(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IImportIntentsResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IImportIntentsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('importIntents response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('importIntents request %j', request); + return this.innerApiCalls + .importIntents(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IImportIntentsResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IImportIntentsMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('importIntents response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `importIntents()`. @@ -1146,6 +1295,7 @@ export class IntentsClient { protos.google.cloud.dialogflow.cx.v3beta1.ImportIntentsMetadata > > { + this._log.info('importIntents long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1291,7 +1441,37 @@ export class IntentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.exportIntents(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IExportIntentsResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IExportIntentsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('exportIntents response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('exportIntents request %j', request); + return this.innerApiCalls + .exportIntents(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IExportIntentsResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IExportIntentsMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportIntents response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `exportIntents()`. @@ -1312,6 +1492,7 @@ export class IntentsClient { protos.google.cloud.dialogflow.cx.v3beta1.ExportIntentsMetadata > > { + this._log.info('exportIntents long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1437,7 +1618,33 @@ export class IntentsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listIntents(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListIntentsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListIntentsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IIntent + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listIntents values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listIntents request %j', request); + return this.innerApiCalls + .listIntents(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IIntent[], + protos.google.cloud.dialogflow.cx.v3beta1.IListIntentsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListIntentsResponse, + ]) => { + this._log.info('listIntents values %j', response); + return [response, input, output]; + } + ); } /** @@ -1491,6 +1698,7 @@ export class IntentsClient { const defaultCallSettings = this._defaults['listIntents']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listIntents stream %j', request); return this.descriptors.page.listIntents.createStream( this.innerApiCalls.listIntents as GaxCall, request, @@ -1552,6 +1760,7 @@ export class IntentsClient { const defaultCallSettings = this._defaults['listIntents']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listIntents iterate %j', request); return this.descriptors.page.listIntents.asyncIterate( this.innerApiCalls['listIntents'] as GaxCall, request as {}, @@ -4168,6 +4377,7 @@ export class IntentsClient { close(): Promise { if (this.intentsStub && !this._terminated) { return this.intentsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/pages_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/pages_client.ts index e85788494fb..d97e92e94ac 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/pages_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/pages_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -55,6 +56,8 @@ export class PagesClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -90,7 +93,7 @@ export class PagesClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -600,7 +603,33 @@ export class PagesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getPage(request, options, callback); + this._log.info('getPage request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IPage, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetPageRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getPage response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getPage(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IPage, + protos.google.cloud.dialogflow.cx.v3beta1.IGetPageRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getPage response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates a page in the specified flow. @@ -715,7 +744,36 @@ export class PagesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createPage(request, options, callback); + this._log.info('createPage request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IPage, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreatePageRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createPage response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createPage(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IPage, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreatePageRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createPage response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified page. @@ -829,7 +887,36 @@ export class PagesClient { 'page.name': request.page!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updatePage(request, options, callback); + this._log.info('updatePage request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IPage, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdatePageRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updatePage response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updatePage(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IPage, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdatePageRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updatePage response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified page. @@ -932,7 +1019,36 @@ export class PagesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deletePage(request, options, callback); + this._log.info('deletePage request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeletePageRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deletePage response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deletePage(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeletePageRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deletePage response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1055,7 +1171,33 @@ export class PagesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listPages(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListPagesRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListPagesResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IPage + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listPages values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listPages request %j', request); + return this.innerApiCalls + .listPages(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IPage[], + protos.google.cloud.dialogflow.cx.v3beta1.IListPagesRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListPagesResponse, + ]) => { + this._log.info('listPages values %j', response); + return [response, input, output]; + } + ); } /** @@ -1119,6 +1261,7 @@ export class PagesClient { const defaultCallSettings = this._defaults['listPages']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listPages stream %j', request); return this.descriptors.page.listPages.createStream( this.innerApiCalls.listPages as GaxCall, request, @@ -1190,6 +1333,7 @@ export class PagesClient { const defaultCallSettings = this._defaults['listPages']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listPages iterate %j', request); return this.descriptors.page.listPages.asyncIterate( this.innerApiCalls['listPages'] as GaxCall, request as {}, @@ -3582,6 +3726,7 @@ export class PagesClient { close(): Promise { if (this.pagesStub && !this._terminated) { return this.pagesStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/playbooks_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/playbooks_client.ts index f4c1798a8aa..673fe5057bf 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/playbooks_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/playbooks_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class PlaybooksClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -91,7 +94,7 @@ export class PlaybooksClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -595,7 +598,36 @@ export class PlaybooksClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createPlaybook(request, options, callback); + this._log.info('createPlaybook request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IPlaybook, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreatePlaybookRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createPlaybook response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createPlaybook(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IPlaybook, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreatePlaybookRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createPlaybook response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes a specified playbook. @@ -693,7 +725,36 @@ export class PlaybooksClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deletePlaybook(request, options, callback); + this._log.info('deletePlaybook request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeletePlaybookRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deletePlaybook response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deletePlaybook(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeletePlaybookRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deletePlaybook response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Retrieves the specified Playbook. @@ -785,7 +846,36 @@ export class PlaybooksClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getPlaybook(request, options, callback); + this._log.info('getPlaybook request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IPlaybook, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetPlaybookRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getPlaybook response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getPlaybook(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IPlaybook, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetPlaybookRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getPlaybook response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified Playbook. @@ -884,7 +974,36 @@ export class PlaybooksClient { 'playbook.name': request.playbook!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updatePlaybook(request, options, callback); + this._log.info('updatePlaybook request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IPlaybook, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdatePlaybookRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updatePlaybook response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updatePlaybook(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IPlaybook, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdatePlaybookRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updatePlaybook response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates a version for the specified Playbook. @@ -984,7 +1103,36 @@ export class PlaybooksClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createPlaybookVersion(request, options, callback); + this._log.info('createPlaybookVersion request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IPlaybookVersion, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreatePlaybookVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createPlaybookVersion response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createPlaybookVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IPlaybookVersion, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreatePlaybookVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createPlaybookVersion response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Retrieves the specified version of the Playbook. @@ -1082,7 +1230,36 @@ export class PlaybooksClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getPlaybookVersion(request, options, callback); + this._log.info('getPlaybookVersion request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IPlaybookVersion, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetPlaybookVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getPlaybookVersion response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getPlaybookVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IPlaybookVersion, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetPlaybookVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getPlaybookVersion response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified version of the Playbook. @@ -1180,7 +1357,36 @@ export class PlaybooksClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deletePlaybookVersion(request, options, callback); + this._log.info('deletePlaybookVersion request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeletePlaybookVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deletePlaybookVersion response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deletePlaybookVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeletePlaybookVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deletePlaybookVersion response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1280,7 +1486,33 @@ export class PlaybooksClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listPlaybooks(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListPlaybooksRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListPlaybooksResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IPlaybook + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listPlaybooks values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listPlaybooks request %j', request); + return this.innerApiCalls + .listPlaybooks(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IPlaybook[], + protos.google.cloud.dialogflow.cx.v3beta1.IListPlaybooksRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListPlaybooksResponse, + ]) => { + this._log.info('listPlaybooks values %j', response); + return [response, input, output]; + } + ); } /** @@ -1321,6 +1553,7 @@ export class PlaybooksClient { const defaultCallSettings = this._defaults['listPlaybooks']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listPlaybooks stream %j', request); return this.descriptors.page.listPlaybooks.createStream( this.innerApiCalls.listPlaybooks as GaxCall, request, @@ -1369,6 +1602,7 @@ export class PlaybooksClient { const defaultCallSettings = this._defaults['listPlaybooks']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listPlaybooks iterate %j', request); return this.descriptors.page.listPlaybooks.asyncIterate( this.innerApiCalls['listPlaybooks'] as GaxCall, request as {}, @@ -1473,7 +1707,33 @@ export class PlaybooksClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listPlaybookVersions(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListPlaybookVersionsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListPlaybookVersionsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IPlaybookVersion + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listPlaybookVersions values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listPlaybookVersions request %j', request); + return this.innerApiCalls + .listPlaybookVersions(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IPlaybookVersion[], + protos.google.cloud.dialogflow.cx.v3beta1.IListPlaybookVersionsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListPlaybookVersionsResponse, + ]) => { + this._log.info('listPlaybookVersions values %j', response); + return [response, input, output]; + } + ); } /** @@ -1515,6 +1775,7 @@ export class PlaybooksClient { const defaultCallSettings = this._defaults['listPlaybookVersions']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listPlaybookVersions stream %j', request); return this.descriptors.page.listPlaybookVersions.createStream( this.innerApiCalls.listPlaybookVersions as GaxCall, request, @@ -1564,6 +1825,7 @@ export class PlaybooksClient { const defaultCallSettings = this._defaults['listPlaybookVersions']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listPlaybookVersions iterate %j', request); return this.descriptors.page.listPlaybookVersions.asyncIterate( this.innerApiCalls['listPlaybookVersions'] as GaxCall, request as {}, @@ -3956,6 +4218,7 @@ export class PlaybooksClient { close(): Promise { if (this.playbooksStub && !this._terminated) { return this.playbooksStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/security_settings_service_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/security_settings_service_client.ts index 0accea38c8b..33c34e67b2a 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/security_settings_service_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/security_settings_service_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -55,6 +56,8 @@ export class SecuritySettingsServiceClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -90,7 +93,7 @@ export class SecuritySettingsServiceClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -604,11 +607,36 @@ export class SecuritySettingsServiceClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createSecuritySettings( - request, - options, - callback - ); + this._log.info('createSecuritySettings request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ISecuritySettings, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateSecuritySettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createSecuritySettings response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createSecuritySettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ISecuritySettings, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateSecuritySettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createSecuritySettings response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Retrieves the specified @@ -708,7 +736,36 @@ export class SecuritySettingsServiceClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getSecuritySettings(request, options, callback); + this._log.info('getSecuritySettings request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ISecuritySettings, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetSecuritySettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getSecuritySettings response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getSecuritySettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ISecuritySettings, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetSecuritySettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getSecuritySettings response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified @@ -809,11 +866,36 @@ export class SecuritySettingsServiceClient { 'security_settings.name': request.securitySettings!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateSecuritySettings( - request, - options, - callback - ); + this._log.info('updateSecuritySettings request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ISecuritySettings, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateSecuritySettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateSecuritySettings response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateSecuritySettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ISecuritySettings, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateSecuritySettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateSecuritySettings response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified @@ -913,11 +995,36 @@ export class SecuritySettingsServiceClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteSecuritySettings( - request, - options, - callback - ); + this._log.info('deleteSecuritySettings request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteSecuritySettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteSecuritySettings response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteSecuritySettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteSecuritySettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteSecuritySettings response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1017,7 +1124,33 @@ export class SecuritySettingsServiceClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listSecuritySettings(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListSecuritySettingsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListSecuritySettingsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.ISecuritySettings + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listSecuritySettings values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listSecuritySettings request %j', request); + return this.innerApiCalls + .listSecuritySettings(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ISecuritySettings[], + protos.google.cloud.dialogflow.cx.v3beta1.IListSecuritySettingsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListSecuritySettingsResponse, + ]) => { + this._log.info('listSecuritySettings values %j', response); + return [response, input, output]; + } + ); } /** @@ -1058,6 +1191,7 @@ export class SecuritySettingsServiceClient { const defaultCallSettings = this._defaults['listSecuritySettings']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listSecuritySettings stream %j', request); return this.descriptors.page.listSecuritySettings.createStream( this.innerApiCalls.listSecuritySettings as GaxCall, request, @@ -1106,6 +1240,7 @@ export class SecuritySettingsServiceClient { const defaultCallSettings = this._defaults['listSecuritySettings']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listSecuritySettings iterate %j', request); return this.descriptors.page.listSecuritySettings.asyncIterate( this.innerApiCalls['listSecuritySettings'] as GaxCall, request as {}, @@ -3766,6 +3901,7 @@ export class SecuritySettingsServiceClient { close(): Promise { if (this.securitySettingsServiceStub && !this._terminated) { return this.securitySettingsServiceStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/session_entity_types_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/session_entity_types_client.ts index 9375a9cd87d..23bd7568780 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/session_entity_types_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/session_entity_types_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class SessionEntityTypesClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -91,7 +94,7 @@ export class SessionEntityTypesClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -593,7 +596,36 @@ export class SessionEntityTypesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getSessionEntityType(request, options, callback); + this._log.info('getSessionEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ISessionEntityType, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetSessionEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getSessionEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getSessionEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ISessionEntityType, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetSessionEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getSessionEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates a session entity type. @@ -697,11 +729,36 @@ export class SessionEntityTypesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createSessionEntityType( - request, - options, - callback - ); + this._log.info('createSessionEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ISessionEntityType, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateSessionEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createSessionEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createSessionEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ISessionEntityType, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateSessionEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createSessionEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified session entity type. @@ -805,11 +862,36 @@ export class SessionEntityTypesClient { 'session_entity_type.name': request.sessionEntityType!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateSessionEntityType( - request, - options, - callback - ); + this._log.info('updateSessionEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ISessionEntityType, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateSessionEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateSessionEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateSessionEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ISessionEntityType, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateSessionEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateSessionEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified session entity type. @@ -911,11 +993,36 @@ export class SessionEntityTypesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteSessionEntityType( - request, - options, - callback - ); + this._log.info('deleteSessionEntityType request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteSessionEntityTypeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteSessionEntityType response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteSessionEntityType(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteSessionEntityTypeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteSessionEntityType response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1020,11 +1127,33 @@ export class SessionEntityTypesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listSessionEntityTypes( - request, - options, - callback - ); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListSessionEntityTypesRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListSessionEntityTypesResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.ISessionEntityType + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listSessionEntityTypes values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listSessionEntityTypes request %j', request); + return this.innerApiCalls + .listSessionEntityTypes(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ISessionEntityType[], + protos.google.cloud.dialogflow.cx.v3beta1.IListSessionEntityTypesRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListSessionEntityTypesResponse, + ]) => { + this._log.info('listSessionEntityTypes values %j', response); + return [response, input, output]; + } + ); } /** @@ -1070,6 +1199,7 @@ export class SessionEntityTypesClient { const defaultCallSettings = this._defaults['listSessionEntityTypes']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listSessionEntityTypes stream %j', request); return this.descriptors.page.listSessionEntityTypes.createStream( this.innerApiCalls.listSessionEntityTypes as GaxCall, request, @@ -1123,6 +1253,7 @@ export class SessionEntityTypesClient { const defaultCallSettings = this._defaults['listSessionEntityTypes']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listSessionEntityTypes iterate %j', request); return this.descriptors.page.listSessionEntityTypes.asyncIterate( this.innerApiCalls['listSessionEntityTypes'] as GaxCall, request as {}, @@ -3598,6 +3729,7 @@ export class SessionEntityTypesClient { close(): Promise { if (this.sessionEntityTypesStub && !this._terminated) { return this.sessionEntityTypesStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/sessions_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/sessions_client.ts index 9d52bc907d1..dcd0a24eb0e 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/sessions_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/sessions_client.ts @@ -29,6 +29,7 @@ import type { import {PassThrough} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class SessionsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -91,7 +94,7 @@ export class SessionsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -637,7 +640,36 @@ export class SessionsClient { session: request.session ?? '', }); this.initialize(); - return this.innerApiCalls.detectIntent(request, options, callback); + this._log.info('detectIntent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IDetectIntentResponse, + | protos.google.cloud.dialogflow.cx.v3beta1.IDetectIntentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('detectIntent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .detectIntent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IDetectIntentResponse, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDetectIntentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('detectIntent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Returns preliminary intent match results, doesn't change the session @@ -746,7 +778,36 @@ export class SessionsClient { session: request.session ?? '', }); this.initialize(); - return this.innerApiCalls.matchIntent(request, options, callback); + this._log.info('matchIntent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IMatchIntentResponse, + | protos.google.cloud.dialogflow.cx.v3beta1.IMatchIntentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('matchIntent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .matchIntent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IMatchIntentResponse, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IMatchIntentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('matchIntent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Fulfills a matched intent returned by @@ -854,7 +915,36 @@ export class SessionsClient { request.matchIntentRequest!.session ?? '', }); this.initialize(); - return this.innerApiCalls.fulfillIntent(request, options, callback); + this._log.info('fulfillIntent request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IFulfillIntentResponse, + | protos.google.cloud.dialogflow.cx.v3beta1.IFulfillIntentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('fulfillIntent response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .fulfillIntent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IFulfillIntentResponse, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IFulfillIntentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('fulfillIntent response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the feedback received from the user for a single turn of the bot @@ -959,7 +1049,36 @@ export class SessionsClient { session: request.session ?? '', }); this.initialize(); - return this.innerApiCalls.submitAnswerFeedback(request, options, callback); + this._log.info('submitAnswerFeedback request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IAnswerFeedback, + | protos.google.cloud.dialogflow.cx.v3beta1.ISubmitAnswerFeedbackRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('submitAnswerFeedback response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .submitAnswerFeedback(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IAnswerFeedback, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ISubmitAnswerFeedbackRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('submitAnswerFeedback response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1017,6 +1136,7 @@ export class SessionsClient { session: request.session ?? '', }); this.initialize(); + this._log.info('serverStreamingDetectIntent stream %j', options); return this.innerApiCalls.serverStreamingDetectIntent(request, options); } @@ -1042,6 +1162,7 @@ export class SessionsClient { */ streamingDetectIntent(options?: CallOptions): gax.CancellableStream { this.initialize(); + this._log.info('streamingDetectIntent stream %j', options); return this.innerApiCalls.streamingDetectIntent(null, options); } @@ -3708,6 +3829,7 @@ export class SessionsClient { close(): Promise { if (this.sessionsStub && !this._terminated) { return this.sessionsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/test_cases_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/test_cases_client.ts index ff9b1530844..33a11a8c3df 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/test_cases_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/test_cases_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -59,6 +60,8 @@ export class TestCasesClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -95,7 +98,7 @@ export class TestCasesClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -701,7 +704,36 @@ export class TestCasesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.batchDeleteTestCases(request, options, callback); + this._log.info('batchDeleteTestCases request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IBatchDeleteTestCasesRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('batchDeleteTestCases response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .batchDeleteTestCases(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IBatchDeleteTestCasesRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('batchDeleteTestCases response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Gets a test case. @@ -793,7 +825,36 @@ export class TestCasesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getTestCase(request, options, callback); + this._log.info('getTestCase request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ITestCase, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetTestCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getTestCase response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getTestCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ITestCase, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetTestCaseRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getTestCase response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates a test case for the given agent. @@ -892,7 +953,36 @@ export class TestCasesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createTestCase(request, options, callback); + this._log.info('createTestCase request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ITestCase, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateTestCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createTestCase response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createTestCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ITestCase, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateTestCaseRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createTestCase response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified test case. @@ -994,7 +1084,36 @@ export class TestCasesClient { 'test_case.name': request.testCase!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateTestCase(request, options, callback); + this._log.info('updateTestCase request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ITestCase, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateTestCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateTestCase response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateTestCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ITestCase, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateTestCaseRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateTestCase response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Calculates the test coverage for an agent. @@ -1093,7 +1212,36 @@ export class TestCasesClient { agent: request.agent ?? '', }); this.initialize(); - return this.innerApiCalls.calculateCoverage(request, options, callback); + this._log.info('calculateCoverage request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ICalculateCoverageResponse, + | protos.google.cloud.dialogflow.cx.v3beta1.ICalculateCoverageRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('calculateCoverage response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .calculateCoverage(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ICalculateCoverageResponse, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICalculateCoverageRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('calculateCoverage response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Gets a test case result. @@ -1191,7 +1339,36 @@ export class TestCasesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getTestCaseResult(request, options, callback); + this._log.info('getTestCaseResult request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ITestCaseResult, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetTestCaseResultRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getTestCaseResult response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getTestCaseResult(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ITestCaseResult, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetTestCaseResultRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getTestCaseResult response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1308,7 +1485,37 @@ export class TestCasesClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.runTestCase(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IRunTestCaseResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IRunTestCaseMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('runTestCase response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('runTestCase request %j', request); + return this.innerApiCalls + .runTestCase(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IRunTestCaseResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IRunTestCaseMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('runTestCase response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `runTestCase()`. @@ -1329,6 +1536,7 @@ export class TestCasesClient { protos.google.cloud.dialogflow.cx.v3beta1.RunTestCaseMetadata > > { + this._log.info('runTestCase long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1460,7 +1668,37 @@ export class TestCasesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.batchRunTestCases(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IBatchRunTestCasesResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IBatchRunTestCasesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('batchRunTestCases response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('batchRunTestCases request %j', request); + return this.innerApiCalls + .batchRunTestCases(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IBatchRunTestCasesResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IBatchRunTestCasesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('batchRunTestCases response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `batchRunTestCases()`. @@ -1481,6 +1719,7 @@ export class TestCasesClient { protos.google.cloud.dialogflow.cx.v3beta1.BatchRunTestCasesMetadata > > { + this._log.info('batchRunTestCases long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1620,7 +1859,37 @@ export class TestCasesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.importTestCases(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IImportTestCasesResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IImportTestCasesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('importTestCases response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('importTestCases request %j', request); + return this.innerApiCalls + .importTestCases(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IImportTestCasesResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IImportTestCasesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('importTestCases response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `importTestCases()`. @@ -1641,6 +1910,7 @@ export class TestCasesClient { protos.google.cloud.dialogflow.cx.v3beta1.ImportTestCasesMetadata > > { + this._log.info('importTestCases long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1792,7 +2062,37 @@ export class TestCasesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.exportTestCases(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IExportTestCasesResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IExportTestCasesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('exportTestCases response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('exportTestCases request %j', request); + return this.innerApiCalls + .exportTestCases(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IExportTestCasesResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IExportTestCasesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportTestCases response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `exportTestCases()`. @@ -1813,6 +2113,7 @@ export class TestCasesClient { protos.google.cloud.dialogflow.cx.v3beta1.ExportTestCasesMetadata > > { + this._log.info('exportTestCases long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1928,7 +2229,33 @@ export class TestCasesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listTestCases(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListTestCasesRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListTestCasesResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.ITestCase + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listTestCases values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listTestCases request %j', request); + return this.innerApiCalls + .listTestCases(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ITestCase[], + protos.google.cloud.dialogflow.cx.v3beta1.IListTestCasesRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListTestCasesResponse, + ]) => { + this._log.info('listTestCases values %j', response); + return [response, input, output]; + } + ); } /** @@ -1972,6 +2299,7 @@ export class TestCasesClient { const defaultCallSettings = this._defaults['listTestCases']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listTestCases stream %j', request); return this.descriptors.page.listTestCases.createStream( this.innerApiCalls.listTestCases as GaxCall, request, @@ -2023,6 +2351,7 @@ export class TestCasesClient { const defaultCallSettings = this._defaults['listTestCases']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listTestCases iterate %j', request); return this.descriptors.page.listTestCases.asyncIterate( this.innerApiCalls['listTestCases'] as GaxCall, request as {}, @@ -2155,7 +2484,33 @@ export class TestCasesClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listTestCaseResults(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListTestCaseResultsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListTestCaseResultsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.ITestCaseResult + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listTestCaseResults values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listTestCaseResults request %j', request); + return this.innerApiCalls + .listTestCaseResults(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ITestCaseResult[], + protos.google.cloud.dialogflow.cx.v3beta1.IListTestCaseResultsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListTestCaseResultsResponse, + ]) => { + this._log.info('listTestCaseResults values %j', response); + return [response, input, output]; + } + ); } /** @@ -2224,6 +2579,7 @@ export class TestCasesClient { const defaultCallSettings = this._defaults['listTestCaseResults']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listTestCaseResults stream %j', request); return this.descriptors.page.listTestCaseResults.createStream( this.innerApiCalls.listTestCaseResults as GaxCall, request, @@ -2300,6 +2656,7 @@ export class TestCasesClient { const defaultCallSettings = this._defaults['listTestCaseResults']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listTestCaseResults iterate %j', request); return this.descriptors.page.listTestCaseResults.asyncIterate( this.innerApiCalls['listTestCaseResults'] as GaxCall, request as {}, @@ -4916,6 +5273,7 @@ export class TestCasesClient { close(): Promise { if (this.testCasesStub && !this._terminated) { return this.testCasesStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/tools_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/tools_client.ts index 385a9ffe8a7..b5b9191d952 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/tools_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/tools_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -57,6 +58,8 @@ export class ToolsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -93,7 +96,7 @@ export class ToolsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -659,7 +662,36 @@ export class ToolsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createTool(request, options, callback); + this._log.info('createTool request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ITool, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateToolRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createTool response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createTool(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ITool, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateToolRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createTool response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Retrieves the specified {@link protos.google.cloud.dialogflow.cx.v3beta1.Tool|Tool}. @@ -751,7 +783,33 @@ export class ToolsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getTool(request, options, callback); + this._log.info('getTool request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ITool, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetToolRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getTool response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getTool(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ITool, + protos.google.cloud.dialogflow.cx.v3beta1.IGetToolRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getTool response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Update the specified {@link protos.google.cloud.dialogflow.cx.v3beta1.Tool|Tool}. @@ -844,7 +902,36 @@ export class ToolsClient { 'tool.name': request.tool!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateTool(request, options, callback); + this._log.info('updateTool request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ITool, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateToolRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateTool response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateTool(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ITool, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateToolRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateTool response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes a specified {@link protos.google.cloud.dialogflow.cx.v3beta1.Tool|Tool}. @@ -944,7 +1031,36 @@ export class ToolsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteTool(request, options, callback); + this._log.info('deleteTool request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteToolRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteTool response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteTool(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteToolRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteTool response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates a version for the specified @@ -1045,7 +1161,36 @@ export class ToolsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createToolVersion(request, options, callback); + this._log.info('createToolVersion request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IToolVersion, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateToolVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createToolVersion response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createToolVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IToolVersion, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateToolVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createToolVersion response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Retrieves the specified version of the @@ -1144,7 +1289,36 @@ export class ToolsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getToolVersion(request, options, callback); + this._log.info('getToolVersion request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IToolVersion, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetToolVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getToolVersion response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getToolVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IToolVersion, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetToolVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getToolVersion response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified version of the @@ -1251,7 +1425,36 @@ export class ToolsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteToolVersion(request, options, callback); + this._log.info('deleteToolVersion request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteToolVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteToolVersion response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteToolVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteToolVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteToolVersion response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Retrieves the specified version of the Tool and stores it as the @@ -1350,7 +1553,36 @@ export class ToolsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.restoreToolVersion(request, options, callback); + this._log.info('restoreToolVersion request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IRestoreToolVersionResponse, + | protos.google.cloud.dialogflow.cx.v3beta1.IRestoreToolVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('restoreToolVersion response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .restoreToolVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IRestoreToolVersionResponse, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IRestoreToolVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('restoreToolVersion response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1473,7 +1705,37 @@ export class ToolsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.exportTools(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IExportToolsResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IExportToolsMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('exportTools response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('exportTools request %j', request); + return this.innerApiCalls + .exportTools(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IExportToolsResponse, + protos.google.cloud.dialogflow.cx.v3beta1.IExportToolsMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportTools response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `exportTools()`. @@ -1494,6 +1756,7 @@ export class ToolsClient { protos.google.cloud.dialogflow.cx.v3beta1.ExportToolsMetadata > > { + this._log.info('exportTools long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1607,7 +1870,33 @@ export class ToolsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listTools(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListToolsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListToolsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.ITool + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listTools values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listTools request %j', request); + return this.innerApiCalls + .listTools(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ITool[], + protos.google.cloud.dialogflow.cx.v3beta1.IListToolsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListToolsResponse, + ]) => { + this._log.info('listTools values %j', response); + return [response, input, output]; + } + ); } /** @@ -1648,6 +1937,7 @@ export class ToolsClient { const defaultCallSettings = this._defaults['listTools']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listTools stream %j', request); return this.descriptors.page.listTools.createStream( this.innerApiCalls.listTools as GaxCall, request, @@ -1696,6 +1986,7 @@ export class ToolsClient { const defaultCallSettings = this._defaults['listTools']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listTools iterate %j', request); return this.descriptors.page.listTools.asyncIterate( this.innerApiCalls['listTools'] as GaxCall, request as {}, @@ -1801,7 +2092,33 @@ export class ToolsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listToolVersions(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListToolVersionsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListToolVersionsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IToolVersion + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listToolVersions values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listToolVersions request %j', request); + return this.innerApiCalls + .listToolVersions(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IToolVersion[], + protos.google.cloud.dialogflow.cx.v3beta1.IListToolVersionsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListToolVersionsResponse, + ]) => { + this._log.info('listToolVersions values %j', response); + return [response, input, output]; + } + ); } /** @@ -1843,6 +2160,7 @@ export class ToolsClient { const defaultCallSettings = this._defaults['listToolVersions']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listToolVersions stream %j', request); return this.descriptors.page.listToolVersions.createStream( this.innerApiCalls.listToolVersions as GaxCall, request, @@ -1892,6 +2210,7 @@ export class ToolsClient { const defaultCallSettings = this._defaults['listToolVersions']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listToolVersions iterate %j', request); return this.descriptors.page.listToolVersions.asyncIterate( this.innerApiCalls['listToolVersions'] as GaxCall, request as {}, @@ -4508,6 +4827,7 @@ export class ToolsClient { close(): Promise { if (this.toolsStub && !this._terminated) { return this.toolsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/transition_route_groups_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/transition_route_groups_client.ts index e56be36c400..1af96d1b4e6 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/transition_route_groups_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/transition_route_groups_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -56,6 +57,8 @@ export class TransitionRouteGroupsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -91,7 +94,7 @@ export class TransitionRouteGroupsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -604,11 +607,36 @@ export class TransitionRouteGroupsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getTransitionRouteGroup( - request, - options, - callback - ); + this._log.info('getTransitionRouteGroup request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ITransitionRouteGroup, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetTransitionRouteGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getTransitionRouteGroup response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getTransitionRouteGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ITransitionRouteGroup, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetTransitionRouteGroupRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getTransitionRouteGroup response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates an @@ -729,11 +757,36 @@ export class TransitionRouteGroupsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createTransitionRouteGroup( - request, - options, - callback - ); + this._log.info('createTransitionRouteGroup request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ITransitionRouteGroup, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateTransitionRouteGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createTransitionRouteGroup response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createTransitionRouteGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ITransitionRouteGroup, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateTransitionRouteGroupRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createTransitionRouteGroup response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified @@ -848,11 +901,36 @@ export class TransitionRouteGroupsClient { 'transition_route_group.name': request.transitionRouteGroup!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateTransitionRouteGroup( - request, - options, - callback - ); + this._log.info('updateTransitionRouteGroup request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ITransitionRouteGroup, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateTransitionRouteGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateTransitionRouteGroup response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateTransitionRouteGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ITransitionRouteGroup, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateTransitionRouteGroupRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateTransitionRouteGroup response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified @@ -966,11 +1044,36 @@ export class TransitionRouteGroupsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteTransitionRouteGroup( - request, - options, - callback - ); + this._log.info('deleteTransitionRouteGroup request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteTransitionRouteGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteTransitionRouteGroup response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteTransitionRouteGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteTransitionRouteGroupRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteTransitionRouteGroup response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1085,11 +1188,33 @@ export class TransitionRouteGroupsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listTransitionRouteGroups( - request, - options, - callback - ); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListTransitionRouteGroupsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListTransitionRouteGroupsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.ITransitionRouteGroup + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listTransitionRouteGroups values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listTransitionRouteGroups request %j', request); + return this.innerApiCalls + .listTransitionRouteGroups(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ITransitionRouteGroup[], + protos.google.cloud.dialogflow.cx.v3beta1.IListTransitionRouteGroupsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListTransitionRouteGroupsResponse, + ]) => { + this._log.info('listTransitionRouteGroups values %j', response); + return [response, input, output]; + } + ); } /** @@ -1145,6 +1270,7 @@ export class TransitionRouteGroupsClient { const defaultCallSettings = this._defaults['listTransitionRouteGroups']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listTransitionRouteGroups stream %j', request); return this.descriptors.page.listTransitionRouteGroups.createStream( this.innerApiCalls.listTransitionRouteGroups as GaxCall, request, @@ -1208,6 +1334,7 @@ export class TransitionRouteGroupsClient { const defaultCallSettings = this._defaults['listTransitionRouteGroups']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listTransitionRouteGroups iterate %j', request); return this.descriptors.page.listTransitionRouteGroups.asyncIterate( this.innerApiCalls['listTransitionRouteGroups'] as GaxCall, request as {}, @@ -3600,6 +3727,7 @@ export class TransitionRouteGroupsClient { close(): Promise { if (this.transitionRouteGroupsStub && !this._terminated) { return this.transitionRouteGroupsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/versions_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/versions_client.ts index 4a4d665d068..27b30842229 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/versions_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/versions_client.ts @@ -33,6 +33,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -57,6 +58,8 @@ export class VersionsClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -93,7 +96,7 @@ export class VersionsClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -660,7 +663,36 @@ export class VersionsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getVersion(request, options, callback); + this._log.info('getVersion request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IVersion, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getVersion response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IVersion, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getVersion response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified @@ -760,7 +792,36 @@ export class VersionsClient { 'version.name': request.version!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateVersion(request, options, callback); + this._log.info('updateVersion request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IVersion, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateVersion response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IVersion, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateVersion response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified @@ -859,7 +920,36 @@ export class VersionsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteVersion(request, options, callback); + this._log.info('deleteVersion request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteVersion response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteVersion response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Compares the specified base version with target version. @@ -972,7 +1062,36 @@ export class VersionsClient { base_version: request.baseVersion ?? '', }); this.initialize(); - return this.innerApiCalls.compareVersions(request, options, callback); + this._log.info('compareVersions request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.ICompareVersionsResponse, + | protos.google.cloud.dialogflow.cx.v3beta1.ICompareVersionsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('compareVersions response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .compareVersions(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.ICompareVersionsResponse, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICompareVersionsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('compareVersions response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -1088,7 +1207,37 @@ export class VersionsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createVersion(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IVersion, + protos.google.cloud.dialogflow.cx.v3beta1.ICreateVersionOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('createVersion response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('createVersion request %j', request); + return this.innerApiCalls + .createVersion(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.dialogflow.cx.v3beta1.IVersion, + protos.google.cloud.dialogflow.cx.v3beta1.ICreateVersionOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createVersion response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `createVersion()`. @@ -1109,6 +1258,7 @@ export class VersionsClient { protos.google.cloud.dialogflow.cx.v3beta1.CreateVersionOperationMetadata > > { + this._log.info('createVersion long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1240,7 +1390,37 @@ export class VersionsClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.loadVersion(request, options, callback); + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('loadVersion response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('loadVersion request %j', request); + return this.innerApiCalls + .loadVersion(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.protobuf.IStruct + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('loadVersion response %j', rawResponse); + return [response, rawResponse, _]; + } + ); } /** * Check the status of the long running operation returned by `loadVersion()`. @@ -1258,6 +1438,7 @@ export class VersionsClient { ): Promise< LROperation > { + this._log.info('loadVersion long-running'); const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( {name} @@ -1372,7 +1553,33 @@ export class VersionsClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listVersions(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListVersionsRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListVersionsResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IVersion + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listVersions values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listVersions request %j', request); + return this.innerApiCalls + .listVersions(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IVersion[], + protos.google.cloud.dialogflow.cx.v3beta1.IListVersionsRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListVersionsResponse, + ]) => { + this._log.info('listVersions values %j', response); + return [response, input, output]; + } + ); } /** @@ -1414,6 +1621,7 @@ export class VersionsClient { const defaultCallSettings = this._defaults['listVersions']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listVersions stream %j', request); return this.descriptors.page.listVersions.createStream( this.innerApiCalls.listVersions as GaxCall, request, @@ -1463,6 +1671,7 @@ export class VersionsClient { const defaultCallSettings = this._defaults['listVersions']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listVersions iterate %j', request); return this.descriptors.page.listVersions.asyncIterate( this.innerApiCalls['listVersions'] as GaxCall, request as {}, @@ -4079,6 +4288,7 @@ export class VersionsClient { close(): Promise { if (this.versionsStub && !this._terminated) { return this.versionsStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/src/v3beta1/webhooks_client.ts b/packages/google-cloud-dialogflow-cx/src/v3beta1/webhooks_client.ts index ad4cd521c50..56052323b52 100644 --- a/packages/google-cloud-dialogflow-cx/src/v3beta1/webhooks_client.ts +++ b/packages/google-cloud-dialogflow-cx/src/v3beta1/webhooks_client.ts @@ -31,6 +31,7 @@ import type { import {Transform} from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -55,6 +56,8 @@ export class WebhooksClient { private _defaults: {[method: string]: gax.CallSettings}; private _universeDomain: string; private _servicePath: string; + private _log = logging.log('dialogflow-cx'); + auth: gax.GoogleAuth; descriptors: Descriptors = { page: {}, @@ -90,7 +93,7 @@ export class WebhooksClient { * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * {@link https://cloud.google.com/docs/authentication/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. @@ -585,7 +588,36 @@ export class WebhooksClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.getWebhook(request, options, callback); + this._log.info('getWebhook request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IWebhook, + | protos.google.cloud.dialogflow.cx.v3beta1.IGetWebhookRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getWebhook response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getWebhook(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IWebhook, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IGetWebhookRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getWebhook response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Creates a webhook in the specified agent. @@ -684,7 +716,36 @@ export class WebhooksClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.createWebhook(request, options, callback); + this._log.info('createWebhook request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IWebhook, + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateWebhookRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('createWebhook response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .createWebhook(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IWebhook, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.ICreateWebhookRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createWebhook response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Updates the specified webhook. @@ -783,7 +844,36 @@ export class WebhooksClient { 'webhook.name': request.webhook!.name ?? '', }); this.initialize(); - return this.innerApiCalls.updateWebhook(request, options, callback); + this._log.info('updateWebhook request %j', request); + const wrappedCallback: + | Callback< + protos.google.cloud.dialogflow.cx.v3beta1.IWebhook, + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateWebhookRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('updateWebhook response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .updateWebhook(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IWebhook, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IUpdateWebhookRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateWebhook response %j', response); + return [response, options, rawResponse]; + } + ); } /** * Deletes the specified webhook. @@ -892,7 +982,36 @@ export class WebhooksClient { name: request.name ?? '', }); this.initialize(); - return this.innerApiCalls.deleteWebhook(request, options, callback); + this._log.info('deleteWebhook request %j', request); + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteWebhookRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('deleteWebhook response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .deleteWebhook(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.dialogflow.cx.v3beta1.IDeleteWebhookRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteWebhook response %j', response); + return [response, options, rawResponse]; + } + ); } /** @@ -992,7 +1111,33 @@ export class WebhooksClient { parent: request.parent ?? '', }); this.initialize(); - return this.innerApiCalls.listWebhooks(request, options, callback); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.dialogflow.cx.v3beta1.IListWebhooksRequest, + | protos.google.cloud.dialogflow.cx.v3beta1.IListWebhooksResponse + | null + | undefined, + protos.google.cloud.dialogflow.cx.v3beta1.IWebhook + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listWebhooks values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listWebhooks request %j', request); + return this.innerApiCalls + .listWebhooks(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.cloud.dialogflow.cx.v3beta1.IWebhook[], + protos.google.cloud.dialogflow.cx.v3beta1.IListWebhooksRequest | null, + protos.google.cloud.dialogflow.cx.v3beta1.IListWebhooksResponse, + ]) => { + this._log.info('listWebhooks values %j', response); + return [response, input, output]; + } + ); } /** @@ -1033,6 +1178,7 @@ export class WebhooksClient { const defaultCallSettings = this._defaults['listWebhooks']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listWebhooks stream %j', request); return this.descriptors.page.listWebhooks.createStream( this.innerApiCalls.listWebhooks as GaxCall, request, @@ -1081,6 +1227,7 @@ export class WebhooksClient { const defaultCallSettings = this._defaults['listWebhooks']; const callSettings = defaultCallSettings.merge(options); this.initialize(); + this._log.info('listWebhooks iterate %j', request); return this.descriptors.page.listWebhooks.asyncIterate( this.innerApiCalls['listWebhooks'] as GaxCall, request as {}, @@ -3659,6 +3806,7 @@ export class WebhooksClient { close(): Promise { if (this.webhooksStub && !this._terminated) { return this.webhooksStub.then(stub => { + this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); this.locationsClient.close(); diff --git a/packages/google-cloud-dialogflow-cx/tsconfig.json b/packages/google-cloud-dialogflow-cx/tsconfig.json index 8c2c889a70c..860d6bf027b 100644 --- a/packages/google-cloud-dialogflow-cx/tsconfig.json +++ b/packages/google-cloud-dialogflow-cx/tsconfig.json @@ -18,4 +18,4 @@ "src/**/*.json", "protos/protos.json" ] -} \ No newline at end of file +}