MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / load

Method load

keepercommander/commands/pam_import/base.py:1006–1042  ·  view source on GitHub ↗
(cls, data: Union[str, dict], rotation_params: Optional[PamRotationParams] = None)

Source from the content-addressed store, hash-verified

1004
1005 @classmethod
1006 def load(cls, data: Union[str, dict], rotation_params: Optional[PamRotationParams] = None):
1007 obj = cls()
1008 try: data = json.loads(data) if isinstance(data, str) else data
1009 except: logging.error(f"PAM User failed to load from: {str(data)[:80]}")
1010 if not isinstance(data, dict): return obj
1011
1012 dtype = str(data["type"]) if "type" in data else "pamUser"
1013 if dtype and dtype.lower() != "pamUser".lower():
1014 logging.warning(f"""PAM User data using wrong type "pamUser" != "{dtype[:80]}" """)
1015
1016 obj.type = "pamUser"
1017 obj.title = str(data["title"]) if "title" in data else None
1018 obj.notes = str(data["notes"]) if "notes" in data else None
1019
1020 obj.login = str(data["login"]) if "login" in data else None
1021 obj.password = str(data["password"]) if "password" in data else None
1022 obj.privatePEMKey = str(data["private_pem_key"]) if "private_pem_key" in data else None
1023 obj.distinguishedName = str(data["distinguished_name"]) if "distinguished_name" in data else None
1024 obj.connectDatabase = str(data["connect_database"]) if "connect_database" in data else None
1025 obj.managed = utils.value_to_boolean(data["managed"]) if "managed" in data else None
1026 obj.oneTimeCode = str(data["otp"]) if "otp" in data else None
1027
1028 obj.attachments = PamAttachmentsObject.load(data.get("attachments", None))
1029 obj.scripts = PamScriptsObject.load(data.get("scripts", None))
1030 rso = PamRotationSettingsObject.load(data.get("rotation_settings", None), rotation_params)
1031 if not is_blank_instance(rso):
1032 obj.rotation_settings = rso
1033
1034 obj.folder_path = str(data["folder_path"]) if "folder_path" in data else None
1035 obj.uid_imported = str(data["uid"]) if "uid" in data else None
1036
1037 if (obj.title is None or not obj.title.strip()) and obj.login and obj.login.strip():
1038 obj.title = f"PAM User - {str(obj.login).strip()}"
1039
1040 obj.validate_record()
1041
1042 return obj
1043
1044 def create_record(self, params, folder_uid):
1045 args = {

Callers 15

find_recordFunction · 0.45
_build_folder_jsonMethod · 0.45
executeMethod · 0.45
include_dagMethod · 0.45
display_rotation_infoMethod · 0.45
executeMethod · 0.45
executeMethod · 0.45
executeMethod · 0.45
executeMethod · 0.45
executeMethod · 0.45
on_folder_fnMethod · 0.45
executeMethod · 0.45

Calls 5

is_blank_instanceFunction · 0.85
warningMethod · 0.80
getMethod · 0.80
errorMethod · 0.45
validate_recordMethod · 0.45

Tested by

no test coverage detected