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
35 36 37 38 39 40 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 35 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
43 44 45 46 47 48 49 50 51 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 43 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
85 86 87 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 85 def export_service(service_name) @base.get("services", "export", service_name, :accept => :json, :retry => false) end |
#import_service(service_name, uri) ⇒ Object
89 90 91 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 89 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 30 31 32 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 27 def infra_by_name(name) if name == "none" return Infra.new("none", "none", "No infra selected", "no-infra.af.cm", "none", "none") end infras.find { |i| i.name == name } unless name.nil? 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.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/appfog-vmc-plugin/cfoundry/v1/client.rb', line 54 def services( = {}) services = [] service_instances = @base.system_services if [:infras] != true service_instances = { none: service_instances } end service_instances.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 |