Class: EY::CloudClient::App

Inherits:
Object
  • Object
show all
Defined in:
lib/engineyard-cloud-client/models/app.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



8
9
10
# File 'lib/engineyard-cloud-client/models/app.rb', line 8

def 
  @account
end

#app_environmentsObject (readonly)

Returns the value of attribute app_environments.



8
9
10
# File 'lib/engineyard-cloud-client/models/app.rb', line 8

def app_environments
  @app_environments
end

Class Method Details

.all(api) ⇒ Object

Return list of all Apps linked to all current user’s accounts



11
12
13
# File 'lib/engineyard-cloud-client/models/app.rb', line 11

def self.all(api)
  self.from_array(api, api.get("/apps", 'no_instances' => 'true')["apps"])
end

.create(api, attrs = {}) ⇒ Object

An everything-you-need helper to create an App If successful, returns new App If unsuccessful, raises EY::CloudClient::RequestFailed

Usage App.create(api,

account:        account         # requires: account.id
name:           "myapp",
repository_uri: "[email protected]:mycompany/myapp.git",
app_type_id:    "rails3",

)

NOTE: Syntax above is for Ruby 1.9. In Ruby 1.8, keys must all be strings.



28
29
30
31
32
33
34
35
36
37
# File 'lib/engineyard-cloud-client/models/app.rb', line 28

def self.create(api, attrs = {})
   = attrs.delete("account")
  params = attrs.dup # no default fields
  raise EY::CloudClient::AttributeRequiredError.new("account", EY::CloudClient::Account) unless 
  raise EY::CloudClient::AttributeRequiredError.new("name") unless params["name"]
  raise EY::CloudClient::AttributeRequiredError.new("repository_uri") unless params["repository_uri"]
  raise EY::CloudClient::AttributeRequiredError.new("app_type_id") unless params["app_type_id"]
  response = api.post("/accounts/#{.id}/apps", "app" => params)
  from_hash(api, response['app'])
end

Instance Method Details

#account_nameObject



39
40
41
# File 'lib/engineyard-cloud-client/models/app.rb', line 39

def 
   && .name
end

#add_app_environment(app_env) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/engineyard-cloud-client/models/app.rb', line 47

def add_app_environment(app_env)
  @app_environments ||= []
  existing_app_env = @app_environments.detect { |ae| app_env.environment == ae.environment }
  unless existing_app_env
    @app_environments << app_env
  end
  existing_app_env || app_env
end

#attributes=(attrs) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/engineyard-cloud-client/models/app.rb', line 56

def attributes=(attrs)
        = attrs.delete('account')
  environments_attrs = attrs.delete('environments')
  super
              if 
  set_environments environments_attrs if environments_attrs
end

#environmentsObject



43
44
45
# File 'lib/engineyard-cloud-client/models/app.rb', line 43

def environments
  (app_environments || []).map { |app_env| app_env.environment }
end