Class: Ridley::SandboxResource
- Inherits:
-
Resource
show all
- Defined in:
- lib/ridley/resources/sandbox_resource.rb
Instance Method Summary
collapse
Methods inherited from Resource
#connection, #new, representation, represented_by, resource_path, set_resource_path
Constructor Details
#initialize(connection_registry, client_name, client_key, options = {}) ⇒ SandboxResource
Returns a new instance of SandboxResource.
8
9
10
11
12
|
# File 'lib/ridley/resources/sandbox_resource.rb', line 8
def initialize(connection_registry, client_name, client_key, options = {})
super(connection_registry)
options = options.reverse_merge(pool_size: 4)
@uploader = SandboxUploader.pool(size: options[:pool_size], args: [ client_name, client_key, options ])
end
|
Instance Method Details
#all(*args) ⇒ Object
80
81
82
|
# File 'lib/ridley/resources/sandbox_resource.rb', line 80
def all(*args)
abort RuntimeError.new("action not supported")
end
|
Create a new Sandbox on the client’s Chef Server. A Sandbox requires an array of file checksums which lets the Chef Server know what the signature of the contents to be uploaded will look like.
30
31
32
33
34
35
|
# File 'lib/ridley/resources/sandbox_resource.rb', line 30
def create(checksums = [])
sumhash = { checksums: Hash.new }.tap do |chks|
Array(checksums).each { |chk| chks[:checksums][chk] = nil }
end
new(request(:post, self.class.resource_path, JSON.fast_generate(sumhash)))
end
|
#delete(*args) ⇒ Object
88
89
90
|
# File 'lib/ridley/resources/sandbox_resource.rb', line 88
def delete(*args)
abort RuntimeError.new("action not supported")
end
|
#delete_all(*args) ⇒ Object
92
93
94
|
# File 'lib/ridley/resources/sandbox_resource.rb', line 92
def delete_all(*args)
abort RuntimeError.new("action not supported")
end
|
#find(*args) ⇒ Object
84
85
86
|
# File 'lib/ridley/resources/sandbox_resource.rb', line 84
def find(*args)
abort RuntimeError.new("action not supported")
end
|
#update(*args) ⇒ Object
76
77
78
|
# File 'lib/ridley/resources/sandbox_resource.rb', line 76
def update(*args)
abort RuntimeError.new("action not supported")
end
|
#upload(object, checksums) ⇒ Array<Hash>
Concurrently upload all of the files in the given sandbox
70
71
72
73
74
|
# File 'lib/ridley/resources/sandbox_resource.rb', line 70
def upload(object, checksums)
checksums.collect do |chk_id, path|
uploader.future(:upload, object, chk_id, path)
end.map(&:value)
end
|