Class: Aliyun::Odps::Functions
- Inherits:
-
ServiceObject
- Object
- ServiceObject
- Aliyun::Odps::Functions
- Defined in:
- lib/aliyun/odps/model/functions.rb
Overview
Methods for Functions
Instance Attribute Summary
Attributes inherited from ServiceObject
Instance Method Summary collapse
-
#create(name, class_path, resources = []) ⇒ Function
Register function in project.
-
#delete(name) ⇒ true
Delete function in project.
-
#get(name) ⇒ Function
(also: #function)
Get Function.
-
#list(options = {}) ⇒ List
List Functions of project.
-
#update(name, class_path, resources = []) ⇒ true
Update function in project.
Methods inherited from ServiceObject
build, #client, #initialize, #project, service_pool
Constructor Details
This class inherits a constructor from Aliyun::Odps::ServiceObject
Instance Method Details
#create(name, class_path, resources = []) ⇒ Function
Register function in project
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/aliyun/odps/model/functions.rb', line 49 def create(name, class_path, resources = []) path = "/projects/#{project.name}/registration/functions" function = Function.new( name: name, class_type: class_path, resources: resources ) resp = client.post(path, body: build_create_body(function)) function.tap do |obj| obj.location = resp.headers['Location'] end end |
#delete(name) ⇒ true
Delete function in project
92 93 94 95 |
# File 'lib/aliyun/odps/model/functions.rb', line 92 def delete(name) path = "/projects/#{project.name}/registration/functions/#{name}" !!client.delete(path) end |
#get(name) ⇒ Function Also known as: function
Get Function
32 33 34 35 36 37 |
# File 'lib/aliyun/odps/model/functions.rb', line 32 def get(name) path = "/projects/#{project.name}/registration/functions/#{name}" result = client.get(path).parsed_response Function.new(Utils.dig_value(result, 'Function')) end |
#list(options = {}) ⇒ List
List Functions of project
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/aliyun/odps/model/functions.rb', line 16 def list( = {}) Utils.stringify_keys!() path = "/projects/#{project.name}/registration/functions" query = Utils.hash_slice(, 'name', 'owner', 'marker', 'maxitems') result = client.get(path, query: query).parsed_response Aliyun::Odps::List.build(result, %w(Functions Function)) do |hash| Function.new(hash) end end |
#update(name, class_path, resources = []) ⇒ true
Update function in project
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/aliyun/odps/model/functions.rb', line 74 def update(name, class_path, resources = []) path = "/projects/#{project.name}/registration/functions/#{name}" function = Function.new( name: name, class_type: class_path, resources: resources ) !!client.put(path, body: build_create_body(function)) end |