Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ConnectionPropsForSessCfg

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

Hierarchy

  • ConnectionPropsForSessCfg

Index

Properties

Static Private Readonly secureSessCfgProps

secureSessCfgProps: string[] = ["user", "password", "tokenValue"]

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

Methods

Static addPropsOrPrompt

  • 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

    • T

    Parameters

    • initialSessCfg: T
         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)
      
    • Default value options: IOptionsForAddConnProps = {}
         Options that alter our actions. See IOptionsForAddConnProps.
         The options parameter need not be supplied.
      

    Returns Promise<T>

    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 logSessCfg

  • logSessCfg(sessCfg: any): void

Static Private propHasValue

  • propHasValue(propToTest: string): boolean

Static Private setTypeForBasicCreds

  • setTypeForBasicCreds(sessCfg: any, options: IOptionsForAddConnProps, tokenType: SessConstants.TOKEN_TYPE_CHOICES): void

Generated using TypeDoc