Class: EY::CloudClient::Recipes

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, environment) ⇒ Recipes

Returns a new instance of Recipes.



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

def initialize(api, environment)
  @api = api
  @environment = environment
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



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

def api
  @api
end

#environmentObject (readonly)

Returns the value of attribute environment.



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

def environment
  @environment
end

Instance Method Details

#downloadObject



20
21
22
23
24
25
26
27
# File 'lib/engineyard-cloud-client/models/recipes.rb', line 20

def download
  tmp = Tempfile.new("recipes")
  data = api.get("/environments/#{environment.id}/recipes")
  tmp.write(data)
  tmp.flush
  tmp.close
  tmp
end

#runObject



15
16
17
18
# File 'lib/engineyard-cloud-client/models/recipes.rb', line 15

def run
  api.put("/environments/#{environment.id}/run_custom_recipes")
  true
end

#upload(file_to_upload) ⇒ Object

Expects a File object opened for binary reading. i.e. upload(File.open(recipes_path, ‘rb’))



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

def upload(file_to_upload)
  api.post("/environments/#{environment.id}/recipes", :file => file_to_upload)
  true
end

#upload_path(recipes_path) ⇒ Object



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

def upload_path(recipes_path)
  recipes_path = Pathname.new(recipes_path)
  if recipes_path.exist?
    upload recipes_path.open('rb')
  else
    raise EY::CloudClient::Error, "Recipes file not found: #{recipes_path}"
  end
end