public void AddUser(string email, string password) { VcapJsonRequest r = BuildVcapJsonRequest(Method.POST, Constants.USERS_PATH); r.AddBody(new { email, password }); r.Execute(); }
public VcapResponse UpdateApplication(Application app) { var r = new VcapJsonRequest(credMgr, Method.PUT, Constants.APPS_PATH, app.Name); r.AddBody(app); return(r.Execute <VcapResponse>()); }
public VcapClientResult AddUser(string email, string password) { var r = new VcapJsonRequest(credMgr, Method.POST, Constants.USERS_PATH); r.AddBody(new { email = email, password = password }); RestResponse response = r.Execute(); return(new VcapClientResult()); }
public void ChangePassword(string user, string newPassword) { VcapRequest request = BuildVcapRequest(Constants.USERS_PATH, user); IRestResponse response = request.Execute(); JObject parsed = JObject.Parse(response.Content); parsed["password"] = newPassword; VcapJsonRequest put = BuildVcapJsonRequest(Method.PUT, Constants.USERS_PATH, user); put.AddBody(parsed); put.Execute(); }
private Resource[] checkResources(Resource[] resourceAry) { /* * Send in a resources manifest array to the system to have * it check what is needed to actually send. Returns array * indicating what is needed. This returned manifest should be * sent in with the upload if resources were removed. * E.g. [{:sha1 => xxx, :size => xxx, :fn => filename}] */ var r = new VcapJsonRequest(credMgr, Method.POST, Constants.RESOURCES_PATH); r.AddBody(resourceAry); RestResponse response = r.Execute(); return(JsonConvert.DeserializeObject <Resource[]>(response.Content)); }
public VcapClientResult ChangePassword(string user, string newpassword) { var r = new VcapRequest(credMgr, Constants.USERS_PATH, user); RestResponse response = r.Execute(); JObject parsed = JObject.Parse(response.Content); parsed["password"] = newpassword; var put = new VcapJsonRequest(credMgr, Method.PUT, Constants.USERS_PATH, user); put.AddBody(parsed); response = put.Execute(); return(new VcapClientResult()); }
public void Login(string email, string password) { VcapJsonRequest r = BuildVcapJsonRequest(Method.POST, Constants.USERS_PATH, email, "tokens"); r.AddBody(new { password }); try { IRestResponse response = r.Execute(); var parsed = JObject.Parse(response.Content); string token = parsed.Value <string>("token"); credMgr.RegisterToken(token); } catch (VcapAuthException) { throw new VcapAuthException(string.Format(Resources.Vmc_LoginFail_Fmt, credMgr.CurrentTarget)); } }
public VcapClientResult UnbindService(string argProvisionedServiceName, string argAppName) { var apps = new AppsHelper(credMgr); string appJson = apps.GetApplicationJson(argAppName); var appParsed = JObject.Parse(appJson); var services = (JArray)appParsed["services"]; appParsed["services"] = new JArray(services.Where(s => ((string)s) != argProvisionedServiceName)); var r = new VcapJsonRequest(credMgr, Method.PUT, Constants.APPS_PATH, argAppName); r.AddBody(appParsed); RestResponse response = r.Execute(); apps = new AppsHelper(credMgr); apps.Restart(argAppName); return(new VcapClientResult()); }
public VcapClientResult BindService(string argProvisionedServiceName, string argAppName) { var apps = new AppsHelper(credMgr); Application app = apps.GetApplication(argAppName); app.Services.Add(argProvisionedServiceName); var request = new VcapJsonRequest(credMgr, Method.PUT, Constants.APPS_PATH, app.Name); request.AddBody(app); RestResponse response = request.Execute(); // Ruby code re-gets info app = apps.GetApplication(argAppName); if (app.IsStarted) { apps.Restart(app); } return(new VcapClientResult()); }
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 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); }