@@ -61,8 +61,10 @@ export class DashboardsServiceClient {
61
61
/**
62
62
* Construct an instance of DashboardsServiceClient.
63
63
*
64
- * @param {object } [options] - The configuration object. See the subsequent
65
- * parameters for more details.
64
+ * @param {object } [options] - The configuration object.
65
+ * The options accepted by the constructor are described in detail
66
+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
67
+ * The common options are:
66
68
* @param {object } [options.credentials] - Credentials object.
67
69
* @param {string } [options.credentials.client_email]
68
70
* @param {string } [options.credentials.private_key]
@@ -82,42 +84,33 @@ export class DashboardsServiceClient {
82
84
* your project ID will be detected automatically.
83
85
* @param {string } [options.apiEndpoint] - The domain name of the
84
86
* API remote host.
87
+ * @param {gax.ClientConfig } [options.clientConfig] - client configuration override.
88
+ * TODO(@alexander-fenster): link to gax documentation.
89
+ * @param {boolean } fallback - Use HTTP fallback mode.
90
+ * In fallback mode, a special browser-compatible transport implementation is used
91
+ * instead of gRPC transport. In browser context (if the `window` object is defined)
92
+ * the fallback mode is enabled automatically; set `options.fallback` to `false`
93
+ * if you need to override this behavior.
85
94
*/
86
-
87
95
constructor ( opts ?: ClientOptions ) {
88
- // Ensure that options include the service address and port .
96
+ // Ensure that options include all the required fields .
89
97
const staticMembers = this . constructor as typeof DashboardsServiceClient ;
90
98
const servicePath =
91
- opts && opts . servicePath
92
- ? opts . servicePath
93
- : opts && opts . apiEndpoint
94
- ? opts . apiEndpoint
95
- : staticMembers . servicePath ;
96
- const port = opts && opts . port ? opts . port : staticMembers . port ;
97
-
98
- if ( ! opts ) {
99
- opts = { servicePath , port } ;
99
+ opts ?. servicePath || opts ?. apiEndpoint || staticMembers . servicePath ;
100
+ const port = opts ?. port || staticMembers . port ;
101
+ const clientConfig = opts ?. clientConfig ?? { } ;
102
+ const fallback = opts ?. fallback ?? typeof window !== 'undefined' ;
103
+ opts = Object . assign ( { servicePath , port , clientConfig , fallback } , opts ) ;
104
+
105
+ // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
106
+ if ( servicePath !== staticMembers . servicePath && ! ( 'scopes' in opts ) ) {
107
+ opts [ 'scopes' ] = staticMembers . scopes ;
100
108
}
101
- opts . servicePath = opts . servicePath || servicePath ;
102
- opts . port = opts . port || port ;
103
-
104
- // users can override the config from client side, like retry codes name.
105
- // The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
106
- // The way to override client config for Showcase API:
107
- //
108
- // const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
109
- // const showcaseClient = new showcaseClient({ projectId, customConfig });
110
- opts . clientConfig = opts . clientConfig || { } ;
111
-
112
- // If we're running in browser, it's OK to omit `fallback` since
113
- // google-gax has `browser` field in its `package.json`.
114
- // For Electron (which does not respect `browser` field),
115
- // pass `{fallback: true}` to the DashboardsServiceClient constructor.
109
+
110
+ // Choose either gRPC or proto-over-HTTP implementation of google-gax.
116
111
this . _gaxModule = opts . fallback ? gax . fallback : gax ;
117
112
118
- // Create a `gaxGrpc` object, with any grpc-specific options
119
- // sent to the client.
120
- opts . scopes = ( this . constructor as typeof DashboardsServiceClient ) . scopes ;
113
+ // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
121
114
this . _gaxGrpc = new this . _gaxModule . GrpcClient ( opts ) ;
122
115
123
116
// Save options to use in initialize() method.
@@ -126,6 +119,11 @@ export class DashboardsServiceClient {
126
119
// Save the auth object to the client, for use by other methods.
127
120
this . auth = this . _gaxGrpc . auth as gax . GoogleAuth ;
128
121
122
+ // Set the default scopes in auth client if needed.
123
+ if ( servicePath === staticMembers . servicePath ) {
124
+ this . auth . defaultScopes = staticMembers . scopes ;
125
+ }
126
+
129
127
// Determine the client header string.
130
128
const clientHeader = [ `gax/${ this . _gaxModule . version } ` , `gapic/${ version } ` ] ;
131
129
if ( typeof process !== 'undefined' && 'versions' in process ) {
@@ -262,6 +260,7 @@ export class DashboardsServiceClient {
262
260
263
261
/**
264
262
* The DNS address for this API service.
263
+ * @returns {string } The DNS address for this service.
265
264
*/
266
265
static get servicePath ( ) {
267
266
return 'monitoring.googleapis.com' ;
@@ -270,13 +269,15 @@ export class DashboardsServiceClient {
270
269
/**
271
270
* The DNS address for this API service - same as servicePath(),
272
271
* exists for compatibility reasons.
272
+ * @returns {string } The DNS address for this service.
273
273
*/
274
274
static get apiEndpoint ( ) {
275
275
return 'monitoring.googleapis.com' ;
276
276
}
277
277
278
278
/**
279
279
* The port for this API service.
280
+ * @returns {number } The default port for this service.
280
281
*/
281
282
static get port ( ) {
282
283
return 443 ;
@@ -285,6 +286,7 @@ export class DashboardsServiceClient {
285
286
/**
286
287
* The scopes needed to make gRPC calls for every method defined
287
288
* in this service.
289
+ * @returns {string[] } List of default scopes.
288
290
*/
289
291
static get scopes ( ) {
290
292
return [
@@ -299,8 +301,7 @@ export class DashboardsServiceClient {
299
301
getProjectId ( callback : Callback < string , undefined , undefined > ) : void ;
300
302
/**
301
303
* Return the project ID used by this class.
302
- * @param {function(Error, string) } callback - the callback to
303
- * be called with the current project Id.
304
+ * @returns {Promise } A promise that resolves to string containing the project ID.
304
305
*/
305
306
getProjectId (
306
307
callback ?: Callback < string , undefined , undefined >
@@ -367,7 +368,11 @@ export class DashboardsServiceClient {
367
368
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
368
369
* @returns {Promise } - The promise which resolves to an array.
369
370
* The first element of the array is an object representing [Dashboard]{@link google.monitoring.dashboard.v1.Dashboard}.
370
- * The promise has a method named "cancel" which cancels the ongoing API call.
371
+ * Please see the
372
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
373
+ * for more details and examples.
374
+ * @example
375
+ * const [response] = await client.createDashboard(request);
371
376
*/
372
377
createDashboard (
373
378
request : protos . google . monitoring . dashboard . v1 . ICreateDashboardRequest ,
@@ -463,7 +468,11 @@ export class DashboardsServiceClient {
463
468
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
464
469
* @returns {Promise } - The promise which resolves to an array.
465
470
* The first element of the array is an object representing [Dashboard]{@link google.monitoring.dashboard.v1.Dashboard}.
466
- * The promise has a method named "cancel" which cancels the ongoing API call.
471
+ * Please see the
472
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
473
+ * for more details and examples.
474
+ * @example
475
+ * const [response] = await client.getDashboard(request);
467
476
*/
468
477
getDashboard (
469
478
request : protos . google . monitoring . dashboard . v1 . IGetDashboardRequest ,
@@ -557,7 +566,11 @@ export class DashboardsServiceClient {
557
566
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
558
567
* @returns {Promise } - The promise which resolves to an array.
559
568
* The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}.
560
- * The promise has a method named "cancel" which cancels the ongoing API call.
569
+ * Please see the
570
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
571
+ * for more details and examples.
572
+ * @example
573
+ * const [response] = await client.deleteDashboard(request);
561
574
*/
562
575
deleteDashboard (
563
576
request : protos . google . monitoring . dashboard . v1 . IDeleteDashboardRequest ,
@@ -649,7 +662,11 @@ export class DashboardsServiceClient {
649
662
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
650
663
* @returns {Promise } - The promise which resolves to an array.
651
664
* The first element of the array is an object representing [Dashboard]{@link google.monitoring.dashboard.v1.Dashboard}.
652
- * The promise has a method named "cancel" which cancels the ongoing API call.
665
+ * Please see the
666
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
667
+ * for more details and examples.
668
+ * @example
669
+ * const [response] = await client.updateDashboard(request);
653
670
*/
654
671
updateDashboard (
655
672
request : protos . google . monitoring . dashboard . v1 . IUpdateDashboardRequest ,
@@ -751,19 +768,14 @@ export class DashboardsServiceClient {
751
768
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
752
769
* @returns {Promise } - The promise which resolves to an array.
753
770
* The first element of the array is Array of [Dashboard]{@link google.monitoring.dashboard.v1.Dashboard}.
754
- * The client library support auto-pagination by default: it will call the API as many
771
+ * The client library will perform auto-pagination by default: it will call the API as many
755
772
* times as needed and will merge results from all the pages into this array.
756
- *
757
- * When autoPaginate: false is specified through options, the array has three elements.
758
- * The first element is Array of [Dashboard]{@link google.monitoring.dashboard.v1.Dashboard} that corresponds to
759
- * the one page received from the API server.
760
- * If the second element is not null it contains the request object of type [ListDashboardsRequest]{@link google.monitoring.dashboard.v1.ListDashboardsRequest}
761
- * that can be used to obtain the next page of the results.
762
- * If it is null, the next page does not exist.
763
- * The third element contains the raw response received from the API server. Its type is
764
- * [ListDashboardsResponse]{@link google.monitoring.dashboard.v1.ListDashboardsResponse}.
765
- *
766
- * The promise has a method named "cancel" which cancels the ongoing API call.
773
+ * Note that it can affect your quota.
774
+ * We recommend using `listDashboardsAsync()`
775
+ * method described below for async iteration which you can stop as needed.
776
+ * Please see the
777
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
778
+ * for more details and examples.
767
779
*/
768
780
listDashboards (
769
781
request : protos . google . monitoring . dashboard . v1 . IListDashboardsRequest ,
@@ -811,18 +823,7 @@ export class DashboardsServiceClient {
811
823
}
812
824
813
825
/**
814
- * Equivalent to {@link listDashboards}, but returns a NodeJS Stream object.
815
- *
816
- * This fetches the paged responses for {@link listDashboards} continuously
817
- * and invokes the callback registered for 'data' event for each element in the
818
- * responses.
819
- *
820
- * The returned object has 'end' method when no more elements are required.
821
- *
822
- * autoPaginate option will be ignored.
823
- *
824
- * @see {@link https://nodejs.org/api/stream.html }
825
- *
826
+ * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object.
826
827
* @param {Object } request
827
828
* The request object that will be sent.
828
829
* @param {string } request.parent
@@ -840,6 +841,13 @@ export class DashboardsServiceClient {
840
841
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
841
842
* @returns {Stream }
842
843
* An object stream which emits an object representing [Dashboard]{@link google.monitoring.dashboard.v1.Dashboard} on 'data' event.
844
+ * The client library will perform auto-pagination by default: it will call the API as many
845
+ * times as needed. Note that it can affect your quota.
846
+ * We recommend using `listDashboardsAsync()`
847
+ * method described below for async iteration which you can stop as needed.
848
+ * Please see the
849
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
850
+ * for more details and examples.
843
851
*/
844
852
listDashboardsStream (
845
853
request ?: protos . google . monitoring . dashboard . v1 . IListDashboardsRequest ,
@@ -864,10 +872,9 @@ export class DashboardsServiceClient {
864
872
}
865
873
866
874
/**
867
- * Equivalent to {@link listDashboards}, but returns an iterable object.
868
- *
869
- * for-await-of syntax is used with the iterable to recursively get response element on-demand.
875
+ * Equivalent to `listDashboards`, but returns an iterable object.
870
876
*
877
+ * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
871
878
* @param {Object } request
872
879
* The request object that will be sent.
873
880
* @param {string } request.parent
@@ -884,7 +891,18 @@ export class DashboardsServiceClient {
884
891
* @param {object } [options]
885
892
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
886
893
* @returns {Object }
887
- * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
894
+ * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
895
+ * When you iterate the returned iterable, each element will be an object representing
896
+ * [Dashboard]{@link google.monitoring.dashboard.v1.Dashboard}. The API will be called under the hood as needed, once per the page,
897
+ * so you can stop the iteration when you don't need more results.
898
+ * Please see the
899
+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
900
+ * for more details and examples.
901
+ * @example
902
+ * const iterable = client.listDashboardsAsync(request);
903
+ * for await (const response of iterable) {
904
+ * // process response
905
+ * }
888
906
*/
889
907
listDashboardsAsync (
890
908
request ?: protos . google . monitoring . dashboard . v1 . IListDashboardsRequest ,
@@ -974,9 +992,10 @@ export class DashboardsServiceClient {
974
992
}
975
993
976
994
/**
977
- * Terminate the GRPC channel and close the client.
995
+ * Terminate the gRPC channel and close the client.
978
996
*
979
997
* The client will no longer be usable and all future behavior is undefined.
998
+ * @returns {Promise } A promise that resolves when the client is closed.
980
999
*/
981
1000
close ( ) : Promise < void > {
982
1001
this . initialize ( ) ;
0 commit comments