@@ -54,8 +54,10 @@ export class OsLoginServiceClient {
5454 /**
5555 * Construct an instance of OsLoginServiceClient.
5656 *
57- * @param {object } [options] - The configuration object. See the subsequent
58- * parameters for more details.
57+ * @param {object } [options] - The configuration object.
58+ * The options accepted by the constructor are described in detail
59+ * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
60+ * The common options are:
5961 * @param {object } [options.credentials] - Credentials object.
6062 * @param {string } [options.credentials.client_email]
6163 * @param {string } [options.credentials.private_key]
@@ -75,42 +77,33 @@ export class OsLoginServiceClient {
7577 * your project ID will be detected automatically.
7678 * @param {string } [options.apiEndpoint] - The domain name of the
7779 * API remote host.
80+ * @param {gax.ClientConfig } [options.clientConfig] - client configuration override.
81+ * TODO(@alexander-fenster): link to gax documentation.
82+ * @param {boolean } fallback - Use HTTP fallback mode.
83+ * In fallback mode, a special browser-compatible transport implementation is used
84+ * instead of gRPC transport. In browser context (if the `window` object is defined)
85+ * the fallback mode is enabled automatically; set `options.fallback` to `false`
86+ * if you need to override this behavior.
7887 */
79-
8088 constructor ( opts ?: ClientOptions ) {
81- // Ensure that options include the service address and port .
89+ // Ensure that options include all the required fields .
8290 const staticMembers = this . constructor as typeof OsLoginServiceClient ;
8391 const servicePath =
84- opts && opts . servicePath
85- ? opts . servicePath
86- : opts && opts . apiEndpoint
87- ? opts . apiEndpoint
88- : staticMembers . servicePath ;
89- const port = opts && opts . port ? opts . port : staticMembers . port ;
90-
91- if ( ! opts ) {
92- opts = { servicePath , port } ;
92+ opts ?. servicePath || opts ?. apiEndpoint || staticMembers . servicePath ;
93+ const port = opts ?. port || staticMembers . port ;
94+ const clientConfig = opts ?. clientConfig ?? { } ;
95+ const fallback = opts ?. fallback ?? typeof window !== 'undefined' ;
96+ opts = Object . assign ( { servicePath , port , clientConfig , fallback } , opts ) ;
97+
98+ // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case.
99+ if ( servicePath !== staticMembers . servicePath && ! ( 'scopes' in opts ) ) {
100+ opts [ 'scopes' ] = staticMembers . scopes ;
93101 }
94- opts . servicePath = opts . servicePath || servicePath ;
95- opts . port = opts . port || port ;
96-
97- // users can override the config from client side, like retry codes name.
98- // The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
99- // The way to override client config for Showcase API:
100- //
101- // const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
102- // const showcaseClient = new showcaseClient({ projectId, customConfig });
103- opts . clientConfig = opts . clientConfig || { } ;
104-
105- // If we're running in browser, it's OK to omit `fallback` since
106- // google-gax has `browser` field in its `package.json`.
107- // For Electron (which does not respect `browser` field),
108- // pass `{fallback: true}` to the OsLoginServiceClient constructor.
102+
103+ // Choose either gRPC or proto-over-HTTP implementation of google-gax.
109104 this . _gaxModule = opts . fallback ? gax . fallback : gax ;
110105
111- // Create a `gaxGrpc` object, with any grpc-specific options
112- // sent to the client.
113- opts . scopes = ( this . constructor as typeof OsLoginServiceClient ) . scopes ;
106+ // Create a `gaxGrpc` object, with any grpc-specific options sent to the client.
114107 this . _gaxGrpc = new this . _gaxModule . GrpcClient ( opts ) ;
115108
116109 // Save options to use in initialize() method.
@@ -119,6 +112,11 @@ export class OsLoginServiceClient {
119112 // Save the auth object to the client, for use by other methods.
120113 this . auth = this . _gaxGrpc . auth as gax . GoogleAuth ;
121114
115+ // Set the default scopes in auth client if needed.
116+ if ( servicePath === staticMembers . servicePath ) {
117+ this . auth . defaultScopes = staticMembers . scopes ;
118+ }
119+
122120 // Determine the client header string.
123121 const clientHeader = [ `gax/${ this . _gaxModule . version } ` , `gapic/${ version } ` ] ;
124122 if ( typeof process !== 'undefined' && 'versions' in process ) {
@@ -245,6 +243,7 @@ export class OsLoginServiceClient {
245243
246244 /**
247245 * The DNS address for this API service.
246+ * @returns {string } The DNS address for this service.
248247 */
249248 static get servicePath ( ) {
250249 return 'oslogin.googleapis.com' ;
@@ -253,13 +252,15 @@ export class OsLoginServiceClient {
253252 /**
254253 * The DNS address for this API service - same as servicePath(),
255254 * exists for compatibility reasons.
255+ * @returns {string } The DNS address for this service.
256256 */
257257 static get apiEndpoint ( ) {
258258 return 'oslogin.googleapis.com' ;
259259 }
260260
261261 /**
262262 * The port for this API service.
263+ * @returns {number } The default port for this service.
263264 */
264265 static get port ( ) {
265266 return 443 ;
@@ -268,6 +269,7 @@ export class OsLoginServiceClient {
268269 /**
269270 * The scopes needed to make gRPC calls for every method defined
270271 * in this service.
272+ * @returns {string[] } List of default scopes.
271273 */
272274 static get scopes ( ) {
273275 return [
@@ -280,8 +282,7 @@ export class OsLoginServiceClient {
280282 getProjectId ( callback : Callback < string , undefined , undefined > ) : void ;
281283 /**
282284 * Return the project ID used by this class.
283- * @param {function(Error, string) } callback - the callback to
284- * be called with the current project Id.
285+ * @returns {Promise } A promise that resolves to string containing the project ID.
285286 */
286287 getProjectId (
287288 callback ?: Callback < string , undefined , undefined >
@@ -340,7 +341,11 @@ export class OsLoginServiceClient {
340341 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
341342 * @returns {Promise } - The promise which resolves to an array.
342343 * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}.
343- * The promise has a method named "cancel" which cancels the ongoing API call.
344+ * Please see the
345+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
346+ * for more details and examples.
347+ * @example
348+ * const [response] = await client.deletePosixAccount(request);
344349 */
345350 deletePosixAccount (
346351 request : protos . google . cloud . oslogin . v1 . IDeletePosixAccountRequest ,
@@ -430,7 +435,11 @@ export class OsLoginServiceClient {
430435 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
431436 * @returns {Promise } - The promise which resolves to an array.
432437 * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}.
433- * The promise has a method named "cancel" which cancels the ongoing API call.
438+ * Please see the
439+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
440+ * for more details and examples.
441+ * @example
442+ * const [response] = await client.deleteSshPublicKey(request);
434443 */
435444 deleteSshPublicKey (
436445 request : protos . google . cloud . oslogin . v1 . IDeleteSshPublicKeyRequest ,
@@ -519,7 +528,11 @@ export class OsLoginServiceClient {
519528 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
520529 * @returns {Promise } - The promise which resolves to an array.
521530 * The first element of the array is an object representing [LoginProfile]{@link google.cloud.oslogin.v1.LoginProfile}.
522- * The promise has a method named "cancel" which cancels the ongoing API call.
531+ * Please see the
532+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
533+ * for more details and examples.
534+ * @example
535+ * const [response] = await client.getLoginProfile(request);
523536 */
524537 getLoginProfile (
525538 request : protos . google . cloud . oslogin . v1 . IGetLoginProfileRequest ,
@@ -603,7 +616,11 @@ export class OsLoginServiceClient {
603616 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
604617 * @returns {Promise } - The promise which resolves to an array.
605618 * The first element of the array is an object representing [SshPublicKey]{@link google.cloud.oslogin.common.SshPublicKey}.
606- * The promise has a method named "cancel" which cancels the ongoing API call.
619+ * Please see the
620+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
621+ * for more details and examples.
622+ * @example
623+ * const [response] = await client.getSshPublicKey(request);
607624 */
608625 getSshPublicKey (
609626 request : protos . google . cloud . oslogin . v1 . IGetSshPublicKeyRequest ,
@@ -695,7 +712,11 @@ export class OsLoginServiceClient {
695712 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
696713 * @returns {Promise } - The promise which resolves to an array.
697714 * The first element of the array is an object representing [ImportSshPublicKeyResponse]{@link google.cloud.oslogin.v1.ImportSshPublicKeyResponse}.
698- * The promise has a method named "cancel" which cancels the ongoing API call.
715+ * Please see the
716+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
717+ * for more details and examples.
718+ * @example
719+ * const [response] = await client.importSshPublicKey(request);
699720 */
700721 importSshPublicKey (
701722 request : protos . google . cloud . oslogin . v1 . IImportSshPublicKeyRequest ,
@@ -790,7 +811,11 @@ export class OsLoginServiceClient {
790811 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
791812 * @returns {Promise } - The promise which resolves to an array.
792813 * The first element of the array is an object representing [SshPublicKey]{@link google.cloud.oslogin.common.SshPublicKey}.
793- * The promise has a method named "cancel" which cancels the ongoing API call.
814+ * Please see the
815+ * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
816+ * for more details and examples.
817+ * @example
818+ * const [response] = await client.updateSshPublicKey(request);
794819 */
795820 updateSshPublicKey (
796821 request : protos . google . cloud . oslogin . v1 . IUpdateSshPublicKeyRequest ,
@@ -941,9 +966,10 @@ export class OsLoginServiceClient {
941966 }
942967
943968 /**
944- * Terminate the GRPC channel and close the client.
969+ * Terminate the gRPC channel and close the client.
945970 *
946971 * The client will no longer be usable and all future behavior is undefined.
972+ * @returns {Promise } A promise that resolves when the client is closed.
947973 */
948974 close ( ) : Promise < void > {
949975 this . initialize ( ) ;
0 commit comments