Пример #1
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());
        }
Пример #2
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);
        }
Пример #3
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[]>());
        }
Пример #4
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[]>());
        }
Пример #5
0
        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();
        }
Пример #6
0
        public IEnumerable <SystemService> GetSystemServices()
        {
            VcapRequest   r        = BuildVcapRequest(Constants.GLOBAL_SERVICES_PATH);
            IRestResponse response = r.Execute();

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

            var dataStores = from val in list.Values
                             from val1 in val.Values
                             from val2 in val1.Values
                             select val2;

            return(dataStores.ToList());
        }
Пример #7
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());
        }
Пример #8
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());
        }
Пример #9
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());
        }
Пример #10
0
        public void Target(Uri uri)
        {
            // "target" does the same thing as "info", but not logged in
            // considered valid if name, build, version and support are all non-null
            VcapRequest request = BuildVcapRequest(false, uri, Constants.INFO_PATH);
            Info        info    = request.Execute <Info>();

            var success = info != null &&
                          !info.Name.IsNullOrWhiteSpace() &&
                          !info.Build.IsNullOrWhiteSpace() &&
                          !info.Version.IsNullOrWhiteSpace() &&
                          !info.Support.IsNullOrWhiteSpace();

            if (success)
            {
                CredentialManager.SetTarget(uri);
                CredentialManager.StoreTarget();
            }
            else
            {
                throw new VcapTargetException(request.ErrorMessage);
            }
        }
Пример #11
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);
        }
Пример #12
0
        public IEnumerable <Application> GetApplications(string proxy_user = null)
        {
            VcapRequest r = BuildVcapRequest(Constants.APPS_PATH);

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

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

            return(r.Execute().Content);
        }
Пример #15
0
        public IEnumerable <ProvisionedService> GetProvisionedServices()
        {
            VcapRequest r = BuildVcapRequest(Constants.SERVICES_PATH);

            return(r.Execute <ProvisionedService[]>());
        }
Пример #16
0
        public string GetApplicationJson(string name)
        {
            var r = new VcapRequest(credMgr, Constants.APPS_PATH, name);

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

            return(new VcapClientResult(true, r.Execute <Info>()));
        }
Пример #18
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);
        }
Пример #19
0
        public Info GetInfo()
        {
            VcapRequest r = BuildVcapRequest(Constants.INFO_PATH);

            return(r.Execute <Info>());
        }
Пример #20
0
        public string GetApplicationJson(string name)
        {
            VcapRequest r = BuildVcapRequest(Constants.APPS_PATH, name);

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