2012-03-15 20:12:30 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class ElasticBeanstalk
|
|
|
|
|
|
|
|
class Application < Fog::Model
|
|
|
|
identity :name, :aliases => 'ApplicationName'
|
|
|
|
attribute :template_names, :aliases => 'ConfigurationTemplates'
|
|
|
|
attribute :created_at, :aliases => 'DateCreated'
|
|
|
|
attribute :updated_at, :aliases => 'DateUpdated'
|
|
|
|
attribute :description, :aliases => 'Description'
|
|
|
|
attribute :version_names, :aliases => 'Versions'
|
|
|
|
|
|
|
|
def initialize(attributes={})
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def environments
|
|
|
|
requires :name
|
2012-12-22 18:32:13 -05:00
|
|
|
service.environments.all({'ApplicationName' => name})
|
2012-03-16 15:39:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def events
|
|
|
|
requires :name
|
2012-12-22 18:32:13 -05:00
|
|
|
service.events.all({'ApplicationName' => name})
|
2012-03-15 20:12:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def templates
|
2012-03-16 15:39:30 -04:00
|
|
|
requires :name
|
2012-12-22 18:32:13 -05:00
|
|
|
service.templates.all({'ApplicationName' => name})
|
2012-03-16 15:39:30 -04:00
|
|
|
end
|
2012-03-15 20:12:30 -04:00
|
|
|
|
2012-03-16 15:39:30 -04:00
|
|
|
def versions
|
|
|
|
requires :name
|
2012-12-22 18:32:13 -05:00
|
|
|
service.versions.all({'ApplicationName' => name})
|
2012-03-15 20:12:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :name
|
2012-12-22 18:32:13 -05:00
|
|
|
service.delete_application(name)
|
2012-03-15 20:12:30 -04:00
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def save
|
|
|
|
requires :name
|
|
|
|
|
|
|
|
options = {
|
|
|
|
'ApplicationName' => name
|
|
|
|
}
|
|
|
|
options['Description'] = description unless description.nil?
|
|
|
|
|
2012-12-22 18:32:13 -05:00
|
|
|
data = service.create_application(options).body['CreateApplicationResult']['Application']
|
2012-03-15 20:12:30 -04:00
|
|
|
merge_attributes(data)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
2012-12-22 18:32:13 -05:00
|
|
|
end
|