Ejemplo n.º 1
0
        public VcapClientResult Update(string name, DirectoryInfo path)
        {
            checkLoginStatus();
            var hlpr = new AppsHelper(credMgr);

            return(hlpr.Update(name, path));
        }
Ejemplo n.º 2
0
        public void Stop(Application app)
        {
            checkLoginStatus();
            var hlpr = new AppsHelper(credMgr);

            hlpr.Stop(app);
        }
Ejemplo n.º 3
0
        public void Delete(string name)
        {
            checkLoginStatus();
            var hlpr = new AppsHelper(credMgr);

            hlpr.Delete(name);
        }
Ejemplo n.º 4
0
        public byte[] FilesSimple(string appName, string path, ushort instance)
        {
            checkLoginStatus();
            var hlpr = new AppsHelper(credMgr);

            return(hlpr.Files(appName, path, instance));
        }
Ejemplo n.º 5
0
        public VcapResponse UpdateApplication(Application app)
        {
            checkLoginStatus();
            var hlpr = new AppsHelper(credMgr);

            return(hlpr.UpdateApplication(app));
        }
Ejemplo n.º 6
0
        public void Restart(Application app)
        {
            checkLoginStatus();
            var hlpr = new AppsHelper(credMgr);

            hlpr.Restart(app);
        }
Ejemplo n.º 7
0
        public IEnumerable <Crash> GetAppCrash(Application app)
        {
            checkLoginStatus();
            var hlpr = new AppsHelper(credMgr);

            return(hlpr.GetAppCrash(app));
        }
Ejemplo n.º 8
0
        public Application GetApplication(string name)
        {
            checkLoginStatus();
            var         hlpr = new AppsHelper(credMgr);
            Application rv   = hlpr.GetApplication(name);

            rv.Parent = cloud; // TODO not thrilled about this
            return(rv);
        }
Ejemplo n.º 9
0
        public VcapClientResult Push(
            string name, string deployFQDN, ushort instances,
            DirectoryInfo path, uint memoryMB, string[] provisionedServiceNames)
        {
            checkLoginStatus();
            var hlpr = new AppsHelper(credMgr);

            return(hlpr.Push(name, deployFQDN, instances, path, memoryMB,
                             provisionedServiceNames, "aspdotnet", "aspdotnet40"));
        }
Ejemplo n.º 10
0
        public IEnumerable <Application> GetApplications()
        {
            checkLoginStatus();
            var hlpr = new AppsHelper(credMgr);
            IEnumerable <Application> apps = hlpr.GetApplications();

            foreach (var a in apps)
            {
                a.Parent = cloud;
            }                                             // TODO not thrilled about this
            return(apps);
        }
Ejemplo n.º 11
0
        public VcapClientResult DeleteUser(string email)
        {
            var appsHelper = new AppsHelper(credMgr);
            foreach (Application a in appsHelper.GetApplications(email))
            {
                appsHelper.Delete(a.Name);
            }

            var servicesHelper = new ServicesHelper(credMgr);
            foreach (ProvisionedService ps in servicesHelper.GetProvisionedServices(email))
            {
                servicesHelper.DeleteService(ps.Name);
            }

            var r = new VcapJsonRequest(credMgr, Method.DELETE, Constants.USERS_PATH, email);
            RestResponse response = r.Execute();
            return new VcapClientResult();
        }
Ejemplo n.º 12
0
        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();
        }
Ejemplo n.º 13
0
        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());
        }
Ejemplo n.º 14
0
        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());
        }
Ejemplo n.º 15
0
        public VcapClientResult DeleteUser(string email)
        {
            var appsHelper = new AppsHelper(credMgr);

            foreach (Application a in appsHelper.GetApplications(email))
            {
                appsHelper.Delete(a.Name);
            }

            var servicesHelper = new ServicesHelper(credMgr);

            foreach (ProvisionedService ps in servicesHelper.GetProvisionedServices(email))
            {
                servicesHelper.DeleteService(ps.Name);
            }

            var          r        = new VcapJsonRequest(credMgr, Method.DELETE, Constants.USERS_PATH, email);
            RestResponse response = r.Execute();

            return(new VcapClientResult());
        }
Ejemplo n.º 16
0
        public VcapFilesResult Files(string appName, string path, ushort instance)
        {
            checkLoginStatus();

            VcapFilesResult rv;

            var hlpr = new AppsHelper(credMgr);
            byte[] content = hlpr.Files(appName, path, instance);
            if (null == content)
            {
                rv = new VcapFilesResult(false);
            }
            else if (content.Length == 0)
            {
                rv = new VcapFilesResult(content);
            }
            else
            {
                int i = 0;
                for (i = 0; i < content.Length; ++i)
                {
                    if (content[i] == '\n')
                    {
                        break;
                    }
                }
                string firstLine = Encoding.ASCII.GetString(content, 0, i);
                if (file_re.IsMatch(firstLine) || dir_re.IsMatch(firstLine))
                {
                    // Probably looking at a listing, not a file
                    string contentAscii = Encoding.ASCII.GetString(content);
                    string[] contentAry = contentAscii.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    rv = new VcapFilesResult();
                    foreach (string item in contentAry)
                    {
                        Match fileMatch = file_re.Match(item);
                        if (null != fileMatch && fileMatch.Success)
                        {
                            string fileName = fileMatch.Groups[1].Value; // NB: 0 is the entire matched string
                            string fileSize = fileMatch.Groups[2].Value;
                            rv.AddFile(fileName, fileSize);
                            continue;
                        }

                        Match dirMatch = dir_re.Match(item);
                        if (null != dirMatch && dirMatch.Success)
                        {
                            string dirName = dirMatch.Groups[1].Value;
                            rv.AddDirectory(dirName);
                            continue;
                        }

                        throw new InvalidOperationException("Match failed.");
                    }
                }
                else
                {
                    rv = new VcapFilesResult(content);
                }
            }

            return rv;
        }
Ejemplo n.º 17
0
 public IEnumerable<Crash> GetAppCrash(Application app)
 {
     checkLoginStatus();
     var hlpr = new AppsHelper(credMgr);
     return hlpr.GetAppCrash(app);
 }
Ejemplo n.º 18
0
 public Application GetApplication(string name)
 {
     checkLoginStatus();
     var hlpr = new AppsHelper(credMgr);
     Application rv =  hlpr.GetApplication(name);
     rv.Parent = cloud; // TODO not thrilled about this
     return rv;
 }
Ejemplo n.º 19
0
        public VcapFilesResult Files(string appName, string path, ushort instance)
        {
            checkLoginStatus();

            VcapFilesResult rv;

            var hlpr = new AppsHelper(credMgr);

            byte[] content = hlpr.Files(appName, path, instance);
            if (null == content)
            {
                rv = new VcapFilesResult(false);
            }
            else if (content.Length == 0)
            {
                rv = new VcapFilesResult(content);
            }
            else
            {
                int i = 0;
                for (i = 0; i < content.Length; ++i)
                {
                    if (content[i] == '\n')
                    {
                        break;
                    }
                }
                string firstLine = Encoding.ASCII.GetString(content, 0, i);
                if (file_re.IsMatch(firstLine) || dir_re.IsMatch(firstLine))
                {
                    // Probably looking at a listing, not a file
                    string   contentAscii = Encoding.ASCII.GetString(content);
                    string[] contentAry   = contentAscii.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                    rv = new VcapFilesResult();
                    foreach (string item in contentAry)
                    {
                        Match fileMatch = file_re.Match(item);
                        if (null != fileMatch && fileMatch.Success)
                        {
                            string fileName = fileMatch.Groups[1].Value; // NB: 0 is the entire matched string
                            string fileSize = fileMatch.Groups[2].Value;
                            rv.AddFile(fileName, fileSize);
                            continue;
                        }

                        Match dirMatch = dir_re.Match(item);
                        if (null != dirMatch && dirMatch.Success)
                        {
                            string dirName = dirMatch.Groups[1].Value;
                            rv.AddDirectory(dirName);
                            continue;
                        }

                        throw new InvalidOperationException("Match failed.");
                    }
                }
                else
                {
                    rv = new VcapFilesResult(content);
                }
            }

            return(rv);
        }
Ejemplo n.º 20
0
 public IEnumerable<Application> GetApplications()
 {
     checkLoginStatus();
     var hlpr = new AppsHelper(credMgr);
     IEnumerable<Application> apps = hlpr.GetApplications();
     foreach (var a in apps) { a.Parent = cloud; } // TODO not thrilled about this
     return apps;
 }
Ejemplo n.º 21
0
 public VcapClientResult Push(
     string name, string deployFQDN, ushort instances,
     DirectoryInfo path, uint memoryMB, string[] provisionedServiceNames)
 {
     checkLoginStatus();
     var hlpr = new AppsHelper(credMgr);
     return hlpr.Push(name, deployFQDN, instances, path, memoryMB,
         provisionedServiceNames, "aspdotnet", "aspdotnet40");
 }
Ejemplo n.º 22
0
 public void Restart(Application app)
 {
     checkLoginStatus();
     var hlpr = new AppsHelper(credMgr);
     hlpr.Restart(app);
 }
Ejemplo n.º 23
0
 public void Stop(Application app)
 {
     checkLoginStatus();
     var hlpr = new AppsHelper(credMgr);
     hlpr.Stop(app);
 }
Ejemplo n.º 24
0
 public VcapClientResult Update(string name, DirectoryInfo path)
 {
     checkLoginStatus();
     var hlpr = new AppsHelper(credMgr);
     return hlpr.Update(name, path);
 }
Ejemplo n.º 25
0
 public VcapResponse UpdateApplication(Application app)
 {
     checkLoginStatus();
     var hlpr = new AppsHelper(credMgr);
     return hlpr.UpdateApplication(app);
 }
Ejemplo n.º 26
0
 public void Delete(string name)
 {
     checkLoginStatus();
     var hlpr = new AppsHelper(credMgr);
     hlpr.Delete(name);
 }
Ejemplo n.º 27
0
        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();
        }
Ejemplo n.º 28
0
 public byte[] FilesSimple(string appName, string path, ushort instance)
 {
     checkLoginStatus();
     var hlpr = new AppsHelper(credMgr);
     return hlpr.Files(appName, path, instance);
 }