class Qubell::Application

Qubell application class

Attributes

organization[R]

Public Class Methods

new(args) click to toggle source
Calls superclass method
# File lib/qubell/application.rb, line 17
def initialize(args)
  super
  @organization = args[:organization]
end

Public Instance Methods

instances() click to toggle source

Get list of all instances for given application. @return [Array<Qubell::Instance>] revisions info

# File lib/qubell/application.rb, line 32
def instances
  # Qubell public API is too enterprise for just getting list of instances
  # by application ID. Actually there is no method for this yet.
  # So, store ID of organization in Application class and to get a list of
  # instances we init new organization class, get all environments in this
  # organization, get all instances in this environment and finally
  # filter them by application.
  # Like in one russian fairytail: "his death is at the end of the needle,
  # that needle is in the egg, then egg is in a duck, that duck is in a
  # hare, the hare is in the trunk, and the trunk stands on a high oak"
  Qubell::Organization.new(id: @organization).environments
                      .map(&:instances).flatten.select do |instance|
    instance.instance_of_app?(self)
  end
end
launch(args) click to toggle source

Launch new instance of given application. @param [Hash<String => String>] args map of configuration parameters @return [Qubell::Instance] revisions info

# File lib/qubell/application.rb, line 62
def launch(args)
  id = Qubell::APICall.put("/applications/#{@id}/launch",
                           args.to_json,
                           content_type: 'application/json')[:id]
  instances.select { |instance| instance.id == id }.first
rescue Qubell::ExecutionError
  raise Qubell::FormatError, 'currect manifest is incorrect'
end
revisions() click to toggle source

Get list of all revisions for given application. @return [Array<Qubell::Revision>] revisions info

# File lib/qubell/application.rb, line 24
def revisions
  Qubell::APICall.get("/applications/#{@id}/revisions").map do |rev|
    Qubell::Revision.new(rev)
  end
end
update(content) click to toggle source

Get the application instance status. @param [String] content new manifest content @return [String] instances status info

# File lib/qubell/application.rb, line 51
def update(content)
  Qubell::APICall.put("/applications/#{@id}/manifest",
                      content,
                      content_type: 'application/x-yaml')[:version]
rescue Qubell::ExecutionError
  raise Qubell::FormatError, 'currect manifest is incorrect'
end