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 secureSessCfgProps

secureSessCfgProps: Set<string> = new Set(["user", "password", "tokenValue", "passphrase"])

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

NOTE(Kelosky): redundant from LoggerUtils.SECURE_PROMPT_OPTIONS - leaving for future date to consolidate

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

    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>

Static Private getValuesBack

Static Private loadSchemaForSessCfgProps

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

Static Private loadSecureSessCfgProps

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

Static Private logSessCfg

  • logSessCfg(sessCfg: any): void

Static Private propHasValue

  • propHasValue(propToTest: any): boolean

Static resolveSessCfgProps

  • 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

    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

Static Private setTypeForTokenRequest

  • setTypeForTokenRequest<SessCfgType>(sessCfg: SessCfgType, options: IOptionsForAddConnProps<SessCfgType>, tokenType: SessConstants.TOKEN_TYPE_CHOICES): void
  • Determine if we want to request a token. Set the session's type and tokenType accordingly.

    Type parameters

    Parameters

    • sessCfg: SessCfgType
        The session configuration to be updated.
      
    • options: IOptionsForAddConnProps<SessCfgType>
        Options that alter our actions. See IOptionsForAddConnProps.
      
    • tokenType: SessConstants.TOKEN_TYPE_CHOICES
        The type of token that we expect to receive.
      

    Returns void

Object literals

Static Private Readonly promptTextForValues

promptTextForValues: object

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

hostname

hostname: string = "Enter the host name of"

password

password: string = "Enter the password for"

port

port: string = "Enter the port number of"

user

user: string = "Enter the user name for"

Generated using TypeDoc