コード例 #1
0
ファイル: InfoHelper.cs プロジェクト: chandermani/ironfoundry
        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
ファイル: InfoHelper.cs プロジェクト: chandermani/ironfoundry
        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
ファイル: InfoHelper.cs プロジェクト: chandermani/ironfoundry
        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);
        }