24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/jets/cli/call.rb', line 24
def invoke
params = {
function_name: function_name,
invocation_type: invocation_type, log_type: @log_type, payload: payload }
resp = nil
begin
resp = lambda_client.invoke(params)
@log_last_4kb = resp.log_result
rescue Aws::Lambda::Errors::ResourceNotFoundException
warn "ERROR: function #{function_name} not found".color(:red)
warn "Maybe check the spelling or the AWS_PROFILE?"
return resp
end
if !/^2/.match?(resp[:status_code].to_s)
warn "ERROR: Lambda function #{function_name} returned status code: #{resp[:status_code]}".color(:red)
warn resp
end
if verbose? && invocation_type != "Event"
log_last_4kb
end
if invocation_type == "Event"
resp
else
text = resp.payload.read data = JSON.parse(text)
ActiveSupport::HashWithIndifferentAccess.new(data)
end
end
|