Sha256: e4d210e52c5bb07f0aedc6d8f7146cf64825a5f340fd164e72363cad41cedf95

Contents?: true

Size: 805 Bytes

Versions: 6

Compression:

Stored size: 805 Bytes

Contents

require 'json'
require 'kinu/resource_base'

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

    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

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kinu-2.0.2 lib/kinu/sandbox.rb
kinu-2.0.1 lib/kinu/sandbox.rb
kinu-2.0.0 lib/kinu/sandbox.rb
kinu-1.0.0.alpha7 lib/kinu/sandbox.rb
kinu-1.0.0.alpha6 lib/kinu/sandbox.rb
kinu-1.0.0.alpha5 lib/kinu/sandbox.rb