Class: Kinu::Sandbox

Inherits:
ResourceBase show all
Defined in:
lib/kinu/sandbox.rb

Instance Attribute Summary

Attributes inherited from ResourceBase

#id, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ResourceBase

#path, #uri

Constructor Details

#initialize(id) ⇒ Sandbox

Returns a new instance of Sandbox.



30
31
32
# File 'lib/kinu/sandbox.rb', line 30

def initialize(id)
  super('__sandbox__', id)
end

Class Method Details

.attach(name, id, sandbox_id) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/kinu/sandbox.rb', line 17

def self.attach(name, id, sandbox_id)
  response = Kinu::HttpClient.post(
    Kinu.base_upload_uri,
    '/sandbox/attach',
    {
      name: name,
      id:   id,
      sandbox_id: sandbox_id,
    }
  )
  Resource.new(response['name'], response['id'])
end

.upload(file) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/kinu/sandbox.rb', line 6

def self.upload(file)
  response = Kinu::HttpClient.multipart_post(
    Kinu.base_upload_uri,
    '/sandbox',
    {
      image: Kinu::HttpClient::UploadFile.new(file),
    }
  )
  new(response['id'])
end

Instance Method Details

#attach_to(name, attach_id) ⇒ Object



34
35
36
# File 'lib/kinu/sandbox.rb', line 34

def attach_to(name, attach_id)
  self.class.attach(name, attach_id, self.id)
end