Class: Aliyun::Odps::Functions

Inherits:
ServiceObject show all
Defined in:
lib/aliyun/odps/model/functions.rb

Overview

Methods for Functions

Instance Attribute Summary

Attributes inherited from ServiceObject

#master

Instance Method Summary collapse

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

Parameters:

  • name (String)

    specify function name

  • class_path (String)

    specify class Path used by function

  • resources (Array<Model::Resource>) (defaults to: [])

    specify resources used by function

Returns:

See Also:



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

Parameters:

  • name (String)

    specify function name

Returns:

  • (true)

See Also:



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

Parameters:

  • name

    specify function name

Returns:



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

Parameters:

  • options (Hash) (defaults to: {})

    options

Options Hash (options):

  • :name (String)

    specify function name

  • :owner (String)

    specify function owner

  • :marker (String)
  • :maxitems (String) — default: 1000

Returns:

See Also:



16
17
18
19
20
21
22
23
24
25
# File 'lib/aliyun/odps/model/functions.rb', line 16

def list(options = {})
  Utils.stringify_keys!(options)
  path = "/projects/#{project.name}/registration/functions"
  query = Utils.hash_slice(options, '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

Parameters:

  • name (String)

    specify function name

  • class_path (String)

    specify class Path used by function

  • resources (Array<Model::Resource>) (defaults to: [])

    specify resources used by function

Returns:

  • (true)

See Also:



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