Пример #1
0
        public byte[] Files(string name, string path, ushort instance)
        {
            var          r        = new VcapRequest(credMgr, Constants.APPS_PATH, name, "instances", instance, "files", path);
            RestResponse response = r.Execute();

            return(response.RawBytes);
        }
Пример #2
0
        public IEnumerable <ExternalInstance> GetInstances(Application argApp)
        {
            var r         = new VcapRequest(credMgr, Constants.APPS_PATH, argApp.Name, "instances");
            var instances = r.Execute <Dictionary <string, ExternalInstance> >();

            return(instances.Values.ToArrayOrNull());
        }
Пример #3
0
        public IEnumerable <ProvisionedService> GetProvisionedServices(string proxy_user = null)
        {
            var r = new VcapRequest(credMgr, Constants.SERVICES_PATH);

            if (false == proxy_user.IsNullOrWhiteSpace())
            {
                r.ProxyUser = proxy_user;
            }
            return(r.Execute <ProvisionedService[]>());
        }
Пример #4
0
        public IEnumerable <Application> GetApplications(string proxy_user = null)
        {
            var r = new VcapRequest(credMgr, Constants.APPS_PATH);

            if (false == proxy_user.IsNullOrWhiteSpace())
            {
                r.ProxyUser = proxy_user;
            }
            return(r.Execute <Application[]>());
        }
Пример #5
0
        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());
        }
Пример #6
0
        public IEnumerable <StatInfo> GetStats(Application argApp)
        {
            var          r        = new VcapRequest(credMgr, Constants.APPS_PATH, argApp.Name, "stats");
            RestResponse response = r.Execute();
            var          tmp      = JsonConvert.DeserializeObject <SortedDictionary <int, StatInfo> >(response.Content);

            var rv = new List <StatInfo>();

            foreach (KeyValuePair <int, StatInfo> kvp in tmp)
            {
                StatInfo si = kvp.Value;
                si.ID = kvp.Key;
                rv.Add(si);
            }
            return(rv.ToArrayOrNull());
        }
Пример #7
0
        public IEnumerable <SystemService> GetSystemServices()
        {
            var          r        = new VcapRequest(credMgr, Constants.GLOBAL_SERVICES_PATH);
            RestResponse response = r.Execute();

            var datastores = new List <SystemService>();
            var list       = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, Dictionary <string, SystemService> > > >(response.Content);

            foreach (var val in list.Values)
            {
                foreach (var val1 in val.Values)
                {
                    foreach (var val2 in val1.Values)
                    {
                        datastores.Add(val2);
                    }
                }
            }

            return(datastores.ToArrayOrNull());
        }
Пример #8
0
        public VcapClientResult Target(Uri argUri = null)
        {
            VcapClientResult rv;

            if (null == argUri)
            {
                // Just return current target
                rv = new VcapClientResult(false, credMgr.CurrentTarget.AbsoluteUriTrimmed());
            }
            else
            {
                // "target" does the same thing as "info", but not logged in
                // considered valid if name, build, version and support are all non-null
                // without argument, displays current target
                var  r    = new VcapRequest(credMgr, false, argUri, Constants.INFO_PATH);
                Info info = r.Execute <Info>();

                bool success = false;
                if (null != info)
                {
                    success = false == info.Name.IsNullOrWhiteSpace() &&
                              false == info.Build.IsNullOrWhiteSpace() &&
                              false == info.Version.IsNullOrWhiteSpace() &&
                              false == info.Support.IsNullOrWhiteSpace();
                }

                if (success)
                {
                    credMgr.SetTarget(argUri);
                    credMgr.StoreTarget();
                }

                rv = new VcapClientResult(success, credMgr.CurrentTarget.AbsoluteUriTrimmed());
            }

            return(rv);
        }
Пример #9
0
        public VcapClientResult Info()
        {
            var r = new VcapRequest(credMgr, Constants.INFO_PATH);

            return(new VcapClientResult(true, r.Execute <Info>()));
        }
Пример #10
0
        public IEnumerable <Crash> GetAppCrash(Application app)
        {
            var r = new VcapRequest(credMgr, Constants.APPS_PATH, app.Name, "crashes");

            return(r.Execute <Crash[]>());
        }
Пример #11
0
        public string GetAppCrash(string name)
        {
            var r = new VcapRequest(credMgr, Constants.APPS_PATH, name, "crashes");

            return(r.Execute().Content);
        }
Пример #12
0
        public string GetStartupLog(Application argApp, ushort argInstance)
        {
            var r = new VcapRequest(credMgr, Constants.APPS_PATH, argApp.Name, argInstance, "files/logs/startup.log");

            return(r.Execute().Content);
        }
Пример #13
0
        public string GetApplicationJson(string name)
        {
            var r = new VcapRequest(credMgr, Constants.APPS_PATH, name);

            return(r.Execute().Content);
        }