def _get_invocation_payload(self): # Default payload payload = self.function.get('payload', {}) if not payload: # Check for defined run script if self.function.get("run_script", False): script_path = self.function.get("run_script") # We first code to base64 in bytes and then decode those bytes to allow the json lib to parse the data # https://stackoverflow.com/questions/37225035/serialize-in-json-a-base64-encoded-data#37239382 payload = {"script": StrUtils.bytes_to_base64str(FileUtils.read_file(script_path, 'rb'))} # Check for defined commands # This overrides any other function payload if self.function.get("c_args", False): payload = {"cmd_args": json.dumps(self.function.get("c_args"))} return json.dumps(payload)
def _get_invocation_payload(self): # Default payload payload = self.aws.lambdaf.payload if hasattr(self.aws.lambdaf, 'payload') else {} if not payload: # Check for defined run script if hasattr(self.aws.lambdaf, "run_script"): script_path = self.aws.lambdaf.run_script if hasattr(self.aws, "config_path"): script_path = FileUtils.join_paths(self.aws.config_path, script_path) # We first code to base64 in bytes and then decode those bytes to allow the json lib to parse the data # https://stackoverflow.com/questions/37225035/serialize-in-json-a-base64-encoded-data#37239382 payload = { "script" : StrUtils.bytes_to_base64str(FileUtils.read_file(script_path, 'rb')) } # Check for defined commands # This overrides any other function payload if hasattr(self.aws.lambdaf, "c_args"): payload = {"cmd_args" : json.dumps(self.aws.lambdaf.c_args)} return json.dumps(payload)