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

Method load

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

Source from the content-addressed store, hash-verified

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