Class: CFoundry::V1::Client
- Inherits:
-
Object
- Object
- CFoundry::V1::Client
- Defined in:
- lib/appfog-vmc-plugin/cfoundry/v1/client.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
Instance Method Summary collapse
-
#app_download(name, path) ⇒ Object
Added to support downloads.
-
#app_pull(name, dir) ⇒ Object
Added to support app pulls.
- #export_service(service_name) ⇒ Object
- #import_service(service_name, uri) ⇒ Object
-
#info_infras ⇒ Object
Retrieve available infras.
- #infra(name) ⇒ Object
- #infra_by_name(name) ⇒ Object
- #infras(options = {}) ⇒ Object
-
#services(options = {}) ⇒ Object
Retrieve available services.
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
3 4 5 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 3 def base @base end |
Instance Method Details
#app_download(name, path) ⇒ Object
Added to support downloads
32 33 34 35 36 37 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 32 def app_download(name, path) body = @base.get("apps", name, "application") file = File.new(path, "wb") file.write(body) file.close end |
#app_pull(name, dir) ⇒ Object
Added to support app pulls
40 41 42 43 44 45 46 47 48 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 40 def app_pull(name, dir) body = @base.get("apps", name, "application") file = Tempfile.new(name) file.binmode file.write(body) file.close CFoundry::Zip.unpack(file.path, dir) file.unlink end |
#export_service(service_name) ⇒ Object
76 77 78 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 76 def export_service(service_name) @base.get("services", "export", service_name, :accept => :json, :retry => false) end |
#import_service(service_name, uri) ⇒ Object
80 81 82 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 80 def import_service(service_name, uri) @base.post("services", "import", service_name, :payload => {:uri => uri}, :multipart => true, :accept => '*/*; q=0.5, application/xml') end |
#info_infras ⇒ Object
Retrieve available infras.
6 7 8 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 6 def info_infras @base.get("info", "infras", :accept => :json) end |
#infra(name) ⇒ Object
23 24 25 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 23 def infra(name) infra_by_name(name) || Infra.new(name) end |
#infra_by_name(name) ⇒ Object
27 28 29 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 27 def infra_by_name(name) infras.find { |i| i.name == name } end |
#infras(options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 10 def infras( = {}) @ins = info_infras unless @ins # cache infras return unless @ins infras = [] @ins.each do |inf| infras << Infra.new(inf[:infra], inf[:name], inf[:description], inf[:base], inf[:locality], inf[:vendor]) end infras end |
#services(options = {}) ⇒ Object
Retrieve available services.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 51 def services( = {}) services = [] @base.system_services.each do |infra, infra_services| infra_services.each do |type, vendors| vendors.each do |vendor, providers| providers.each do |provider, properties| properties.each do |_, | [:supported_versions].each do |ver| state = [:version_aliases].find { |k, v| v == ver } services << Service.new(vendor.to_s, infra, ver.to_s, [:description], type.to_s, provider.to_s, state && state.first, [:plans], [:default_plan]) end end end end end end services end |