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.



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

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

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



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

def api
  @api
end

#environmentObject (readonly)

Returns the value of attribute environment.



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

def environment
  @environment
end

Instance Method Details

#downloadObject



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

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

#runObject



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

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’))



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

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

#upload_path(recipes_path) ⇒ Object



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

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