ConfigFile

class core.zowe.core_for_zowe_sdk.config_file.ConfigFile(type: str, name: str, _location: str | None = None, profiles: dict | None = None, defaults: dict | None = None, schema_property: dict | None = None, secure_props: dict | None = None, jsonc: dict | None = None, _missing_secure_props: list = <factory>)

Class used to represent a single config file.

Mainly it will have the following details : 1. Type (“User Config” or “Team Config”)

User Configs override Team Configs. User Configs are used to have personalised config details that the user don’t want to have in the Team Config.

  1. Directory in which the file is located.

  2. Name (excluding .config.json or .config.user.json)

4. Contents of the file. 4.1 Profiles 4.2 Defaults 4.3 Schema Property 5. Secure Properties associated with the file.

autodiscover_config_dir() None

Autodiscover Zowe z/OSMF Team Config files by going up the path from current working directory :returns: * None

  • Sets path if it finds the config directory,

  • Else, it raises an Exception

find_profile(path: str, profiles: dict)

Find a profile at a specified location from within a set of nested profiles :returns: The profile object that was found, or None if not found :rtype: dictionary

get_profile(profile_name: str | None = None, profile_type: str | None = None, validate_schema: bool | None = True) Profile

Load given profile including secure properties and excluding values from base profile :returns: Returns a namedtuple called Profile :rtype: Profile

get_profile_name_from_path(path: str) str

Get the name of the profile from the given path.

get_profile_path_from_name(short_path: str) str

Get the path of the profile from the given name.

get_profilename_from_profiletype(profile_type: str) str

Returns profilename from given profiletype as defined in the team config profile :returns: * str

  • Return the exact profilename of the profile to load from the mentioned type.

  • First tries to look into the defaults, if not found,

  • then it tries to iterate through the profiles

init_from_file(validate_schema: bool | None = True) None

Initializes the class variable after setting filepath (or if not set, autodiscover the file)

load_profile_properties(profile_name: str) dict

Load profile properties given profile_name including secure properties :returns: * dictionary – Object containing profile properties

  • Load exact profile properties (without prepopulated fields from base profile)

  • from the profile dict and populate fields from the secure credentials storage

save(update_secure_props=True)

Save the config file to disk. and secure props to vault parameters:

secure_props (bool): If True, the secure properties will be stored in the vault. Default is True.

Returns:

None

schema_list(cwd=None) list

Loads the schema properties in a sorted order according to the priority

Returns:

Returns the profile properties from schema (prop: value)

Return type:

Dictionary

set_profile(profile_path: str, profile_data: dict) None

Set a profile in the config file.

Parameters:

profile_path (str): The path of the profile to be set. eg: profiles.zosmf profile_data (dict): The data to be set for the profile.

set_property(json_path, value, secure=None) None

Set a property in the profile, storing it securely if necessary.

Parameters:

json_path (str): The JSON path of the property to set. value (str): The value to be set for the property. profile_name (str): The name of the profile to set the property in. secure (bool): If True, the property will be stored securely. Default is None.

validate_schema() None

Get the $schema_property from the config and load the schema

Return type:

file_path to the $schema property