Class: Aliyun::Odps::Resources
- Inherits:
-
ServiceObject
- Object
- ServiceObject
- Aliyun::Odps::Resources
- Defined in:
- lib/aliyun/odps/model/resources.rb
Overview
Methods for Resources
Instance Attribute Summary
Attributes inherited from ServiceObject
Instance Method Summary collapse
-
#create(name, type, options = {}) ⇒ Resource
Create resource in project.
-
#delete(name) ⇒ true
Delete resource in project.
-
#get(name) ⇒ Resource
(also: #resource)
Get resource of project.
-
#get_meta(name) ⇒ Resource
(also: #head)
Get resource information in project.
-
#list(options = {}) ⇒ List
List resources of project.
-
#update(name, type, options = {}) ⇒ true
Update resource 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, type, options = {}) ⇒ Resource
Create resource in project
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/aliyun/odps/model/resources.rb', line 67 def create(name, type, = {}) Utils.stringify_keys!() path = "/projects/#{project.name}/resources/" headers = build_create_base_headers(name, type, ) body = build_create_base_body() location = client.post(path, headers: headers, body: body).headers['Location'] Resource.new(name: name, resource_type: type, comment: ['comment'], location: location) end |
#delete(name) ⇒ true
Delete resource in project
107 108 109 110 111 |
# File 'lib/aliyun/odps/model/resources.rb', line 107 def delete(name) path = "/projects/#{project.name}/resources/#{name}" !!client.delete(path) end |
#get(name) ⇒ Resource Also known as: resource
Get resource of project
34 35 36 37 38 |
# File 'lib/aliyun/odps/model/resources.rb', line 34 def get(name) path = "/projects/#{project.name}/resources/#{name}" resp = client.get(path) build_resource(resp) end |
#get_meta(name) ⇒ Resource Also known as: head
Get resource information in project
48 49 50 51 52 |
# File 'lib/aliyun/odps/model/resources.rb', line 48 def (name) path = "/projects/#{project.name}/resources/#{name}" resp = client.head(path) build_resource(resp) end |
#list(options = {}) ⇒ List
List resources of project
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/aliyun/odps/model/resources.rb', line 16 def list( = {}) Utils.stringify_keys!() path = "/projects/#{project.name}/resources" query = Utils.hash_slice(, 'name', 'owner', 'marker', 'maxitems') result = client.get(path, query: query).parsed_response Aliyun::Odps::List.build(result, %w(Resources Resource)) do |hash| Resource.new(hash) end end |
#update(name, type, options = {}) ⇒ true
Update resource in project
90 91 92 93 94 95 96 97 98 |
# File 'lib/aliyun/odps/model/resources.rb', line 90 def update(name, type, = {}) Utils.stringify_keys!() path = "/projects/#{project.name}/resources/#{name}" headers = build_create_base_headers(name, type, ) body = build_create_base_body() !!client.put(path, headers: headers, body: body) end |