public VcapClientResult Login(string argEmail, string argPassword) { VcapClientResult rv; var r = new VcapJsonRequest(credMgr, Method.POST, Constants.USERS_PATH, argEmail, "tokens"); r.AddBody(new { password = argPassword }); RestResponse response = r.Execute(); if (response.Content.IsNullOrEmpty()) { rv = new VcapClientResult(false, Resources.Vmc_NoContentReturned_Text); } else { var parsed = JObject.Parse(response.Content); string token = parsed.Value <string>("token"); credMgr.RegisterToken(token); rv = new VcapClientResult(); } return(rv); }
public void DeleteUser(string email) { // TODO: doing this causes a "not logged in" failure when the user // doesn't exist, which is kind of misleading. var appsHelper = new AppsHelper(proxyUser, credMgr); foreach (Application a in appsHelper.GetApplications(email)) { appsHelper.Delete(a.Name); } var servicesHelper = new ServicesHelper(proxyUser, credMgr); foreach (ProvisionedService ps in servicesHelper.GetProvisionedServices()) { servicesHelper.DeleteService(ps.Name); } VcapJsonRequest r = BuildVcapJsonRequest(Method.DELETE, Constants.USERS_PATH, email); r.Execute(); }
public VcapClientResult CreateService(string argServiceName, string argProvisionedServiceName) { VcapClientResult rv; IEnumerable <SystemService> services = GetSystemServices(); if (services.IsNullOrEmpty()) { rv = new VcapClientResult(false); } else { SystemService svc = services.FirstOrDefault(s => s.Vendor == argServiceName); if (null == svc) { rv = new VcapClientResult(false); } else { // from vmc client.rb var data = new { name = argProvisionedServiceName, type = svc.Type, tier = "free", vendor = svc.Vendor, version = svc.Version, }; var r = new VcapJsonRequest(credMgr, Method.POST, Constants.SERVICES_PATH); r.AddBody(data); RestResponse response = r.Execute(); rv = new VcapClientResult(); } } return(rv); }
public VcapClientResult Push(string name, string deployFQDN, ushort instances, DirectoryInfo path, uint memoryMB, string[] provisionedServiceNames, string framework, string runtime) { VcapClientResult rv; if (path == null) { rv = new VcapClientResult(false, "Application local location is needed"); } else if (deployFQDN == null) { rv = new VcapClientResult(false, "Please specify the url to deploy as."); } else if (framework == null) { rv = new VcapClientResult(false, "Please specify application framework"); } else { if (AppExists(name)) { rv = new VcapClientResult(false, String.Format(Resources.AppsHelper_PushApplicationExists_Fmt, name)); } else { /* * Before creating the app, ensure we can build resource list */ var resources = new List <Resource>(); ulong totalSize = addDirectoryToResources(resources, path, path.FullName); var manifest = new AppManifest { Name = name, Staging = new Staging { Framework = framework, Runtime = runtime }, Uris = new string[] { deployFQDN }, Instances = instances, Resources = new AppResources { Memory = memoryMB }, }; var r = new VcapJsonRequest(credMgr, Method.POST, Constants.APPS_PATH); r.AddBody(manifest); RestResponse response = r.Execute(); uploadAppBits(name, path); Application app = GetApplication(name); app.Start(); r = new VcapJsonRequest(credMgr, Method.PUT, Constants.APPS_PATH, name); r.AddBody(app); response = r.Execute(); bool started = isStarted(app.Name); if (started && false == provisionedServiceNames.IsNullOrEmpty()) { foreach (string svcName in provisionedServiceNames) { var servicesHelper = new ServicesHelper(credMgr); servicesHelper.BindService(svcName, app.Name); } } rv = new VcapClientResult(started); } } return(rv); }
public void Delete(string name) { var r = new VcapJsonRequest(credMgr, Method.DELETE, Constants.APPS_PATH, name); r.Execute(); }
public IEnumerable <VcapUser> GetUsers() { VcapJsonRequest r = BuildVcapJsonRequest(Method.GET, Constants.USERS_PATH); return(r.Execute <VcapUser[]>()); }
public VcapUser GetUser(string email) { VcapJsonRequest r = BuildVcapJsonRequest(Method.GET, Constants.USERS_PATH, email); return(r.Execute <VcapUser>()); }