Beispiel #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());
        }
Beispiel #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);
        }
        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[]>());
        }
        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[]>());
        }
Beispiel #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();
        }
        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());
        }
Beispiel #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());
        }
Beispiel #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());
        }
        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());
        }
Beispiel #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);
            }
        }
Beispiel #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);
        }
        public IEnumerable <Application> GetApplications(string proxy_user = null)
        {
            VcapRequest r = BuildVcapRequest(Constants.APPS_PATH);

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

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

            return(r.Execute().Content);
        }
        public IEnumerable <ProvisionedService> GetProvisionedServices()
        {
            VcapRequest r = BuildVcapRequest(Constants.SERVICES_PATH);

            return(r.Execute <ProvisionedService[]>());
        }
        public string GetApplicationJson(string name)
        {
            var r = new VcapRequest(credMgr, Constants.APPS_PATH, name);

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

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

            return(r.Execute <Info>());
        }
        public string GetApplicationJson(string name)
        {
            VcapRequest r = BuildVcapRequest(Constants.APPS_PATH, name);

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