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

Method load

keepercommander/commands/pam_import/base.py:379–400  ·  view source on GitHub ↗
(cls, data: Union[str, dict])

Source from the content-addressed store, hash-verified

377
378 @classmethod
379 def load(cls, data: Union[str, dict]) -> PamScriptObject:
380 obj = cls()
381 try: data = json.loads(data) if isinstance(data, str) else data
382 except: logging.error(f"PAM script failed to load from: {str(data)[:80]}")
383 if not isinstance(data, dict): return obj
384
385 # TUI: "script": { "script_command": "pwsh.exe", "file": "path/file.ext", "additional_credentials": ["admin1", "user2"] },
386 # JSON: "script": [{"command":"", "fileRef":"path/file.ext", "recordRef": ["uid1", "uid2"]}]
387 # use file upload to attach to existing record and get UIDs
388 cmd = data.get("script_command", None)
389 if isinstance(cmd, str) and cmd.strip() != "": obj.script_command = cmd.strip()
390 file = data.get("file", None)
391 if isinstance(file, str) and file.strip() != "": obj.file = file.strip()
392 # before use call validate() which also checks if file exists
393
394 # NB! If script has additional_credentials these must be added later,
395 # after pamUser creation
396 acs = data.get("additional_credentials", None)
397 if isinstance(acs, str): acs = [acs]
398 if isinstance(acs, list) and acs: obj.additional_credentials = acs
399
400 return obj
401
402 # def to_json(self): pass # File upload will create the JSON format
403

Callers

nothing calls this directly

Calls 2

errorMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected