This class adds connection information to an existing session configuration object for making REST API calls with the Imperative RestClient.

### Hierarchy

- ConnectionPropsForSessCfg

## Index

### Properties

- secureSessCfgProps

### Methods

- addPropsOrPrompt
- clientPrompt
- getValuesBack
- loadSchemaForSessCfgProps
- loadSecureSessCfgProps
- propHasValue
- resolveSessCfgProps
- sessHasCreds

### Object literals

- promptTextForValues

## Properties

### Static Private Readonly secureSessCfgProps

secureSessCfgProps: Set<string> = new Set(Censor.SECURE_PROMPT_OPTIONS)

- Defined in @zowe/imperative/src/rest/src/session/ConnectionPropsForSessCfg.ts:358

List of properties on `sessCfg` object that should be kept secret and may not appear in Imperative log files.

## Methods

### Static addPropsOrPrompt

- addPropsOrPrompt<SessCfgType>(initialSessCfg: SessCfgType, cmdArgs: ICommandArguments, connOpts?: IOptionsForAddConnProps<SessCfgType>): Promise<SessCfgType>

- - Defined in @zowe/imperative/src/rest/src/session/ConnectionPropsForSessCfg.ts:99

  Create a REST session configuration object starting with the supplied initialSessCfg and retrieving connection properties from the command line arguments (or environment, or profile). If required connection properties are missing we interactively prompt the user for the values. for any of the following properties: host port user name password

  Any prompt will timeout after 30 seconds so that this function can be run from an automated script, and will not indefinitely hang that script.

  In addition to properties that we prompt for, we will also add the following properties to the session configuration if they are available. type tokenType tokenValue

  example

         // Within the process() function of a command handler,
         // do steps similar to the following:
         const sessCfg: ISession =  {
             rejectUnauthorized: commandParameters.arguments.rejectUnauthorized,
             basePath: commandParameters.arguments.basePath
         };
         const connectableSessCfg = await ConnectionPropsForSessCfg.addPropsOrPrompt<ISession>(
              sessCfg, commandParameters.arguments
         );
         mySession = new Session(connectableSessCfg);

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### initialSessCfg: SessCfgType

           An initial session configuration (like ISession, or other
           specially defined configuration) that contains your desired
           session configuration properties.

  - ##### cmdArgs: ICommandArguments

           The arguments specified by the user on the command line
           (or in environment, or in profile). The contents of the
           supplied cmdArgs will be modified.

  - ##### Default value connOpts: IOptionsForAddConnProps<SessCfgType> = {}

           Options that alter our connection actions. See IOptionsForAddConnProps.
           The connOpts parameter need not be supplied.

  #### Returns Promise<SessCfgType>

  A session configuration object with connection information added to the initialSessCfg. Its intended use is for our caller to create a session for a REST Client.

### Static Private clientPrompt

- clientPrompt(promptText: string, opts: IHandlePromptOptions): Promise<string>

- - Defined in @zowe/imperative/src/rest/src/session/ConnectionPropsForSessCfg.ts:467

  Handle prompting for clients. If in a CLI environment, use the IHandlerParameters.response object prompt method.

  static
  memberof

    ConnectionPropsForSessCfg

  #### Parameters

  - ##### promptText: string

  - ##### opts: IHandlePromptOptions

  #### Returns Promise<string>

### Static Private getValuesBack

- getValuesBack<SessCfgType>(connOpts: IOptionsForAddConnProps<SessCfgType>): (properties: string[]) => Promise<{}>

- - Defined in @zowe/imperative/src/rest/src/session/ConnectionPropsForSessCfg.ts:378

  Prompts the user to input session config values in a CLI environment. This is the default implementation of the `getValuesBack` callback when `connOpts.doPrompting` is true.

  #### Type parameters

  - #### SessCfgType: ISession = ISession

  #### Parameters

  - ##### connOpts: IOptionsForAddConnProps<SessCfgType>

    Options for adding connection properties

  #### Returns (properties: string[]) => Promise<{}>

  Name-value pairs of connection properties

  - - (properties: string[]): Promise<{}>

    - #### Parameters

      - ##### properties: string[]

      #### Returns Promise<{}>

### Static Private loadSchemaForSessCfgProps

- loadSchemaForSessCfgProps(params: IHandlerParameters | undefined, promptForValues: string[]): {}

- - Defined in @zowe/imperative/src/rest/src/session/ConnectionPropsForSessCfg.ts:494

  Load base profile property schema for connection properties.

  #### Parameters

  - ##### params: IHandlerParameters | undefined

    CLI handler parameters object

  - ##### promptForValues: string[]

    List of ISessCfg properties to prompt for

  #### Returns {}

  Key-value pairs of ISessCfg property name and profile property schema

  - ##### [key: string]: IProfileProperty

### Static Private loadSecureSessCfgProps

- loadSecureSessCfgProps(params: IHandlerParameters | undefined, promptForValues: string[]): void

- - Defined in @zowe/imperative/src/rest/src/session/ConnectionPropsForSessCfg.ts:512

  Load list of secure property names defined in team config.

  #### Parameters

  - ##### params: IHandlerParameters | undefined

    CLI handler parameters object

  - ##### promptForValues: string[]

    List of ISessCfg properties to prompt for

  #### Returns void

### Static Private propHasValue

- propHasValue(propToTest: any): boolean

- - Defined in @zowe/imperative/src/rest/src/session/ConnectionPropsForSessCfg.ts:484

  Confirm whether the specified property has a value.

  #### Parameters

  - ##### propToTest: any

          the property key to be confirmed.

  #### Returns boolean

  true is the property exists and has a value. false otherwise.

### Static resolveSessCfgProps

- resolveSessCfgProps<SessCfgType>(sessCfg: SessCfgType, cmdArgs?: ICommandArguments, connOpts?: IOptionsForAddConnProps<SessCfgType>): void

- - Defined in @zowe/imperative/src/rest/src/session/ConnectionPropsForSessCfg.ts:273

  Resolve the overlapping or mutually exclusive properties that can occur. Ensure that the resulting session configuration object contains only the applicable properties. The contents of the supplied sessCfg, cmdArgs, and connOpts will be modified.

  example

         let sessCfg = YouCollectAllProfilePropertiesRelatedToSession();
         let cmdArgs = YouSetPropertiesRequiredInCmdArgs();
         ConnectionPropsForSessCfg.resolveSessCfgProps(sessCfg, cmdArgs);
         sessionToUse = new Session(sessCfg);

  #### Type parameters

  - #### SessCfgType: ISession

  #### Parameters

  - ##### sessCfg: SessCfgType

         An initial session configuration that contains your desired
         session configuration properties.

  - ##### Default value cmdArgs: ICommandArguments = { $0: "", _: [] }

         The arguments specified by the user on the command line
         (or in environment, or in profile)

  - ##### Default value connOpts: IOptionsForAddConnProps<SessCfgType> = {}

         Options that alter our actions. See IOptionsForAddConnProps.
         The connOpts parameter need not be supplied.
         The only option values used by this function are:
             connOpts.requestToken
             connOpts.defaultTokenType

  #### Returns void

### Static sessHasCreds

- sessHasCreds(sessToTest: ISession): string | false | true

- - Defined in @zowe/imperative/src/rest/src/session/ConnectionPropsForSessCfg.ts:343

  Confirm whether the given session has a credentials.

  #### Parameters

  - ##### sessToTest: ISession

          the session to be confirmed.

  #### Returns string | false | true

  true is the session has credentials. false otherwise.

## Object literals

### Static Private Readonly promptTextForValues

promptTextForValues: object

- Defined in @zowe/imperative/src/rest/src/session/ConnectionPropsForSessCfg.ts:364

List of prompt messages that is used when the CLI prompts for session config values.

### hostname

hostname: string = "Enter the host name of"

- Defined in @zowe/imperative/src/rest/src/session/ConnectionPropsForSessCfg.ts:365

### password

password: string = "Enter the password for"

- Defined in @zowe/imperative/src/rest/src/session/ConnectionPropsForSessCfg.ts:368

### port

port: string = "Enter the port number of"

- Defined in @zowe/imperative/src/rest/src/session/ConnectionPropsForSessCfg.ts:366

### user

user: string = "Enter the user name for"

- Defined in @zowe/imperative/src/rest/src/session/ConnectionPropsForSessCfg.ts:367

Generated using TypeDoc