diff --git a/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts b/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts index 5786a3af2817..68498eb35d31 100644 --- a/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts +++ b/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts @@ -41,12 +41,7 @@ export class OsLoginServiceClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; + descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; innerApiCalls: {[name: string]: Function}; pathTemplates: {[name: string]: gax.PathTemplate}; osLoginServiceStub?: Promise<{[name: string]: Function}>; @@ -80,12 +75,10 @@ export class OsLoginServiceClient { constructor(opts?: ClientOptions) { // Ensure that options include the service address and port. const staticMembers = this.constructor as typeof OsLoginServiceClient; - const servicePath = - opts && opts.servicePath - ? opts.servicePath - : opts && opts.apiEndpoint - ? opts.apiEndpoint - : staticMembers.servicePath; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); const port = opts && opts.port ? opts.port : staticMembers.port; if (!opts) { @@ -95,8 +88,8 @@ export class OsLoginServiceClient { opts.port = opts.port || port; opts.clientConfig = opts.clientConfig || {}; - const isBrowser = typeof window !== 'undefined'; - if (isBrowser) { + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ opts.fallback = true; } // If we are in browser, we are already using fallback because of the @@ -113,10 +106,13 @@ export class OsLoginServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); // Determine the client header string. - const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -132,18 +128,12 @@ export class OsLoginServiceClient { // For Node.js, pass the path to JSON proto file. // For browsers, pass the JSON content. - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); this._protos = this._gaxGrpc.loadProto( - opts.fallback - ? // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - : nodejsProtoPath + opts.fallback ? + // eslint-disable-next-line @typescript-eslint/no-var-requires + require("../../protos/protos.json") : + nodejsProtoPath ); // This API contains "path templates"; forward-slash-separated @@ -156,16 +146,15 @@ export class OsLoginServiceClient { sshPublicKeyPathTemplate: new this._gaxModule.PathTemplate( 'users/{user}/sshPublicKeys/{fingerprint}' ), - userPathTemplate: new this._gaxModule.PathTemplate('users/{user}'), + userPathTemplate: new this._gaxModule.PathTemplate( + 'users/{user}' + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.oslogin.v1.OsLoginService', - gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, - {'x-goog-api-client': clientHeader.join(' ')} - ); + 'google.cloud.oslogin.v1.OsLoginService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -193,25 +182,16 @@ export class OsLoginServiceClient { // Put together the "service stub" for // google.cloud.oslogin.v1.OsLoginService. this.osLoginServiceStub = this._gaxGrpc.createStub( - this._opts.fallback - ? (this._protos as protobuf.Root).lookupService( - 'google.cloud.oslogin.v1.OsLoginService' - ) - : // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.oslogin.v1.OsLoginService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.oslogin.v1.OsLoginService, - this._opts - ) as Promise<{[method: string]: Function}>; + this._opts) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const osLoginServiceStubMethods = [ - 'deletePosixAccount', - 'deleteSshPublicKey', - 'getLoginProfile', - 'getSshPublicKey', - 'importSshPublicKey', - 'updateSshPublicKey', - ]; + const osLoginServiceStubMethods = + ['deletePosixAccount', 'deleteSshPublicKey', 'getLoginProfile', 'getSshPublicKey', 'importSshPublicKey', 'updateSshPublicKey']; for (const methodName of osLoginServiceStubMethods) { const callPromise = this.osLoginServiceStub.then( stub => (...args: Array<{}>) => { @@ -221,17 +201,16 @@ export class OsLoginServiceClient { const func = stub[methodName]; return func.apply(stub, args); }, - (err: Error | null | undefined) => () => { + (err: Error|null|undefined) => () => { throw err; - } - ); + }); const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], this.descriptors.page[methodName] || - this.descriptors.stream[methodName] || - this.descriptors.longrunning[methodName] + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); this.innerApiCalls[methodName] = apiCall; @@ -269,7 +248,7 @@ export class OsLoginServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/compute' ]; } @@ -280,9 +259,8 @@ export class OsLoginServiceClient { * @param {function(Error, string)} callback - the callback to * be called with the current project Id. */ - getProjectId( - callback?: Callback - ): Promise | void { + getProjectId(callback?: Callback): + Promise|void { if (callback) { this.auth.getProjectId(callback); return; @@ -294,82 +272,61 @@ export class OsLoginServiceClient { // -- Service calls -- // ------------------- deletePosixAccount( - request: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, - options?: gax.CallOptions - ): Promise< - [ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest | undefined, - {} | undefined - ] - >; + request: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, + options?: gax.CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|undefined, {}|undefined + ]>; deletePosixAccount( - request: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest - | null - | undefined, - {} | null | undefined - > - ): void; + request: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>): void; deletePosixAccount( - request: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest - | null - | undefined, - {} | null | undefined - > - ): void; - /** - * Deletes a POSIX account. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A reference to the POSIX account to update. POSIX accounts are identified - * by the project ID they are associated with. A reference to the POSIX - * account is in format `users/{user}/projects/{project}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>): void; +/** + * Deletes a POSIX account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A reference to the POSIX account to update. POSIX accounts are identified + * by the project ID they are associated with. A reference to the POSIX + * account is in format `users/{user}/projects/{project}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ deletePosixAccount( - request: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< + request: protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest, + optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest - | null - | undefined, - {} | null | undefined - > - ): Promise< - [ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest | undefined, - {} | undefined - ] - > | void { + protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeletePosixAccountRequest|undefined, {}|undefined + ]>|void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } else { + } + else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -378,88 +335,67 @@ export class OsLoginServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - name: request.name || '', + 'name': request.name || '', }); this.initialize(); return this.innerApiCalls.deletePosixAccount(request, options, callback); } deleteSshPublicKey( - request: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, - options?: gax.CallOptions - ): Promise< - [ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest | undefined, - {} | undefined - ] - >; + request: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, + options?: gax.CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|undefined, {}|undefined + ]>; deleteSshPublicKey( - request: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): void; + request: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; deleteSshPublicKey( - request: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): void; - /** - * Deletes an SSH public key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The fingerprint of the public key to update. Public keys are identified by - * their SHA-256 fingerprint. The fingerprint of the public key is in format - * `users/{user}/sshPublicKeys/{fingerprint}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Deletes an SSH public key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The fingerprint of the public key to update. Public keys are identified by + * their SHA-256 fingerprint. The fingerprint of the public key is in format + * `users/{user}/sshPublicKeys/{fingerprint}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ deleteSshPublicKey( - request: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< + request: protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest, + optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): Promise< - [ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest | undefined, - {} | undefined - ] - > | void { + protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1.IDeleteSshPublicKeyRequest|undefined, {}|undefined + ]>|void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } else { + } + else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -468,85 +404,70 @@ export class OsLoginServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - name: request.name || '', + 'name': request.name || '', }); this.initialize(); return this.innerApiCalls.deleteSshPublicKey(request, options, callback); } getLoginProfile( - request: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, - options?: gax.CallOptions - ): Promise< - [ - protos.google.cloud.oslogin.v1.ILoginProfile, - protos.google.cloud.oslogin.v1.IGetLoginProfileRequest | undefined, - {} | undefined - ] - >; + request: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, + options?: gax.CallOptions): + Promise<[ + protos.google.cloud.oslogin.v1.ILoginProfile, + protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|undefined, {}|undefined + ]>; getLoginProfile( - request: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.oslogin.v1.ILoginProfile, - protos.google.cloud.oslogin.v1.IGetLoginProfileRequest | null | undefined, - {} | null | undefined - > - ): void; + request: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.oslogin.v1.ILoginProfile, + protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>): void; getLoginProfile( - request: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, - callback: Callback< - protos.google.cloud.oslogin.v1.ILoginProfile, - protos.google.cloud.oslogin.v1.IGetLoginProfileRequest | null | undefined, - {} | null | undefined - > - ): void; - /** - * Retrieves the profile information used for logging in to a virtual machine - * on Google Compute Engine. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique ID for the user in format `users/{user}`. - * @param {string} request.projectId - * The project ID of the Google Cloud Platform project. - * @param {string} request.systemId - * A system ID for filtering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [LoginProfile]{@link google.cloud.oslogin.v1.LoginProfile}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, + callback: Callback< + protos.google.cloud.oslogin.v1.ILoginProfile, + protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>): void; +/** + * Retrieves the profile information used for logging in to a virtual machine + * on Google Compute Engine. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique ID for the user in format `users/{user}`. + * @param {string} request.projectId + * The project ID of the Google Cloud Platform project. + * @param {string} request.systemId + * A system ID for filtering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LoginProfile]{@link google.cloud.oslogin.v1.LoginProfile}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getLoginProfile( - request: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< + request: protos.google.cloud.oslogin.v1.IGetLoginProfileRequest, + optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.oslogin.v1.ILoginProfile, - | protos.google.cloud.oslogin.v1.IGetLoginProfileRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - protos.google.cloud.oslogin.v1.ILoginProfile, - protos.google.cloud.oslogin.v1.IGetLoginProfileRequest | null | undefined, - {} | null | undefined - > - ): Promise< - [ - protos.google.cloud.oslogin.v1.ILoginProfile, - protos.google.cloud.oslogin.v1.IGetLoginProfileRequest | undefined, - {} | undefined - ] - > | void { + protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.oslogin.v1.ILoginProfile, + protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.v1.ILoginProfile, + protos.google.cloud.oslogin.v1.IGetLoginProfileRequest|undefined, {}|undefined + ]>|void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } else { + } + else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -555,82 +476,67 @@ export class OsLoginServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - name: request.name || '', + 'name': request.name || '', }); this.initialize(); return this.innerApiCalls.getLoginProfile(request, options, callback); } getSshPublicKey( - request: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, - options?: gax.CallOptions - ): Promise< - [ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest | undefined, - {} | undefined - ] - >; + request: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, + options?: gax.CallOptions): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|undefined, {}|undefined + ]>; getSshPublicKey( - request: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest | null | undefined, - {} | null | undefined - > - ): void; + request: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; getSshPublicKey( - request: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest | null | undefined, - {} | null | undefined - > - ): void; - /** - * Retrieves an SSH public key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The fingerprint of the public key to retrieve. Public keys are identified - * by their SHA-256 fingerprint. The fingerprint of the public key is in - * format `users/{user}/sshPublicKeys/{fingerprint}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [SshPublicKey]{@link google.cloud.oslogin.common.SshPublicKey}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Retrieves an SSH public key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The fingerprint of the public key to retrieve. Public keys are identified + * by their SHA-256 fingerprint. The fingerprint of the public key is in + * format `users/{user}/sshPublicKeys/{fingerprint}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [SshPublicKey]{@link google.cloud.oslogin.common.SshPublicKey}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getSshPublicKey( - request: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< + request: protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< protos.google.cloud.oslogin.common.ISshPublicKey, - | protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest | null | undefined, - {} | null | undefined - > - ): Promise< - [ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest | undefined, - {} | undefined - ] - > | void { + protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IGetSshPublicKeyRequest|undefined, {}|undefined + ]>|void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } else { + } + else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -639,92 +545,71 @@ export class OsLoginServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - name: request.name || '', + 'name': request.name || '', }); this.initialize(); return this.innerApiCalls.getSshPublicKey(request, options, callback); } importSshPublicKey( - request: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, - options?: gax.CallOptions - ): Promise< - [ - protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest | undefined, - {} | undefined - ] - >; + request: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, + options?: gax.CallOptions): + Promise<[ + protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|undefined, {}|undefined + ]>; importSshPublicKey( - request: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, - | protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): void; + request: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; importSshPublicKey( - request: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, - | protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): void; - /** - * Adds an SSH public key and returns the profile information. Default POSIX - * account information is set when no username and UID exist as part of the - * login profile. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique ID for the user in format `users/{user}`. - * @param {google.cloud.oslogin.common.SshPublicKey} [request.sshPublicKey] - * Optional. The SSH public key and expiration time. - * @param {string} request.projectId - * The project ID of the Google Cloud Platform project. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ImportSshPublicKeyResponse]{@link google.cloud.oslogin.v1.ImportSshPublicKeyResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Adds an SSH public key and returns the profile information. Default POSIX + * account information is set when no username and UID exist as part of the + * login profile. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique ID for the user in format `users/{user}`. + * @param {google.cloud.oslogin.common.SshPublicKey} [request.sshPublicKey] + * Optional. The SSH public key and expiration time. + * @param {string} request.projectId + * The project ID of the Google Cloud Platform project. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ImportSshPublicKeyResponse]{@link google.cloud.oslogin.v1.ImportSshPublicKeyResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ importSshPublicKey( - request: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< + request: protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, - | protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, - | protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): Promise< - [ - protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest | undefined, - {} | undefined - ] - > | void { + protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1.IImportSshPublicKeyRequest|undefined, {}|undefined + ]>|void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } else { + } + else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -733,93 +618,72 @@ export class OsLoginServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - parent: request.parent || '', + 'parent': request.parent || '', }); this.initialize(); return this.innerApiCalls.importSshPublicKey(request, options, callback); } updateSshPublicKey( - request: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, - options?: gax.CallOptions - ): Promise< - [ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest | undefined, - {} | undefined - ] - >; + request: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, + options?: gax.CallOptions): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|undefined, {}|undefined + ]>; updateSshPublicKey( - request: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - | protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): void; + request: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; updateSshPublicKey( - request: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - | protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): void; - /** - * Updates an SSH public key and returns the profile information. This method - * supports patch semantics. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The fingerprint of the public key to update. Public keys are identified by - * their SHA-256 fingerprint. The fingerprint of the public key is in format - * `users/{user}/sshPublicKeys/{fingerprint}`. - * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey - * Required. The SSH public key and expiration time. - * @param {google.protobuf.FieldMask} request.updateMask - * Mask to control which fields get updated. Updates all if not present. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [SshPublicKey]{@link google.cloud.oslogin.common.SshPublicKey}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Updates an SSH public key and returns the profile information. This method + * supports patch semantics. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The fingerprint of the public key to update. Public keys are identified by + * their SHA-256 fingerprint. The fingerprint of the public key is in format + * `users/{user}/sshPublicKeys/{fingerprint}`. + * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey + * Required. The SSH public key and expiration time. + * @param {google.protobuf.FieldMask} request.updateMask + * Mask to control which fields get updated. Updates all if not present. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [SshPublicKey]{@link google.cloud.oslogin.common.SshPublicKey}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ updateSshPublicKey( - request: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< + request: protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< protos.google.cloud.oslogin.common.ISshPublicKey, - | protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - | protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): Promise< - [ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest | undefined, - {} | undefined - ] - > | void { + protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.IUpdateSshPublicKeyRequest|undefined, {}|undefined + ]>|void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } else { + } + else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -828,7 +692,7 @@ export class OsLoginServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - name: request.name || '', + 'name': request.name || '', }); this.initialize(); return this.innerApiCalls.updateSshPublicKey(request, options, callback); @@ -845,7 +709,7 @@ export class OsLoginServiceClient { * @param {string} project * @returns {string} Resource name string. */ - posixAccountPath(user: string, project: string) { + posixAccountPath(user:string,project:string) { return this.pathTemplates.posixAccountPathTemplate.render({ user: user, project: project, @@ -860,8 +724,7 @@ export class OsLoginServiceClient { * @returns {string} A string representing the user. */ matchUserFromPosixAccountName(posixAccountName: string) { - return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName) - .user; + return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName).user; } /** @@ -872,8 +735,7 @@ export class OsLoginServiceClient { * @returns {string} A string representing the project. */ matchProjectFromPosixAccountName(posixAccountName: string) { - return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName) - .project; + return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName).project; } /** @@ -883,7 +745,7 @@ export class OsLoginServiceClient { * @param {string} fingerprint * @returns {string} Resource name string. */ - sshPublicKeyPath(user: string, fingerprint: string) { + sshPublicKeyPath(user:string,fingerprint:string) { return this.pathTemplates.sshPublicKeyPathTemplate.render({ user: user, fingerprint: fingerprint, @@ -898,8 +760,7 @@ export class OsLoginServiceClient { * @returns {string} A string representing the user. */ matchUserFromSshPublicKeyName(sshPublicKeyName: string) { - return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName) - .user; + return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName).user; } /** @@ -910,8 +771,7 @@ export class OsLoginServiceClient { * @returns {string} A string representing the fingerprint. */ matchFingerprintFromSshPublicKeyName(sshPublicKeyName: string) { - return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName) - .fingerprint; + return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName).fingerprint; } /** @@ -920,7 +780,7 @@ export class OsLoginServiceClient { * @param {string} user * @returns {string} Resource name string. */ - userPath(user: string) { + userPath(user:string) { return this.pathTemplates.userPathTemplate.render({ user: user, }); diff --git a/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts b/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts index b9d7beec1700..e86053adbd37 100644 --- a/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts +++ b/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts @@ -41,12 +41,7 @@ export class OsLoginServiceClient { private _protos: {}; private _defaults: {[method: string]: gax.CallSettings}; auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; + descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}}; innerApiCalls: {[name: string]: Function}; pathTemplates: {[name: string]: gax.PathTemplate}; osLoginServiceStub?: Promise<{[name: string]: Function}>; @@ -80,12 +75,10 @@ export class OsLoginServiceClient { constructor(opts?: ClientOptions) { // Ensure that options include the service address and port. const staticMembers = this.constructor as typeof OsLoginServiceClient; - const servicePath = - opts && opts.servicePath - ? opts.servicePath - : opts && opts.apiEndpoint - ? opts.apiEndpoint - : staticMembers.servicePath; + const servicePath = opts && opts.servicePath ? + opts.servicePath : + ((opts && opts.apiEndpoint) ? opts.apiEndpoint : + staticMembers.servicePath); const port = opts && opts.port ? opts.port : staticMembers.port; if (!opts) { @@ -95,8 +88,8 @@ export class OsLoginServiceClient { opts.port = opts.port || port; opts.clientConfig = opts.clientConfig || {}; - const isBrowser = typeof window !== 'undefined'; - if (isBrowser) { + const isBrowser = (typeof window !== 'undefined'); + if (isBrowser){ opts.fallback = true; } // If we are in browser, we are already using fallback because of the @@ -113,10 +106,13 @@ export class OsLoginServiceClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = this._gaxGrpc.auth as gax.GoogleAuth; + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); // Determine the client header string. - const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -132,18 +128,12 @@ export class OsLoginServiceClient { // For Node.js, pass the path to JSON proto file. // For browsers, pass the JSON content. - const nodejsProtoPath = path.join( - __dirname, - '..', - '..', - 'protos', - 'protos.json' - ); + const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json'); this._protos = this._gaxGrpc.loadProto( - opts.fallback - ? // eslint-disable-next-line @typescript-eslint/no-var-requires - require('../../protos/protos.json') - : nodejsProtoPath + opts.fallback ? + // eslint-disable-next-line @typescript-eslint/no-var-requires + require("../../protos/protos.json") : + nodejsProtoPath ); // This API contains "path templates"; forward-slash-separated @@ -156,16 +146,15 @@ export class OsLoginServiceClient { sshPublicKeyPathTemplate: new this._gaxModule.PathTemplate( 'users/{user}/sshPublicKeys/{fingerprint}' ), - userPathTemplate: new this._gaxModule.PathTemplate('users/{user}'), + userPathTemplate: new this._gaxModule.PathTemplate( + 'users/{user}' + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.oslogin.v1beta.OsLoginService', - gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, - {'x-goog-api-client': clientHeader.join(' ')} - ); + 'google.cloud.oslogin.v1beta.OsLoginService', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -193,25 +182,16 @@ export class OsLoginServiceClient { // Put together the "service stub" for // google.cloud.oslogin.v1beta.OsLoginService. this.osLoginServiceStub = this._gaxGrpc.createStub( - this._opts.fallback - ? (this._protos as protobuf.Root).lookupService( - 'google.cloud.oslogin.v1beta.OsLoginService' - ) - : // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.oslogin.v1beta.OsLoginService') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.oslogin.v1beta.OsLoginService, - this._opts - ) as Promise<{[method: string]: Function}>; + this._opts) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const osLoginServiceStubMethods = [ - 'deletePosixAccount', - 'deleteSshPublicKey', - 'getLoginProfile', - 'getSshPublicKey', - 'importSshPublicKey', - 'updateSshPublicKey', - ]; + const osLoginServiceStubMethods = + ['deletePosixAccount', 'deleteSshPublicKey', 'getLoginProfile', 'getSshPublicKey', 'importSshPublicKey', 'updateSshPublicKey']; for (const methodName of osLoginServiceStubMethods) { const callPromise = this.osLoginServiceStub.then( stub => (...args: Array<{}>) => { @@ -221,17 +201,16 @@ export class OsLoginServiceClient { const func = stub[methodName]; return func.apply(stub, args); }, - (err: Error | null | undefined) => () => { + (err: Error|null|undefined) => () => { throw err; - } - ); + }); const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], this.descriptors.page[methodName] || - this.descriptors.stream[methodName] || - this.descriptors.longrunning[methodName] + this.descriptors.stream[methodName] || + this.descriptors.longrunning[methodName] ); this.innerApiCalls[methodName] = apiCall; @@ -271,7 +250,7 @@ export class OsLoginServiceClient { 'https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/cloud-platform.read-only', 'https://www.googleapis.com/auth/compute', - 'https://www.googleapis.com/auth/compute.readonly', + 'https://www.googleapis.com/auth/compute.readonly' ]; } @@ -282,9 +261,8 @@ export class OsLoginServiceClient { * @param {function(Error, string)} callback - the callback to * be called with the current project Id. */ - getProjectId( - callback?: Callback - ): Promise | void { + getProjectId(callback?: Callback): + Promise|void { if (callback) { this.auth.getProjectId(callback); return; @@ -296,82 +274,61 @@ export class OsLoginServiceClient { // -- Service calls -- // ------------------- deletePosixAccount( - request: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, - options?: gax.CallOptions - ): Promise< - [ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest | undefined, - {} | undefined - ] - >; + request: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, + options?: gax.CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|undefined, {}|undefined + ]>; deletePosixAccount( - request: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest - | null - | undefined, - {} | null | undefined - > - ): void; + request: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>): void; deletePosixAccount( - request: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest - | null - | undefined, - {} | null | undefined - > - ): void; - /** - * Deletes a POSIX account. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. A reference to the POSIX account to update. POSIX accounts are identified - * by the project ID they are associated with. A reference to the POSIX - * account is in format `users/{user}/projects/{project}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>): void; +/** + * Deletes a POSIX account. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. A reference to the POSIX account to update. POSIX accounts are identified + * by the project ID they are associated with. A reference to the POSIX + * account is in format `users/{user}/projects/{project}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ deletePosixAccount( - request: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< + request: protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest, + optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest - | null - | undefined, - {} | null | undefined - > - ): Promise< - [ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest | undefined, - {} | undefined - ] - > | void { + protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeletePosixAccountRequest|undefined, {}|undefined + ]>|void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } else { + } + else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -380,88 +337,67 @@ export class OsLoginServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - name: request.name || '', + 'name': request.name || '', }); this.initialize(); return this.innerApiCalls.deletePosixAccount(request, options, callback); } deleteSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, - options?: gax.CallOptions - ): Promise< - [ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest | undefined, - {} | undefined - ] - >; + request: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, + options?: gax.CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|undefined, {}|undefined + ]>; deleteSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): void; + request: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; deleteSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): void; - /** - * Deletes an SSH public key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The fingerprint of the public key to update. Public keys are identified by - * their SHA-256 fingerprint. The fingerprint of the public key is in format - * `users/{user}/sshPublicKeys/{fingerprint}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Deletes an SSH public key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The fingerprint of the public key to update. Public keys are identified by + * their SHA-256 fingerprint. The fingerprint of the public key is in format + * `users/{user}/sshPublicKeys/{fingerprint}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ deleteSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< + request: protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest, + optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - protos.google.protobuf.IEmpty, - | protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): Promise< - [ - protos.google.protobuf.IEmpty, - protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest | undefined, - {} | undefined - ] - > | void { + protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.oslogin.v1beta.IDeleteSshPublicKeyRequest|undefined, {}|undefined + ]>|void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } else { + } + else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -470,91 +406,70 @@ export class OsLoginServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - name: request.name || '', + 'name': request.name || '', }); this.initialize(); return this.innerApiCalls.deleteSshPublicKey(request, options, callback); } getLoginProfile( - request: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, - options?: gax.CallOptions - ): Promise< - [ - protos.google.cloud.oslogin.v1beta.ILoginProfile, - protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest | undefined, - {} | undefined - ] - >; + request: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, + options?: gax.CallOptions): + Promise<[ + protos.google.cloud.oslogin.v1beta.ILoginProfile, + protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|undefined, {}|undefined + ]>; getLoginProfile( - request: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.oslogin.v1beta.ILoginProfile, - | protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest - | null - | undefined, - {} | null | undefined - > - ): void; + request: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.oslogin.v1beta.ILoginProfile, + protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>): void; getLoginProfile( - request: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, - callback: Callback< - protos.google.cloud.oslogin.v1beta.ILoginProfile, - | protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest - | null - | undefined, - {} | null | undefined - > - ): void; - /** - * Retrieves the profile information used for logging in to a virtual machine - * on Google Compute Engine. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique ID for the user in format `users/{user}`. - * @param {string} request.projectId - * The project ID of the Google Cloud Platform project. - * @param {string} request.systemId - * A system ID for filtering the results of the request. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [LoginProfile]{@link google.cloud.oslogin.v1beta.LoginProfile}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, + callback: Callback< + protos.google.cloud.oslogin.v1beta.ILoginProfile, + protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>): void; +/** + * Retrieves the profile information used for logging in to a virtual machine + * on Google Compute Engine. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique ID for the user in format `users/{user}`. + * @param {string} request.projectId + * The project ID of the Google Cloud Platform project. + * @param {string} request.systemId + * A system ID for filtering the results of the request. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [LoginProfile]{@link google.cloud.oslogin.v1beta.LoginProfile}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getLoginProfile( - request: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< + request: protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest, + optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.oslogin.v1beta.ILoginProfile, - | protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - protos.google.cloud.oslogin.v1beta.ILoginProfile, - | protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest - | null - | undefined, - {} | null | undefined - > - ): Promise< - [ - protos.google.cloud.oslogin.v1beta.ILoginProfile, - protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest | undefined, - {} | undefined - ] - > | void { + protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.oslogin.v1beta.ILoginProfile, + protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.v1beta.ILoginProfile, + protos.google.cloud.oslogin.v1beta.IGetLoginProfileRequest|undefined, {}|undefined + ]>|void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } else { + } + else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -563,88 +478,67 @@ export class OsLoginServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - name: request.name || '', + 'name': request.name || '', }); this.initialize(); return this.innerApiCalls.getLoginProfile(request, options, callback); } getSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, - options?: gax.CallOptions - ): Promise< - [ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest | undefined, - {} | undefined - ] - >; + request: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, + options?: gax.CallOptions): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|undefined, {}|undefined + ]>; getSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - | protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): void; + request: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; getSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - | protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): void; - /** - * Retrieves an SSH public key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The fingerprint of the public key to retrieve. Public keys are identified - * by their SHA-256 fingerprint. The fingerprint of the public key is in - * format `users/{user}/sshPublicKeys/{fingerprint}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [SshPublicKey]{@link google.cloud.oslogin.common.SshPublicKey}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Retrieves an SSH public key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The fingerprint of the public key to retrieve. Public keys are identified + * by their SHA-256 fingerprint. The fingerprint of the public key is in + * format `users/{user}/sshPublicKeys/{fingerprint}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [SshPublicKey]{@link google.cloud.oslogin.common.SshPublicKey}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< + request: protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< protos.google.cloud.oslogin.common.ISshPublicKey, - | protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - | protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): Promise< - [ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest | undefined, - {} | undefined - ] - > | void { + protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IGetSshPublicKeyRequest|undefined, {}|undefined + ]>|void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } else { + } + else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -653,92 +547,71 @@ export class OsLoginServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - name: request.name || '', + 'name': request.name || '', }); this.initialize(); return this.innerApiCalls.getSshPublicKey(request, options, callback); } importSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, - options?: gax.CallOptions - ): Promise< - [ - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest | undefined, - {} | undefined - ] - >; + request: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, + options?: gax.CallOptions): + Promise<[ + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|undefined, {}|undefined + ]>; importSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, - | protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): void; + request: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; importSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, - | protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): void; - /** - * Adds an SSH public key and returns the profile information. Default POSIX - * account information is set when no username and UID exist as part of the - * login profile. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The unique ID for the user in format `users/{user}`. - * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey - * Required. The SSH public key and expiration time. - * @param {string} request.projectId - * The project ID of the Google Cloud Platform project. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ImportSshPublicKeyResponse]{@link google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Adds an SSH public key and returns the profile information. Default POSIX + * account information is set when no username and UID exist as part of the + * login profile. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The unique ID for the user in format `users/{user}`. + * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey + * Required. The SSH public key and expiration time. + * @param {string} request.projectId + * The project ID of the Google Cloud Platform project. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ImportSshPublicKeyResponse]{@link google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ importSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< + request: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, - | protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, - | protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): Promise< - [ - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, - protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest | undefined, - {} | undefined - ] - > | void { + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse, + protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyRequest|undefined, {}|undefined + ]>|void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } else { + } + else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -747,93 +620,72 @@ export class OsLoginServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - parent: request.parent || '', + 'parent': request.parent || '', }); this.initialize(); return this.innerApiCalls.importSshPublicKey(request, options, callback); } updateSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, - options?: gax.CallOptions - ): Promise< - [ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest | undefined, - {} | undefined - ] - >; + request: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, + options?: gax.CallOptions): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|undefined, {}|undefined + ]>; updateSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, - options: gax.CallOptions, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - | protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): void; + request: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, + options: gax.CallOptions, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; updateSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, - callback: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - | protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): void; - /** - * Updates an SSH public key and returns the profile information. This method - * supports patch semantics. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The fingerprint of the public key to update. Public keys are identified by - * their SHA-256 fingerprint. The fingerprint of the public key is in format - * `users/{user}/sshPublicKeys/{fingerprint}`. - * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey - * Required. The SSH public key and expiration time. - * @param {google.protobuf.FieldMask} request.updateMask - * Mask to control which fields get updated. Updates all if not present. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [SshPublicKey]{@link google.cloud.oslogin.common.SshPublicKey}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + request: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): void; +/** + * Updates an SSH public key and returns the profile information. This method + * supports patch semantics. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The fingerprint of the public key to update. Public keys are identified by + * their SHA-256 fingerprint. The fingerprint of the public key is in format + * `users/{user}/sshPublicKeys/{fingerprint}`. + * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey + * Required. The SSH public key and expiration time. + * @param {google.protobuf.FieldMask} request.updateMask + * Mask to control which fields get updated. Updates all if not present. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [SshPublicKey]{@link google.cloud.oslogin.common.SshPublicKey}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ updateSshPublicKey( - request: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, - optionsOrCallback?: - | gax.CallOptions - | Callback< + request: protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest, + optionsOrCallback?: gax.CallOptions|Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< protos.google.cloud.oslogin.common.ISshPublicKey, - | protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - >, - callback?: Callback< - protos.google.cloud.oslogin.common.ISshPublicKey, - | protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest - | null - | undefined, - {} | null | undefined - > - ): Promise< - [ - protos.google.cloud.oslogin.common.ISshPublicKey, - protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest | undefined, - {} | undefined - ] - > | void { + protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.IUpdateSshPublicKeyRequest|undefined, {}|undefined + ]>|void { request = request || {}; let options: gax.CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } else { + } + else { options = optionsOrCallback as gax.CallOptions; } options = options || {}; @@ -842,7 +694,7 @@ export class OsLoginServiceClient { options.otherArgs.headers[ 'x-goog-request-params' ] = gax.routingHeader.fromParams({ - name: request.name || '', + 'name': request.name || '', }); this.initialize(); return this.innerApiCalls.updateSshPublicKey(request, options, callback); @@ -859,7 +711,7 @@ export class OsLoginServiceClient { * @param {string} project * @returns {string} Resource name string. */ - posixAccountPath(user: string, project: string) { + posixAccountPath(user:string,project:string) { return this.pathTemplates.posixAccountPathTemplate.render({ user: user, project: project, @@ -874,8 +726,7 @@ export class OsLoginServiceClient { * @returns {string} A string representing the user. */ matchUserFromPosixAccountName(posixAccountName: string) { - return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName) - .user; + return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName).user; } /** @@ -886,8 +737,7 @@ export class OsLoginServiceClient { * @returns {string} A string representing the project. */ matchProjectFromPosixAccountName(posixAccountName: string) { - return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName) - .project; + return this.pathTemplates.posixAccountPathTemplate.match(posixAccountName).project; } /** @@ -897,7 +747,7 @@ export class OsLoginServiceClient { * @param {string} fingerprint * @returns {string} Resource name string. */ - sshPublicKeyPath(user: string, fingerprint: string) { + sshPublicKeyPath(user:string,fingerprint:string) { return this.pathTemplates.sshPublicKeyPathTemplate.render({ user: user, fingerprint: fingerprint, @@ -912,8 +762,7 @@ export class OsLoginServiceClient { * @returns {string} A string representing the user. */ matchUserFromSshPublicKeyName(sshPublicKeyName: string) { - return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName) - .user; + return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName).user; } /** @@ -924,8 +773,7 @@ export class OsLoginServiceClient { * @returns {string} A string representing the fingerprint. */ matchFingerprintFromSshPublicKeyName(sshPublicKeyName: string) { - return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName) - .fingerprint; + return this.pathTemplates.sshPublicKeyPathTemplate.match(sshPublicKeyName).fingerprint; } /** @@ -934,7 +782,7 @@ export class OsLoginServiceClient { * @param {string} user * @returns {string} Resource name string. */ - userPath(user: string) { + userPath(user:string) { return this.pathTemplates.userPathTemplate.render({ user: user, }); diff --git a/packages/google-cloud-oslogin/synth.metadata b/packages/google-cloud-oslogin/synth.metadata index f92abc0cb059..2e3ea9ef53bf 100644 --- a/packages/google-cloud-oslogin/synth.metadata +++ b/packages/google-cloud-oslogin/synth.metadata @@ -4,24 +4,22 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-os-login.git", - "sha": "cfd13be891933c70727cc81c58c13205a8b63900" + "sha": "e41bec8bc5a9c129196a1523bc99a5e00262a174" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "26523a96798ce1a6caa1b3c912119059cfcc98a7", - "internalRef": "306320014", - "log": "26523a96798ce1a6caa1b3c912119059cfcc98a7\nchore: delete gapic config for resourcemanager/v2\n\nCommitter: @miraleung\nPiperOrigin-RevId: 306320014\n\n35672e7936b923eff048d0ee1529faa163cc81b8\nchore: enable gapicv2 for datacatalog/v1beta1 API\n\nCommitter: @miraleung\nPiperOrigin-RevId: 306318928\n\ndea1f52034d188ca371c3a70c716ca2a6b3f2aa1\nchore: delete gapic config for language/v1beta1\n\nCommitter: @miraleung\nPiperOrigin-RevId: 306298030\n\ndf955af5d9508cf9215de6f1fbdad033d5b8fef6\nchore: enable gapicv2 for language/v1beta2 API\n\nCommitter: @miraleung\nPiperOrigin-RevId: 306297639\n\ne2a59ff2f861b1b92b2f15b242780dccddd77ab9\nchore: enable gapicv2 for bigquery/reservation/v1 API\n\nCommitter: @miraleung\nPiperOrigin-RevId: 306297615\n\nc9942c00e8f35b5b37cd589ef7a0323aeda264e2\nchore: enable gapicv2 for datacatalog/v1beta1 API\n\nCommitter: @miraleung\nPiperOrigin-RevId: 306297587\n\nf561f57eea013327be27d8f6799b3cc2d18ee804\nbazel: upgrade gapic-generator-go to v0.13.2\n\nChanges include:\n* update Bazel rules_go to v0.22.3\n* update Bazel Go repositories with latest\n* fix Bazel go_gapic_assembly_pkg archive contents path\n\nPiperOrigin-RevId: 306294636\n\na34f4eb96a94bfd5b3e7f8de253db28d0a3e9237\nchore: enable gapicv2 for asset/v1beta1 API\n\nCommitter: @miraleung\nPiperOrigin-RevId: 306283252\n\n4efd71279f0781579ced60c374336ce1b8b8cea8\nchore: enable gapicv2 for asset/v1p4beta1 API\n\nCommitter: @miraleung\nPiperOrigin-RevId: 306282838\n\n789fd7e0680b04a589447139811d55c5d1f34afe\nchore: enable gapicv2 for asset/v1p1beta1 API\n\nCommitter: @miraleung\nPiperOrigin-RevId: 306282062\n\n0feb08065d91d6deebffef3019751f0619a72140\nchore: enable gapicv2 for asset/v1p2beta1 API\n\nCommitter: @miraleung\nPiperOrigin-RevId: 306281797\n\n9ea892ebe8a7cd66da9bd62eb7086b8dc2ddd559\nchore: enable gapicv2 for vision/v1 API\n\nCommitter: @miraleung\nPiperOrigin-RevId: 306281271\n\n4d61e1cb40184a7ad63ef37b1813f6608718674a\nAdd speech adaptation, phrase sets and custom classes.\n\nPiperOrigin-RevId: 306280989\n\n3824f547aa44df459580615c73cabb30a2a78ee0\nfeat: Adding Retry policy for OS Config V1Beta AgentEndpointService\n\nPiperOrigin-RevId: 306254195\n\n" + "sha": "3028060618e8024af9a32b3ab3456c160091ecb7", + "internalRef": "306450502" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "52638600f387deb98efb5f9c85fec39e82aa9052", - "log": "52638600f387deb98efb5f9c85fec39e82aa9052\nbuild(java): set GOOGLE_CLOUD_PROJECT env for samples/integration tests (#484)\n\n* build(java): set GOOGLE_CLOUD_PROJECT env variable for samples/integration tests\n\n* ci: use java-docs-samples-testing for sample tests\n3df869dd6eb546ef13beeb7a9efa6ee0226afafd\nci: add dependency list completeness check (#490)\n\n\n682c0c37d1054966ca662a44259e96cc7aea4413\nbuild(nodejs): update lint ignore rules (#488)\n\n\n97c7ccfdceb927db1cbe6f3bb09616aa02bafd89\ndoc: document context-aware commit flags (#481)\n\nAlso, delete obsolete blurb about cleaning up old, dead files.\n\nCo-authored-by: Jeff Ching \n8eff3790f88b50706a0c4b6a20b385f24e9ac4e7\nfeat: common postprocessing for node libraries (#485)\n\nCo-authored-by: Justin Beckwith \n21c3b57ae54ae9db6a3a6b48b31c970c6ab56f19\nbuild(nodejs): remove unused codecov config (#486)\n\n\n" + "sha": "52638600f387deb98efb5f9c85fec39e82aa9052" } } ], diff --git a/packages/google-cloud-oslogin/system-test/fixtures/sample/src/index.js b/packages/google-cloud-oslogin/system-test/fixtures/sample/src/index.js index 22d41bdb59df..0b00fd748a12 100644 --- a/packages/google-cloud-oslogin/system-test/fixtures/sample/src/index.js +++ b/packages/google-cloud-oslogin/system-test/fixtures/sample/src/index.js @@ -16,6 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** + /* eslint-disable node/no-missing-require, no-unused-vars */ const oslogin = require('@google-cloud/os-login'); diff --git a/packages/google-cloud-oslogin/system-test/install.ts b/packages/google-cloud-oslogin/system-test/install.ts index c4d80e9c0c8c..5e4ed6364817 100644 --- a/packages/google-cloud-oslogin/system-test/install.ts +++ b/packages/google-cloud-oslogin/system-test/install.ts @@ -16,36 +16,34 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {packNTest} from 'pack-n-play'; -import {readFileSync} from 'fs'; -import {describe, it} from 'mocha'; +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; describe('typescript consumer tests', () => { + it('should have correct type signature for typescript users', async function() { this.timeout(300000); const options = { - packageDir: process.cwd(), // path to your module. + packageDir: process.cwd(), // path to your module. sample: { description: 'typescript based user can use the type definitions', - ts: readFileSync( - './system-test/fixtures/sample/src/index.ts' - ).toString(), - }, + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } }; - await packNTest(options); // will throw upon error. + await packNTest(options); // will throw upon error. }); it('should have correct type signature for javascript users', async function() { this.timeout(300000); const options = { - packageDir: process.cwd(), // path to your module. + packageDir: process.cwd(), // path to your module. sample: { description: 'typescript based user can use the type definitions', - ts: readFileSync( - './system-test/fixtures/sample/src/index.js' - ).toString(), - }, + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } }; - await packNTest(options); // will throw upon error. + await packNTest(options); // will throw upon error. }); + }); diff --git a/packages/google-cloud-oslogin/test/gapic_os_login_service_v1.ts b/packages/google-cloud-oslogin/test/gapic_os_login_service_v1.ts index e6844dbe64d6..8be0cd8599af 100644 --- a/packages/google-cloud-oslogin/test/gapic_os_login_service_v1.ts +++ b/packages/google-cloud-oslogin/test/gapic_os_login_service_v1.ts @@ -20,946 +20,714 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { describe, it } from 'mocha'; import * as osloginserviceModule from '../src'; import {protobuf} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message).toObject( - instance as protobuf.Message, - {defaults: true} - ); - return (instance.constructor as typeof protobuf.Message).fromObject( - filledObject - ) as T; + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error - ? sinon.stub().rejects(error) - : sinon.stub().resolves([response]); + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback( - response?: ResponseType, - error?: Error -) { - return error - ? sinon.stub().callsArgWith(2, error) - : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); } describe('v1.OsLoginServiceClient', () => { - it('has servicePath', () => { - const servicePath = - osloginserviceModule.v1.OsLoginServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = - osloginserviceModule.v1.OsLoginServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = osloginserviceModule.v1.OsLoginServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - fallback: true, + it('has servicePath', () => { + const servicePath = osloginserviceModule.v1.OsLoginServiceClient.servicePath; + assert(servicePath); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.osLoginServiceStub, undefined); - await client.initialize(); - assert(client.osLoginServiceStub); - }); - - it('has close method', () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('deletePosixAccount', () => { - it('invokes deletePosixAccount without error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.DeletePosixAccountRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePosixAccount = stubSimpleCall( - expectedResponse - ); - const [response] = await client.deletePosixAccount(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + it('has apiEndpoint', () => { + const apiEndpoint = osloginserviceModule.v1.OsLoginServiceClient.apiEndpoint; + assert(apiEndpoint); }); - it('invokes deletePosixAccount without error using callback', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.DeletePosixAccountRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePosixAccount = stubSimpleCallWithCallback( - expectedResponse - ); - const promise = new Promise((resolve, reject) => { - client.deletePosixAccount( - request, - ( - err?: Error | null, - result?: protos.google.protobuf.IEmpty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - } - ); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + it('has port', () => { + const port = osloginserviceModule.v1.OsLoginServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - it('invokes deletePosixAccount with error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.DeletePosixAccountRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePosixAccount = stubSimpleCall( - undefined, - expectedError - ); - await assert.rejects(async () => { - await client.deletePosixAccount(request); - }, expectedError); - assert( - (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); - }); - }); - - describe('deleteSshPublicKey', () => { - it('invokes deleteSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteSshPublicKey = stubSimpleCall( - expectedResponse - ); - const [response] = await client.deleteSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + it('should create a client with no option', () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient(); + assert(client); }); - it('invokes deleteSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteSshPublicKey = stubSimpleCallWithCallback( - expectedResponse - ); - const promise = new Promise((resolve, reject) => { - client.deleteSshPublicKey( - request, - ( - err?: Error | null, - result?: protos.google.protobuf.IEmpty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - } - ); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + it('should create a client with gRPC fallback', () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + fallback: true, + }); + assert(client); }); - it('invokes deleteSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSshPublicKey = stubSimpleCall( - undefined, - expectedError - ); - await assert.rejects(async () => { - await client.deleteSshPublicKey(request); - }, expectedError); - assert( - (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); - }); - }); - - describe('getLoginProfile', () => { - it('invokes getLoginProfile without error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.GetLoginProfileRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1.LoginProfile() - ); - client.innerApiCalls.getLoginProfile = stubSimpleCall(expectedResponse); - const [response] = await client.getLoginProfile(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + it('has initialize method and supports deferred initialization', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.osLoginServiceStub, undefined); + await client.initialize(); + assert(client.osLoginServiceStub); }); - it('invokes getLoginProfile without error using callback', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.GetLoginProfileRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1.LoginProfile() - ); - client.innerApiCalls.getLoginProfile = stubSimpleCallWithCallback( - expectedResponse - ); - const promise = new Promise((resolve, reject) => { - client.getLoginProfile( - request, - ( - err?: Error | null, - result?: protos.google.cloud.oslogin.v1.ILoginProfile | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - } - ); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + it('has close method', () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); }); - it('invokes getLoginProfile with error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.GetLoginProfileRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getLoginProfile = stubSimpleCall( - undefined, - expectedError - ); - await assert.rejects(async () => { - await client.getLoginProfile(request); - }, expectedError); - assert( - (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); - }); - }); - - describe('getSshPublicKey', () => { - it('invokes getSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.GetSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.getSshPublicKey = stubSimpleCall(expectedResponse); - const [response] = await client.getSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - it('invokes getSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.GetSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.getSshPublicKey = stubSimpleCallWithCallback( - expectedResponse - ); - const promise = new Promise((resolve, reject) => { - client.getSshPublicKey( - request, - ( - err?: Error | null, - result?: protos.google.cloud.oslogin.common.ISshPublicKey | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - } - ); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - it('invokes getSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.GetSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getSshPublicKey = stubSimpleCall( - undefined, - expectedError - ); - await assert.rejects(async () => { - await client.getSshPublicKey(request); - }, expectedError); - assert( - (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); - }); - }); - - describe('importSshPublicKey', () => { - it('invokes importSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.ImportSshPublicKeyRequest() - ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1.ImportSshPublicKeyResponse() - ); - client.innerApiCalls.importSshPublicKey = stubSimpleCall( - expectedResponse - ); - const [response] = await client.importSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + describe('deletePosixAccount', () => { + it('invokes deletePosixAccount without error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.DeletePosixAccountRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deletePosixAccount = stubSimpleCall(expectedResponse); + const [response] = await client.deletePosixAccount(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deletePosixAccount without error using callback', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.DeletePosixAccountRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deletePosixAccount = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePosixAccount( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deletePosixAccount with error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.DeletePosixAccountRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePosixAccount = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { await client.deletePosixAccount(request); }, expectedError); + assert((client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); }); - it('invokes importSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.ImportSshPublicKeyRequest() - ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1.ImportSshPublicKeyResponse() - ); - client.innerApiCalls.importSshPublicKey = stubSimpleCallWithCallback( - expectedResponse - ); - const promise = new Promise((resolve, reject) => { - client.importSshPublicKey( - request, - ( - err?: Error | null, - result?: protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - } - ); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + describe('deleteSshPublicKey', () => { + it('invokes deleteSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.deleteSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSshPublicKey( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.DeleteSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { await client.deleteSshPublicKey(request); }, expectedError); + assert((client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); }); - it('invokes importSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.ImportSshPublicKeyRequest() - ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importSshPublicKey = stubSimpleCall( - undefined, - expectedError - ); - await assert.rejects(async () => { - await client.importSshPublicKey(request); - }, expectedError); - assert( - (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); - }); - }); - - describe('updateSshPublicKey', () => { - it('invokes updateSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.updateSshPublicKey = stubSimpleCall( - expectedResponse - ); - const [response] = await client.updateSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + describe('getLoginProfile', () => { + it('invokes getLoginProfile without error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.GetLoginProfileRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.v1.LoginProfile()); + client.innerApiCalls.getLoginProfile = stubSimpleCall(expectedResponse); + const [response] = await client.getLoginProfile(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getLoginProfile without error using callback', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.GetLoginProfileRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.v1.LoginProfile()); + client.innerApiCalls.getLoginProfile = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLoginProfile( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.v1.ILoginProfile|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getLoginProfile with error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.GetLoginProfileRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getLoginProfile = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { await client.getLoginProfile(request); }, expectedError); + assert((client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); }); - it('invokes updateSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.updateSshPublicKey = stubSimpleCallWithCallback( - expectedResponse - ); - const promise = new Promise((resolve, reject) => { - client.updateSshPublicKey( - request, - ( - err?: Error | null, - result?: protos.google.cloud.oslogin.common.ISshPublicKey | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - } - ); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + describe('getSshPublicKey', () => { + it('invokes getSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.GetSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.common.SshPublicKey()); + client.innerApiCalls.getSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.getSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.GetSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.common.SshPublicKey()); + client.innerApiCalls.getSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.GetSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { await client.getSshPublicKey(request); }, expectedError); + assert((client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); }); - it('invokes updateSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSshPublicKey = stubSimpleCall( - undefined, - expectedError - ); - await assert.rejects(async () => { - await client.updateSshPublicKey(request); - }, expectedError); - assert( - (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); - }); - }); - - describe('Path templates', () => { - describe('posixAccount', () => { - const fakePath = '/rendered/path/posixAccount'; - const expectedParameters = { - user: 'userValue', - project: 'projectValue', - }; - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.posixAccountPathTemplate.render = sinon - .stub() - .returns(fakePath); - client.pathTemplates.posixAccountPathTemplate.match = sinon - .stub() - .returns(expectedParameters); - - it('posixAccountPath', () => { - const result = client.posixAccountPath('userValue', 'projectValue'); - assert.strictEqual(result, fakePath); - assert( - (client.pathTemplates.posixAccountPathTemplate.render as SinonStub) - .getCall(-1) - .calledWith(expectedParameters) - ); - }); - - it('matchUserFromPosixAccountName', () => { - const result = client.matchUserFromPosixAccountName(fakePath); - assert.strictEqual(result, 'userValue'); - assert( - (client.pathTemplates.posixAccountPathTemplate.match as SinonStub) - .getCall(-1) - .calledWith(fakePath) - ); - }); - - it('matchProjectFromPosixAccountName', () => { - const result = client.matchProjectFromPosixAccountName(fakePath); - assert.strictEqual(result, 'projectValue'); - assert( - (client.pathTemplates.posixAccountPathTemplate.match as SinonStub) - .getCall(-1) - .calledWith(fakePath) - ); - }); + describe('importSshPublicKey', () => { + it('invokes importSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.ImportSshPublicKeyRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.v1.ImportSshPublicKeyResponse()); + client.innerApiCalls.importSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.importSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.ImportSshPublicKeyRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.v1.ImportSshPublicKeyResponse()); + client.innerApiCalls.importSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.v1.IImportSshPublicKeyResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.ImportSshPublicKeyRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { await client.importSshPublicKey(request); }, expectedError); + assert((client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); }); - describe('sshPublicKey', () => { - const fakePath = '/rendered/path/sshPublicKey'; - const expectedParameters = { - user: 'userValue', - fingerprint: 'fingerprintValue', - }; - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.sshPublicKeyPathTemplate.render = sinon - .stub() - .returns(fakePath); - client.pathTemplates.sshPublicKeyPathTemplate.match = sinon - .stub() - .returns(expectedParameters); - - it('sshPublicKeyPath', () => { - const result = client.sshPublicKeyPath('userValue', 'fingerprintValue'); - assert.strictEqual(result, fakePath); - assert( - (client.pathTemplates.sshPublicKeyPathTemplate.render as SinonStub) - .getCall(-1) - .calledWith(expectedParameters) - ); - }); - - it('matchUserFromSshPublicKeyName', () => { - const result = client.matchUserFromSshPublicKeyName(fakePath); - assert.strictEqual(result, 'userValue'); - assert( - (client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) - .getCall(-1) - .calledWith(fakePath) - ); - }); - - it('matchFingerprintFromSshPublicKeyName', () => { - const result = client.matchFingerprintFromSshPublicKeyName(fakePath); - assert.strictEqual(result, 'fingerprintValue'); - assert( - (client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) - .getCall(-1) - .calledWith(fakePath) - ); - }); + describe('updateSshPublicKey', () => { + it('invokes updateSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.common.SshPublicKey()); + client.innerApiCalls.updateSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.updateSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.common.SshPublicKey()); + client.innerApiCalls.updateSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1.UpdateSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { await client.updateSshPublicKey(request); }, expectedError); + assert((client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); }); - describe('user', () => { - const fakePath = '/rendered/path/user'; - const expectedParameters = { - user: 'userValue', - }; - const client = new osloginserviceModule.v1.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.userPathTemplate.render = sinon - .stub() - .returns(fakePath); - client.pathTemplates.userPathTemplate.match = sinon - .stub() - .returns(expectedParameters); - - it('userPath', () => { - const result = client.userPath('userValue'); - assert.strictEqual(result, fakePath); - assert( - (client.pathTemplates.userPathTemplate.render as SinonStub) - .getCall(-1) - .calledWith(expectedParameters) - ); - }); - - it('matchUserFromUserName', () => { - const result = client.matchUserFromUserName(fakePath); - assert.strictEqual(result, 'userValue'); - assert( - (client.pathTemplates.userPathTemplate.match as SinonStub) - .getCall(-1) - .calledWith(fakePath) - ); - }); + describe('Path templates', () => { + + describe('posixAccount', () => { + const fakePath = "/rendered/path/posixAccount"; + const expectedParameters = { + user: "userValue", + project: "projectValue", + }; + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.posixAccountPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.posixAccountPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('posixAccountPath', () => { + const result = client.posixAccountPath("userValue", "projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.posixAccountPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchUserFromPosixAccountName', () => { + const result = client.matchUserFromPosixAccountName(fakePath); + assert.strictEqual(result, "userValue"); + assert((client.pathTemplates.posixAccountPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProjectFromPosixAccountName', () => { + const result = client.matchProjectFromPosixAccountName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.posixAccountPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('sshPublicKey', () => { + const fakePath = "/rendered/path/sshPublicKey"; + const expectedParameters = { + user: "userValue", + fingerprint: "fingerprintValue", + }; + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.sshPublicKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.sshPublicKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('sshPublicKeyPath', () => { + const result = client.sshPublicKeyPath("userValue", "fingerprintValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.sshPublicKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchUserFromSshPublicKeyName', () => { + const result = client.matchUserFromSshPublicKeyName(fakePath); + assert.strictEqual(result, "userValue"); + assert((client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchFingerprintFromSshPublicKeyName', () => { + const result = client.matchFingerprintFromSshPublicKeyName(fakePath); + assert.strictEqual(result, "fingerprintValue"); + assert((client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('user', () => { + const fakePath = "/rendered/path/user"; + const expectedParameters = { + user: "userValue", + }; + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.userPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.userPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('userPath', () => { + const result = client.userPath("userValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.userPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchUserFromUserName', () => { + const result = client.matchUserFromUserName(fakePath); + assert.strictEqual(result, "userValue"); + assert((client.pathTemplates.userPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); }); - }); }); diff --git a/packages/google-cloud-oslogin/test/gapic_os_login_service_v1beta.ts b/packages/google-cloud-oslogin/test/gapic_os_login_service_v1beta.ts index 53e0454bdfb6..d501e3082db0 100644 --- a/packages/google-cloud-oslogin/test/gapic_os_login_service_v1beta.ts +++ b/packages/google-cloud-oslogin/test/gapic_os_login_service_v1beta.ts @@ -20,946 +20,714 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; import {SinonStub} from 'sinon'; -import {describe, it} from 'mocha'; +import { describe, it } from 'mocha'; import * as osloginserviceModule from '../src'; import {protobuf} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message).toObject( - instance as protobuf.Message, - {defaults: true} - ); - return (instance.constructor as typeof protobuf.Message).fromObject( - filledObject - ) as T; + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error - ? sinon.stub().rejects(error) - : sinon.stub().resolves([response]); + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback( - response?: ResponseType, - error?: Error -) { - return error - ? sinon.stub().callsArgWith(2, error) - : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); } describe('v1beta.OsLoginServiceClient', () => { - it('has servicePath', () => { - const servicePath = - osloginserviceModule.v1beta.OsLoginServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = - osloginserviceModule.v1beta.OsLoginServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = osloginserviceModule.v1beta.OsLoginServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - fallback: true, + it('has servicePath', () => { + const servicePath = osloginserviceModule.v1beta.OsLoginServiceClient.servicePath; + assert(servicePath); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.osLoginServiceStub, undefined); - await client.initialize(); - assert(client.osLoginServiceStub); - }); - - it('has close method', () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.close(); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('deletePosixAccount', () => { - it('invokes deletePosixAccount without error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.DeletePosixAccountRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePosixAccount = stubSimpleCall( - expectedResponse - ); - const [response] = await client.deletePosixAccount(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + it('has apiEndpoint', () => { + const apiEndpoint = osloginserviceModule.v1beta.OsLoginServiceClient.apiEndpoint; + assert(apiEndpoint); }); - it('invokes deletePosixAccount without error using callback', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.DeletePosixAccountRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePosixAccount = stubSimpleCallWithCallback( - expectedResponse - ); - const promise = new Promise((resolve, reject) => { - client.deletePosixAccount( - request, - ( - err?: Error | null, - result?: protos.google.protobuf.IEmpty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - } - ); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + it('has port', () => { + const port = osloginserviceModule.v1beta.OsLoginServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - it('invokes deletePosixAccount with error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.DeletePosixAccountRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePosixAccount = stubSimpleCall( - undefined, - expectedError - ); - await assert.rejects(async () => { - await client.deletePosixAccount(request); - }, expectedError); - assert( - (client.innerApiCalls.deletePosixAccount as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); - }); - }); - - describe('deleteSshPublicKey', () => { - it('invokes deleteSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteSshPublicKey = stubSimpleCall( - expectedResponse - ); - const [response] = await client.deleteSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + it('should create a client with no option', () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient(); + assert(client); }); - it('invokes deleteSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteSshPublicKey = stubSimpleCallWithCallback( - expectedResponse - ); - const promise = new Promise((resolve, reject) => { - client.deleteSshPublicKey( - request, - ( - err?: Error | null, - result?: protos.google.protobuf.IEmpty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - } - ); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + it('should create a client with gRPC fallback', () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + fallback: true, + }); + assert(client); }); - it('invokes deleteSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSshPublicKey = stubSimpleCall( - undefined, - expectedError - ); - await assert.rejects(async () => { - await client.deleteSshPublicKey(request); - }, expectedError); - assert( - (client.innerApiCalls.deleteSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); - }); - }); - - describe('getLoginProfile', () => { - it('invokes getLoginProfile without error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.GetLoginProfileRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.LoginProfile() - ); - client.innerApiCalls.getLoginProfile = stubSimpleCall(expectedResponse); - const [response] = await client.getLoginProfile(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + it('has initialize method and supports deferred initialization', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.osLoginServiceStub, undefined); + await client.initialize(); + assert(client.osLoginServiceStub); }); - it('invokes getLoginProfile without error using callback', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.GetLoginProfileRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.LoginProfile() - ); - client.innerApiCalls.getLoginProfile = stubSimpleCallWithCallback( - expectedResponse - ); - const promise = new Promise((resolve, reject) => { - client.getLoginProfile( - request, - ( - err?: Error | null, - result?: protos.google.cloud.oslogin.v1beta.ILoginProfile | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - } - ); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + it('has close method', () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); }); - it('invokes getLoginProfile with error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.GetLoginProfileRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getLoginProfile = stubSimpleCall( - undefined, - expectedError - ); - await assert.rejects(async () => { - await client.getLoginProfile(request); - }, expectedError); - assert( - (client.innerApiCalls.getLoginProfile as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); - }); - }); - - describe('getSshPublicKey', () => { - it('invokes getSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.getSshPublicKey = stubSimpleCall(expectedResponse); - const [response] = await client.getSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - it('invokes getSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.getSshPublicKey = stubSimpleCallWithCallback( - expectedResponse - ); - const promise = new Promise((resolve, reject) => { - client.getSshPublicKey( - request, - ( - err?: Error | null, - result?: protos.google.cloud.oslogin.common.ISshPublicKey | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - } - ); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); }); - it('invokes getSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getSshPublicKey = stubSimpleCall( - undefined, - expectedError - ); - await assert.rejects(async () => { - await client.getSshPublicKey(request); - }, expectedError); - assert( - (client.innerApiCalls.getSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); - }); - }); - - describe('importSshPublicKey', () => { - it('invokes importSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest() - ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse() - ); - client.innerApiCalls.importSshPublicKey = stubSimpleCall( - expectedResponse - ); - const [response] = await client.importSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + describe('deletePosixAccount', () => { + it('invokes deletePosixAccount without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.DeletePosixAccountRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deletePosixAccount = stubSimpleCall(expectedResponse); + const [response] = await client.deletePosixAccount(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deletePosixAccount without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.DeletePosixAccountRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deletePosixAccount = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePosixAccount( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deletePosixAccount with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.DeletePosixAccountRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePosixAccount = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { await client.deletePosixAccount(request); }, expectedError); + assert((client.innerApiCalls.deletePosixAccount as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); }); - it('invokes importSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest() - ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse() - ); - client.innerApiCalls.importSshPublicKey = stubSimpleCallWithCallback( - expectedResponse - ); - const promise = new Promise((resolve, reject) => { - client.importSshPublicKey( - request, - ( - err?: Error | null, - result?: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - } - ); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + describe('deleteSshPublicKey', () => { + it('invokes deleteSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.deleteSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSshPublicKey( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.DeleteSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { await client.deleteSshPublicKey(request); }, expectedError); + assert((client.innerApiCalls.deleteSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); }); - it('invokes importSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest() - ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.importSshPublicKey = stubSimpleCall( - undefined, - expectedError - ); - await assert.rejects(async () => { - await client.importSshPublicKey(request); - }, expectedError); - assert( - (client.innerApiCalls.importSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); - }); - }); - - describe('updateSshPublicKey', () => { - it('invokes updateSshPublicKey without error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.updateSshPublicKey = stubSimpleCall( - expectedResponse - ); - const [response] = await client.updateSshPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + describe('getLoginProfile', () => { + it('invokes getLoginProfile without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.GetLoginProfileRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.LoginProfile()); + client.innerApiCalls.getLoginProfile = stubSimpleCall(expectedResponse); + const [response] = await client.getLoginProfile(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getLoginProfile without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.GetLoginProfileRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.LoginProfile()); + client.innerApiCalls.getLoginProfile = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLoginProfile( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.v1beta.ILoginProfile|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getLoginProfile with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.GetLoginProfileRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getLoginProfile = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { await client.getLoginProfile(request); }, expectedError); + assert((client.innerApiCalls.getLoginProfile as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); }); - it('invokes updateSshPublicKey without error using callback', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.oslogin.common.SshPublicKey() - ); - client.innerApiCalls.updateSshPublicKey = stubSimpleCallWithCallback( - expectedResponse - ); - const promise = new Promise((resolve, reject) => { - client.updateSshPublicKey( - request, - ( - err?: Error | null, - result?: protos.google.cloud.oslogin.common.ISshPublicKey | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - } - ); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + describe('getSshPublicKey', () => { + it('invokes getSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.common.SshPublicKey()); + client.innerApiCalls.getSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.getSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.common.SshPublicKey()); + client.innerApiCalls.getSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.GetSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { await client.getSshPublicKey(request); }, expectedError); + assert((client.innerApiCalls.getSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); }); - it('invokes updateSshPublicKey with error', async () => { - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateSshPublicKey = stubSimpleCall( - undefined, - expectedError - ); - await assert.rejects(async () => { - await client.updateSshPublicKey(request); - }, expectedError); - assert( - (client.innerApiCalls.updateSshPublicKey as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); - }); - }); - - describe('Path templates', () => { - describe('posixAccount', () => { - const fakePath = '/rendered/path/posixAccount'; - const expectedParameters = { - user: 'userValue', - project: 'projectValue', - }; - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.posixAccountPathTemplate.render = sinon - .stub() - .returns(fakePath); - client.pathTemplates.posixAccountPathTemplate.match = sinon - .stub() - .returns(expectedParameters); - - it('posixAccountPath', () => { - const result = client.posixAccountPath('userValue', 'projectValue'); - assert.strictEqual(result, fakePath); - assert( - (client.pathTemplates.posixAccountPathTemplate.render as SinonStub) - .getCall(-1) - .calledWith(expectedParameters) - ); - }); - - it('matchUserFromPosixAccountName', () => { - const result = client.matchUserFromPosixAccountName(fakePath); - assert.strictEqual(result, 'userValue'); - assert( - (client.pathTemplates.posixAccountPathTemplate.match as SinonStub) - .getCall(-1) - .calledWith(fakePath) - ); - }); - - it('matchProjectFromPosixAccountName', () => { - const result = client.matchProjectFromPosixAccountName(fakePath); - assert.strictEqual(result, 'projectValue'); - assert( - (client.pathTemplates.posixAccountPathTemplate.match as SinonStub) - .getCall(-1) - .calledWith(fakePath) - ); - }); + describe('importSshPublicKey', () => { + it('invokes importSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse()); + client.innerApiCalls.importSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.importSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes importSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse()); + client.innerApiCalls.importSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.v1beta.IImportSshPublicKeyResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes importSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.importSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { await client.importSshPublicKey(request); }, expectedError); + assert((client.innerApiCalls.importSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); }); - describe('sshPublicKey', () => { - const fakePath = '/rendered/path/sshPublicKey'; - const expectedParameters = { - user: 'userValue', - fingerprint: 'fingerprintValue', - }; - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.sshPublicKeyPathTemplate.render = sinon - .stub() - .returns(fakePath); - client.pathTemplates.sshPublicKeyPathTemplate.match = sinon - .stub() - .returns(expectedParameters); - - it('sshPublicKeyPath', () => { - const result = client.sshPublicKeyPath('userValue', 'fingerprintValue'); - assert.strictEqual(result, fakePath); - assert( - (client.pathTemplates.sshPublicKeyPathTemplate.render as SinonStub) - .getCall(-1) - .calledWith(expectedParameters) - ); - }); - - it('matchUserFromSshPublicKeyName', () => { - const result = client.matchUserFromSshPublicKeyName(fakePath); - assert.strictEqual(result, 'userValue'); - assert( - (client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) - .getCall(-1) - .calledWith(fakePath) - ); - }); - - it('matchFingerprintFromSshPublicKeyName', () => { - const result = client.matchFingerprintFromSshPublicKeyName(fakePath); - assert.strictEqual(result, 'fingerprintValue'); - assert( - (client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) - .getCall(-1) - .calledWith(fakePath) - ); - }); + describe('updateSshPublicKey', () => { + it('invokes updateSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.common.SshPublicKey()); + client.innerApiCalls.updateSshPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.updateSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.oslogin.common.SshPublicKey()); + client.innerApiCalls.updateSshPublicKey = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateSshPublicKey( + request, + (err?: Error|null, result?: protos.google.cloud.oslogin.common.ISshPublicKey|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.oslogin.v1beta.UpdateSshPublicKeyRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateSshPublicKey = stubSimpleCall(undefined, expectedError); + await assert.rejects(async () => { await client.updateSshPublicKey(request); }, expectedError); + assert((client.innerApiCalls.updateSshPublicKey as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); }); - describe('user', () => { - const fakePath = '/rendered/path/user'; - const expectedParameters = { - user: 'userValue', - }; - const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.userPathTemplate.render = sinon - .stub() - .returns(fakePath); - client.pathTemplates.userPathTemplate.match = sinon - .stub() - .returns(expectedParameters); - - it('userPath', () => { - const result = client.userPath('userValue'); - assert.strictEqual(result, fakePath); - assert( - (client.pathTemplates.userPathTemplate.render as SinonStub) - .getCall(-1) - .calledWith(expectedParameters) - ); - }); - - it('matchUserFromUserName', () => { - const result = client.matchUserFromUserName(fakePath); - assert.strictEqual(result, 'userValue'); - assert( - (client.pathTemplates.userPathTemplate.match as SinonStub) - .getCall(-1) - .calledWith(fakePath) - ); - }); + describe('Path templates', () => { + + describe('posixAccount', () => { + const fakePath = "/rendered/path/posixAccount"; + const expectedParameters = { + user: "userValue", + project: "projectValue", + }; + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.posixAccountPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.posixAccountPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('posixAccountPath', () => { + const result = client.posixAccountPath("userValue", "projectValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.posixAccountPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchUserFromPosixAccountName', () => { + const result = client.matchUserFromPosixAccountName(fakePath); + assert.strictEqual(result, "userValue"); + assert((client.pathTemplates.posixAccountPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchProjectFromPosixAccountName', () => { + const result = client.matchProjectFromPosixAccountName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.posixAccountPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('sshPublicKey', () => { + const fakePath = "/rendered/path/sshPublicKey"; + const expectedParameters = { + user: "userValue", + fingerprint: "fingerprintValue", + }; + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.sshPublicKeyPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.sshPublicKeyPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('sshPublicKeyPath', () => { + const result = client.sshPublicKeyPath("userValue", "fingerprintValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.sshPublicKeyPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchUserFromSshPublicKeyName', () => { + const result = client.matchUserFromSshPublicKeyName(fakePath); + assert.strictEqual(result, "userValue"); + assert((client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchFingerprintFromSshPublicKeyName', () => { + const result = client.matchFingerprintFromSshPublicKeyName(fakePath); + assert.strictEqual(result, "fingerprintValue"); + assert((client.pathTemplates.sshPublicKeyPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('user', () => { + const fakePath = "/rendered/path/user"; + const expectedParameters = { + user: "userValue", + }; + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.userPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.userPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('userPath', () => { + const result = client.userPath("userValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.userPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchUserFromUserName', () => { + const result = client.matchUserFromUserName(fakePath); + assert.strictEqual(result, "userValue"); + assert((client.pathTemplates.userPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); }); - }); }); diff --git a/packages/google-cloud-oslogin/webpack.config.js b/packages/google-cloud-oslogin/webpack.config.js index ee3e093147b8..5b16c430172b 100644 --- a/packages/google-cloud-oslogin/webpack.config.js +++ b/packages/google-cloud-oslogin/webpack.config.js @@ -36,27 +36,27 @@ module.exports = { { test: /\.tsx?$/, use: 'ts-loader', - exclude: /node_modules/, + exclude: /node_modules/ }, { test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader', + use: 'null-loader' }, { test: /node_modules[\\/]grpc/, - use: 'null-loader', + use: 'null-loader' }, { test: /node_modules[\\/]retry-request/, - use: 'null-loader', + use: 'null-loader' }, { test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader', + use: 'null-loader' }, { test: /node_modules[\\/]gtoken/, - use: 'null-loader', + use: 'null-loader' }, ], },