Class: FaaStRuby::Function

Inherits:
BaseObject show all
Defined in:
lib/faastruby/function.rb

Direct Known Subclasses

Local::CrystalFunction, Local::RubyFunction

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseObject

#assign_attributes, #attributes=, #call_api, #initialize, #mass_assign

Constructor Details

This class inherits a constructor from FaaStRuby::BaseObject

Instance Attribute Details

#contextObject

Returns the value of attribute context.



3
4
5
# File 'lib/faastruby/function.rb', line 3

def context
  @context
end

#created_atObject

Returns the value of attribute created_at.



3
4
5
# File 'lib/faastruby/function.rb', line 3

def created_at
  @created_at
end

#errorsObject

Returns the value of attribute errors.



3
4
5
# File 'lib/faastruby/function.rb', line 3

def errors
  @errors
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/faastruby/function.rb', line 3

def name
  @name
end

#updated_atObject

Returns the value of attribute updated_at.



3
4
5
# File 'lib/faastruby/function.rb', line 3

def updated_at
  @updated_at
end

#workspaceObject

Returns the value of attribute workspace.



3
4
5
# File 'lib/faastruby/function.rb', line 3

def workspace
  @workspace
end

Instance Method Details

#destroyObject



12
13
14
15
# File 'lib/faastruby/function.rb', line 12

def destroy
  response = @api.delete_from_workspace(function_name: self.name, workspace_name: @workspace.name)
  @errors += response.errors if response.errors.any?
end

#run(options) ⇒ Object



5
6
7
8
9
10
# File 'lib/faastruby/function.rb', line 5

def run(options)
  options['method'] ||= 'get'
  options['headers'] ||= {}
  response = @api.run(function_name: name, workspace_name: options['workspace_name'], payload: options['body'], method: options['method'], headers: options['headers'], time: options['time'], query: options['query'])
  response
end

#update(new_context:) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/faastruby/function.rb', line 17

def update(new_context:)
  payload = {'context' => new_context}
  response = @api.update_function_context(function_name: self.name, workspace_name: @workspace.name, payload: payload)
  @errors += response.errors if response.errors.any?
  unless @errors.any?
    self.context = response.body['context']
  end
  self
end