lib/vmc/client.rb in af-0.3.18.4 vs lib/vmc/client.rb in af-0.3.18.5

- old
+ new

@@ -157,15 +157,25 @@ url = path(VMC::APPS_PATH, name, "instances", instance, "files", path) _, body, headers = http_get(url) body end + def app_download(name,path) + check_login_status + url = path(VMC::APPS_PATH, name, "application") + status, body, headers = http_get(url,'application/octet-stream') + file = File.new(path,"wb") + file.write(body) + file.close + end + def app_pull(name, dir) check_login_status url = path(VMC::APPS_PATH, name, "application") status, body, headers = http_get(url,'application/octet-stream') file = Tempfile.new(name) + file.binmode file.write(body) file.close ::VMC::Cli::ZipUtil.unpack(file.path, dir) file.unlink end @@ -235,10 +245,18 @@ services = app[:services] || [] services.delete(service) app[:services] = services update_app(appname, app) end + + def export_service(service) + json_get(path(VMC::SERVICE_EXPORT_PATH, service)) + end + + def import_service(service,uri) + json_post(path(VMC::SERVICE_IMPORT_PATH, service),{uri:uri}) + end ###################################################### # Resources ###################################################### @@ -358,12 +376,17 @@ !infras.empty? end def base_for_infra(name) info = infras.detect { |i| i[:infra] == name } - info ? info[:base] : "aws.af.cm" + info ? info[:base] : default_base end + def default_base + return "vcap.me" if @target =~ /https?:\/\/api.vcap.me/ + "aws.af.cm" + end + def infra_valid?(name) infras.detect { |i| i[:infra] == name } end def infra_descriptions