import { AbstractSession , ImperativeExpect , ImperativeError } from "@zowe/imperative" ; import { IMountFsOptions } from "./doc/IMountFsOptions" ; import { isNullOrUndefined } from "util" ; import { ZosmfRestClient , ZosmfHeaders } from "@zowe/core-for-zowe-sdk" ; import { ZosFilesConstants } from "../../constants/ZosFiles.constants" ; import { ZosFilesMessages } from "../../constants/ZosFiles.messages" ; import { IZosFilesResponse } from "../../doc/IZosFilesResponse" ; /**
 * This class holds helper functions that are used to mount file systems through the z/OS MF APIs
 */ export class Mount { param { AbstractSession } session param { string } fileSystemName param { string } mountPoint param { IListOptions } options returns { Promise < IZosFilesResponse > } throws throws {Error} When the  ZosmfRestClient throws an error
     *
     *  see https public static async fs ( session , fileSystemName , mountPoint , options ? ) { ImperativeExpect . toBeDefinedAndNonBlank ( fileSystemName , ZosFilesMessages . missingFileSystemName . message ) ; ImperativeExpect . toBeDefinedAndNonBlank ( mountPoint , ZosFilesMessages . missingMountPoint . message ) ; const tempOptions = ! isNullOrUndefined ( options ) ? JSON . parse ( JSON . stringify ( options ) ) : { } ; this . fsValidateOptions ( tempOptions ) ; tempOptions . action = "mount" ; tempOptions [ "mount-point" ] = mountPoint ; const endpoint = ZosFilesConstants . RESOURCE + ZosFilesConstants . RES_MFS + "/" + fileSystemName ; const jsonContent = JSON . stringify ( tempOptions ) ; const headers = [ { "Content-Length" : jsonContent . length } , ZosmfHeaders . ACCEPT_ENCODING ] ; if ( options . responseTimeout != null ) { headers . push ( { [ ZosmfHeaders . X_IBM_RESPONSE_TIMEOUT ] : options . responseTimeout . toString ( ) } ) ; } const data = await ZosmfRestClient . putExpectString ( session , endpoint , headers , jsonContent ) ; return { success : true , commandResponse : ZosFilesMessages . fsMountedSuccessfully . message , apiResponse : data } ; } param options private static fsValidateOptions ( options ) { ImperativeExpect . toNotBeNullOrUndefined ( options , ZosFilesMessages . missingFilesMountOptions . message ) ; ImperativeExpect . toBeDefinedAndNonBlank ( options [ "fs-type" ] , ZosFilesMessages . missingFsOption . message + "fs-type" ) ; ImperativeExpect . toBeDefinedAndNonBlank ( options . mode , ZosFilesMessages . missingFsOption . message + "mode" ) ; for ( const option in options ) { if ( Object . prototype . hasOwnProperty . call ( options , option ) ) { switch ( option ) { case "mode" : if ( ( options . mode !== "rdonly" ) && ( options . mode !== "rdwr" ) ) { throw new ImperativeError ( { msg : ZosFilesMessages . invalidMountModeOption . message + options . mode } ) ; } break ; case "fs-type" : case "responseTimeout" : break ; default : throw new ImperativeError ( { msg : ZosFilesMessages . invalidFilesMountOption . message + option } ) ; } } } } }