Sha256: 9e4bee6c218c1b13907300cc673c51be40d4395682211ef3fd89c016cfe3b3d9

Contents?: true

Size: 745 Bytes

Versions: 4

Compression:

Stored size: 745 Bytes

Contents

require 'json'
require 'kinu/resource_base'

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

    def self.attach(name, id, sandbox_id)
      response = Kinu::HttpClient.post(
        '/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

4 entries across 4 versions & 1 rubygems

Version Path
kinu-1.0.0.alpha4 lib/kinu/sandbox.rb
kinu-1.0.0.alpha3 lib/kinu/sandbox.rb
kinu-1.0.0.alpha2 lib/kinu/sandbox.rb
kinu-1.0.0.alpha1 lib/kinu/sandbox.rb