Class: Qubell::Instance

Inherits:
Base
  • Object
show all
Defined in:
lib/qubell/instance.rb

Overview

Implement Qubell application interface

Instance Attribute Summary collapse

Attributes inherited from Base

#id, #name

Instance Method Summary collapse

Methods inherited from Base

#==, #to_hash, #to_json, #to_s

Constructor Details

#initialize(args) ⇒ Instance

Returns a new instance of Instance.



13
14
15
16
17
# File 'lib/qubell/instance.rb', line 13

def initialize(args)
  super
  @environment = args[:environment]
  @revision = args[:revision]
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



10
11
12
# File 'lib/qubell/instance.rb', line 10

def environment
  @environment
end

#revisionObject (readonly)

Returns the value of attribute revision.



11
12
13
# File 'lib/qubell/instance.rb', line 11

def revision
  @revision
end

Instance Method Details

#destroy(force = false) ⇒ #void

Destroy an application

Parameters:

  • force (String) (defaults to: false)

    specifies whether the instance should be deleted

Returns:

  • (#void)


39
40
41
42
43
44
45
46
# File 'lib/qubell/instance.rb', line 39

def destroy(force = false)
  status = force ? '1' : '0'
  begin
    Qubell::APICall.delete("/instances/#{@id}?#{status}")
  rescue Qubell::ExecutionError
    raise Qubell::DestroyError
  end
end

#instance_of_app?(app) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/qubell/instance.rb', line 48

def instance_of_app?(app)
  global_info[:applicationId] == app.id
end

#launch_workflow(workflow, _args) ⇒ Hashes{String => String}

Runs the specified application instance workflow.

Parameters:

  • workflow (String)

    instance workflow name

  • workflow (Hash{String => String})

    instance workflow name

Returns:

  • (Hashes{String => String})

    instance id



23
24
25
# File 'lib/qubell/instance.rb', line 23

def launch_workflow(workflow, _args)
  Qubell::APICall.get("/instances/#{@id}/#{workflow}")
end

#userdata(data) ⇒ #void

Associates user data with the instance.

Parameters:

  • data (String)

    JSON-encoded user data

Returns:

  • (#void)


30
31
32
33
34
# File 'lib/qubell/instance.rb', line 30

def userdata(data)
  Qubell::APICall.put("/instances/#{@id}/userData", data)
rescue Qubell::ExecutionError
  raise Qubell::FormatError
end