The Config class provides facilities for reading and writing team configuration files. It is used by Imperative to perform low-level operations on a team configuration. The intent is that consumer apps will not typically use the Config class, since end-users are expected to write team configuration files by directly editing them in an editor like VSCode.

### Hierarchy

- Config

## Index

### Constructors

- constructor

### Properties

- mActive
- mApi
- mApp
- mHomeDir
- mLayers
- mProjectDir
- mSecure
- mVault
- opts
- END_OF_TEAM_CONFIG
- END_OF_USER_CONFIG

### Accessors

- api
- appName
- configName
- exists
- layers
- mProperties
- maskedProperties
- paths
- properties
- schemaName
- userConfigName

### Methods

- delete
- findLayer
- formMainConfigPathNm
- getSchemaInfo
- layerActive
- layerExists
- layerMerge
- layerPath
- layerProfiles
- reload
- save
- set
- setSchema
- empty
- load
- search

## Constructors

### Private constructor

- new Config(opts?: IConfigOpts): Config

- - Defined in @zowe/imperative/src/config/src/Config.ts:118

  Constructor for Config class. Don't use this directly. Await `Config.load` instead.

  #### Parameters

  - ##### Optional opts: IConfigOpts

    Options to control how Config class behaves

  #### Returns Config

## Properties

### mActive

mActive: { global: boolean; user: boolean }

- Defined in @zowe/imperative/src/config/src/Config.ts:93

Currently active layer whose properties will be manipulated

internal

#### Type declaration

- ##### global: boolean

- ##### user: boolean

### Private mApi

mApi: { layers: ConfigLayers; plugins: ConfigPlugins; profiles: ConfigProfiles; secure: ConfigSecure }

- Defined in @zowe/imperative/src/config/src/Config.ts:113

Cached version of Config APIs

#### Type declaration

- ##### layers: ConfigLayers

- ##### plugins: ConfigPlugins

- ##### profiles: ConfigProfiles

- ##### secure: ConfigSecure

### mApp

mApp: string

- Defined in @zowe/imperative/src/config/src/Config.ts:69

App name used in config filenames (e.g., my_cli.config.json) It could be an absolute path, we recommend always using the getter method

internal

### mHomeDir

mHomeDir: string

- Defined in @zowe/imperative/src/config/src/Config.ts:81

Directory where global config files are located. Defaults to `~/.appName`.

internal

### mLayers

mLayers: IConfigLayer[]

- Defined in @zowe/imperative/src/config/src/Config.ts:75

List to store each of the config layers enumerated in `layers` enum

internal

### mProjectDir

mProjectDir: string | false

- Defined in @zowe/imperative/src/config/src/Config.ts:87

Directory where project config files are located. Defaults to working directory.

internal

### mSecure

mSecure: IConfigSecure

- Defined in @zowe/imperative/src/config/src/Config.ts:108

Secure properties object stored in credential vault

internal

### mVault

mVault: IConfigVault

- Defined in @zowe/imperative/src/config/src/Config.ts:102

Vault object with methods for loading and saving secure credentials

internal

### Optional opts

opts: IConfigOpts

- Defined in @zowe/imperative/src/config/src/Config.ts:126

Options to control how Config class behaves

### Static Private Readonly END_OF_TEAM_CONFIG

END_OF_TEAM_CONFIG: ".config.json" = ".config.json"

- Defined in @zowe/imperative/src/config/src/Config.ts:57

The trailing portion of a shared config file name

### Static Private Readonly END_OF_USER_CONFIG

END_OF_USER_CONFIG: ".config.user.json" = ".config.user.json"

- Defined in @zowe/imperative/src/config/src/Config.ts:62

The trailing portion of a user-specific config file name

## Accessors

### api

- get api(): { layers: ConfigLayers; plugins: ConfigPlugins; profiles: ConfigProfiles; secure: ConfigSecure }

- - Defined in @zowe/imperative/src/config/src/Config.ts:276

  Access the config API for manipulating profiles, plugins, layers, and secure values.

  #### Returns { layers: ConfigLayers; plugins: ConfigPlugins; profiles: ConfigProfiles; secure: ConfigSecure }

  - ##### layers: ConfigLayers

  - ##### plugins: ConfigPlugins

  - ##### profiles: ConfigProfiles

  - ##### secure: ConfigSecure

### appName

- get appName(): string

- - Defined in @zowe/imperative/src/config/src/Config.ts:339

  App name used in config filenames (e.g., my_cli.config.json)

  #### Returns string

### configName

- get configName(): string

- - Defined in @zowe/imperative/src/config/src/Config.ts:347

  Filename used for config JSONC files

  #### Returns string

### exists

- get exists(): boolean

- - Defined in @zowe/imperative/src/config/src/Config.ts:292

  True if any config layers exist on disk, otherwise false.

  #### Returns boolean

### layers

- get layers(): IConfigLayer[]

- - Defined in @zowe/imperative/src/config/src/Config.ts:311

  List of all config layers. Returns a clone to prevent accidental edits of the original object.

  #### Returns IConfigLayer[]

### mProperties

- get mProperties(): IConfig

- - Defined in @zowe/imperative/src/config/src/Config.ts:331

  List of properties across all config layers. Returns the original object, not a clone, so use with caution. This is used in internal code because cloning a JSONC object is slow.

  internal

  #### Returns IConfig

### maskedProperties

- get maskedProperties(): IConfig

- - Defined in @zowe/imperative/src/config/src/Config.ts:419

  The properties object with secure values masked.

  memberof

    Config

  #### Returns IConfig

### paths

- get paths(): string[]

- - Defined in @zowe/imperative/src/config/src/Config.ts:302

  List of absolute file paths for all config layers.

  #### Returns string[]

### properties

- get properties(): IConfig

- - Defined in @zowe/imperative/src/config/src/Config.ts:321

  List of properties across all config layers. Returns a clone to prevent accidental edits of the original object.

  #### Returns IConfig

### schemaName

- get schemaName(): string

- - Defined in @zowe/imperative/src/config/src/Config.ts:363

  Filename used for config schema JSON files

  #### Returns string

### userConfigName

- get userConfigName(): string

- - Defined in @zowe/imperative/src/config/src/Config.ts:355

  Filename used for user config JSONC files

  #### Returns string

## Methods

### delete

- delete(propertyPath: string, opts?: { secure?: boolean }): void

- - Defined in @zowe/imperative/src/config/src/Config.ts:482

  Unset value of a property in the active config layer.

  #### Parameters

  - ##### propertyPath: string

    Property path

  - ##### Optional opts: { secure?: boolean }

    Include `secure: false` to preserve property in secure array

    - ##### Optional secure?: boolean

  #### Returns void

### findLayer

- findLayer(user: boolean, global: boolean): IConfigLayer

- - Defined in @zowe/imperative/src/config/src/Config.ts:612

  Find the layer with the specified user and global properties.

  internal

  #### Parameters

  - ##### user: boolean

    True specifies that you want the user layer.

  - ##### global: boolean

    True specifies that you want the layer at the global level.

  #### Returns IConfigLayer

  The desired layer object. Null if no layer matches.

### formMainConfigPathNm

- formMainConfigPathNm(options: any): string

- - Defined in @zowe/imperative/src/config/src/Config.ts:670

  Form the path name of the team config file to display in messages. Always return the team name (not the user name). If the a team configuration is active, return the full path to the config file.

  #### Parameters

  - ##### options: any

    a map containing option properties. Currently, the only property supported is a boolean named addPath. {addPath: true | false}

  #### Returns string

  The path (if requested) and file name of the team config file.

### getSchemaInfo

- getSchemaInfo(): IConfigSchemaInfo

- - Defined in @zowe/imperative/src/config/src/Config.ts:371

  Schema file path used by the active layer

  #### Returns IConfigSchemaInfo

### layerActive

- layerActive(): IConfigLayer

- - Defined in @zowe/imperative/src/config/src/Config.ts:625

  Obtain the layer object that is currently active.

  #### Returns IConfigLayer

  The active layer object

### layerExists

- layerExists(inDir: string, user?: boolean): boolean

- - Defined in @zowe/imperative/src/config/src/Config.ts:637

  Check if a layer exists in the given path

  #### Parameters

  - ##### inDir: string

    The directory to which you want to look for the layer.

  - ##### Optional user: boolean

  #### Returns boolean

### layerMerge

- layerMerge(opts?: IConfigMergeOpts): IConfig

- - Defined in @zowe/imperative/src/config/src/Config.ts:530

  Merge the properties from multiple layers into a single Config object.

  internal

  #### Parameters

  - ##### Default value opts: IConfigMergeOpts = {}

    Options to control how config layers are merged

  #### Returns IConfig

  The resulting Config object

### Private layerPath

- layerPath(layer: Layers): string

- - Defined in @zowe/imperative/src/config/src/Config.ts:253

  Get absolute file path for a config layer. For project config files, We search up from our current directory and ignore the Zowe hone directory (in case our current directory is under Zowe home.). For global config files we only retrieve config files from the Zowe home directory.

  internal

  #### Parameters

  - ##### layer: Layers

    Enum value for config layer

  #### Returns string

### layerProfiles

- layerProfiles(layer: IConfigLayer, opts?: IConfigMergeOpts): {}

- - Defined in @zowe/imperative/src/config/src/Config.ts:586

  Obtain the profiles object for a specified layer object.

  internal

  #### Parameters

  - ##### layer: IConfigLayer

  - ##### Default value opts: IConfigMergeOpts = {}

    Options to control how config layers are merged

  #### Returns {}

  The resulting profile object

  - ##### [key: string]: IConfigProfile

### reload

- reload(opts?: IConfigOpts): Promise<void>

- - Defined in @zowe/imperative/src/config/src/Config.ts:167

  Reload config files from disk in the current project directory.

  throws

    An ImperativeError if the configuration does not load successfully

  #### Parameters

  - ##### Optional opts: IConfigOpts

    Options to control how Config class behaves

  #### Returns Promise<void>

### save

- save(allLayers?: boolean): Promise<void>

- - Defined in @zowe/imperative/src/config/src/Config.ts:223

  Save config files to disk and store secure properties in vault.

  #### Parameters

  - ##### Optional allLayers: boolean

    Specify true to save all config layers instead of only the active one

  #### Returns Promise<void>

### set

- set(propertyPath: string, value: any, opts?: { parseString?: boolean; secure?: boolean }): void

- - Defined in @zowe/imperative/src/config/src/Config.ts:436

  Set value of a property in the active config layer. TODO: more validation

  #### Parameters

  - ##### propertyPath: string

    Property path

  - ##### value: any

    Property value

  - ##### Optional opts: { parseString?: boolean; secure?: boolean }

    Optional parameters to change behavior

    - `parseString` - If true, strings will be converted to a more specific

                      type like boolean or number when possible

    - `secure` - If true, the property will be stored securely.

                 If false, the property will be stored in plain text.

    - ##### Optional parseString?: boolean

    - ##### Optional secure?: boolean

  #### Returns void

### setSchema

- setSchema(schema: string | object): void

- - Defined in @zowe/imperative/src/config/src/Config.ts:505

  Set the $schema value at the top of the config JSONC. Also save the schema to disk if an object is provided.

  #### Parameters

  - ##### schema: string | object

    The URI of JSON schema, or a schema object to use

  #### Returns void

### Static empty

- empty(): IConfig

- - Defined in @zowe/imperative/src/config/src/Config.ts:132

  Return a Config interface with required fields initialized as empty.

  #### Returns IConfig

### Static load

- load(app: string, opts?: IConfigOpts): Promise<Config>

- - Defined in @zowe/imperative/src/config/src/Config.ts:146

  Load config files from disk and secure properties from vault.

  throws

    An ImperativeError if the configuration does not load successfully

  #### Parameters

  - ##### app: string

    App name used in config filenames (e.g., my_cli.config.json)

  - ##### Optional opts: IConfigOpts

    Options to control how Config class behaves

  #### Returns Promise<Config>

### Static search

- search(file: string, opts?: { ignoreDirs?: string[]; startDir?: string }): string

- - Defined in @zowe/imperative/src/config/src/Config.ts:404

  Search up the directory tree for the directory containing the specified config file.

  #### Parameters

  - ##### file: string

    Contains the name of the desired config file

  - ##### Optional opts: { ignoreDirs?: string[]; startDir?: string }

    - ##### Optional ignoreDirs?: string[]

      Contains an array of directory names to be ignored (skipped) during the search.

    - ##### Optional startDir?: string

      Contains the name of the directory where the search should be started. Defaults to working directory.

  #### Returns string

  The full path name to config file or null if not found.

Generated using TypeDoc