Class: EY::CloudClient::AppEnvironment

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, attrs) ⇒ AppEnvironment

Returns a new instance of AppEnvironment.

Raises:

  • (ArgumentError)


26
27
28
29
30
31
# File 'lib/engineyard-cloud-client/models/app_environment.rb', line 26

def initialize(api, attrs)
  super

  raise ArgumentError, 'AppEnvironment created without app!'         unless app
  raise ArgumentError, 'AppEnvironment created without environment!' unless environment
end

Class Method Details

.resolve(api, constraints) ⇒ Object

Return a constrained list of app_environments given a set of constraints like:

  • app_name: app name full or partial match string

  • account_name: account name full or partial match string

  • environment_name: environment name full or partial match string

  • remotes: An array of git remote URIs



18
19
20
21
22
23
24
# File 'lib/engineyard-cloud-client/models/app_environment.rb', line 18

def self.resolve(api, constraints)
  clean_constraints = constraints.reject { |k,v| v.nil? }
  params = {'constraints' => clean_constraints}
  response = api.get("/app_environments/resolve", params)['resolver']
  matches = from_array(api, response['matches'])
  ResolverResult.new(api, matches, response['errors'], response['suggestions'])
end

Instance Method Details

#account_nameObject



41
42
43
# File 'lib/engineyard-cloud-client/models/app_environment.rb', line 41

def 
  app.
end

#app_nameObject



45
46
47
# File 'lib/engineyard-cloud-client/models/app_environment.rb', line 45

def app_name
  app.name
end

#attributes=(attrs) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/engineyard-cloud-client/models/app_environment.rb', line 33

def attributes=(attrs)
  app_attrs         = attrs.delete('app')
  environment_attrs = attrs.delete('environment')
  super
  set_app         app_attrs         if app_attrs
  set_environment environment_attrs if environment_attrs
end

#deploy(attrs) ⇒ Object

Trigger a deployment on the api side.

This is like hitting the deploy button on the web interface.

Returns a started deployment that will run from EY Cloud automatically. Load the deployment again to see when it finishes. This action returns immediately before the deployment is complete.



81
82
83
# File 'lib/engineyard-cloud-client/models/app_environment.rb', line 81

def deploy(attrs)
  Deployment.deploy(api, self, attrs)
end

#environment_nameObject



49
50
51
# File 'lib/engineyard-cloud-client/models/app_environment.rb', line 49

def environment_name
  environment.name
end

#hierarchy_nameObject



57
58
59
# File 'lib/engineyard-cloud-client/models/app_environment.rb', line 57

def hierarchy_name
  [, app_name, environment_name].join(' / ')
end

#last_deploymentObject



61
62
63
# File 'lib/engineyard-cloud-client/models/app_environment.rb', line 61

def last_deployment
  Deployment.last(api, self)
end

#new_deployment(attrs) ⇒ Object

Create a new, unsaved, Deployment record.

Call start on the return object to indicate to EY Cloud that you will be starting a deployment using your own connection to your servers. This is the way that the engineyard gem does deployments.



70
71
72
# File 'lib/engineyard-cloud-client/models/app_environment.rb', line 70

def new_deployment(attrs)
  Deployment.from_hash(api, attrs.merge(:app_environment => self))
end

#repository_uriObject



53
54
55
# File 'lib/engineyard-cloud-client/models/app_environment.rb', line 53

def repository_uri
  app.repository_uri
end

#sort_attributesObject



85
86
87
# File 'lib/engineyard-cloud-client/models/app_environment.rb', line 85

def sort_attributes
  [sort_string(), sort_string(app_name), sort_string(environment_name)]
end