Example #1
0
        public void TestHighLevel()
        {
            var goodCredentials = ReadCredentialsFromFile("..\\..\\Credentials.txt");
            Assert.IsNotNull(goodCredentials);
            var api = new CSAPIHighLevel(goodCredentials.ApiKey, goodCredentials.ApiId);

            var envStatusList = api.GetEnvironmentStatusList();
            foreach (var env in envStatusList)
            {
                Console.WriteLine(env.envId);
            }
        }
Example #2
0
        public void TestTemplates()
        {
            var goodCredentials = ReadCredentialsFromFile("..\\..\\Credentials.txt");
            Assert.IsNotNull(goodCredentials);

            var api = new CSAPILowLevel(goodCredentials.ApiKey, goodCredentials.ApiId);
            Assert.IsTrue(api.CheckKeys());

            var highlevel = new CSAPIHighLevel(goodCredentials.ApiKey, goodCredentials.ApiId);
            var templatesList = highlevel.ListTemplates();

            var categoriesLists = (from t in templatesList select t.categories).ToList();
            var categories = new HashSet<string>();
            foreach (var cList in categoriesLists)
            {
                if (cList != null)
                    foreach (var item in cList)
                        if (item != null)
                            categories.Add((String)item);
            }
            Console.WriteLine(String.Join("\n", categories));

            Console.WriteLine("number of templates = " + templatesList.Count.ToString());
            var envList = highlevel.ListEnvironments();
            foreach (var env in envList)
                Console.WriteLine(env.name + "\t" + env.envId);
            foreach (var tmp in templatesList)
                if (tmp.memory_size_mb < 1024)
                    Console.WriteLine(tmp.name + "\t" + tmp.id);
        }
Example #3
0
        public void TestCheckCloudFolders()
        {
            var goodCredentials = ReadCredentialsFromFile("..\\..\\Credentials.txt");
            Assert.IsNotNull(goodCredentials);
            var api = new CSAPIHighLevel(goodCredentials.ApiKey, goodCredentials.ApiId);

            var cloudFoldersInfo = api.GetCloudFoldersInfo();
            Console.WriteLine("CloudFolder status -");
            Console.WriteLine("host: " + cloudFoldersInfo.host);
            Console.WriteLine("user: "******"password: " + cloudFoldersInfo.password);
        }
Example #4
0
        public void TestHighLevelAsync()
        {
            var goodCredentials = ReadCredentialsFromFile("..\\..\\Credentials.txt");
            Assert.IsNotNull(goodCredentials);
            var api = new CSAPIHighLevel(goodCredentials.ApiKey, goodCredentials.ApiId);

            var envStatusList = api.GetEnvironmentStatusList();
            
            foreach (var env in envStatusList)
            {
                try
                {
                    var t = api.ResumeEnvironmentAsync(env);
                    t.Wait();
                    Console.WriteLine("Resumed env {0}", env.envId);
                }
                catch (AggregateException e)
                {
                    Assert.IsTrue(e.InnerException is ApiException);
                    var apiException = e.InnerException as ApiException;
                    Assert.IsTrue(apiException.ApiResponse != null, String.Format("We got Bad API Exception: {0}", apiException.Message));
                    
                    Console.WriteLine("Not expected to fail resuming env {0}.\nException message: {1}", env.envId, apiException.Message);
                }

                try
                {
                    env.envId = "NOTEXIST";
                    var t = api.ResumeEnvironmentAsync(env);
                    t.Wait();
                    Console.WriteLine("Resumed env {0}", env.envId);
                }
                catch (AggregateException e)
                {
                    Assert.IsTrue(e.InnerException is ApiException);
                    var apiException = e.InnerException as ApiException;
                    Assert.IsTrue(apiException.ApiResponse != null, String.Format("We got Bad API Exception: {0}", apiException.Message));

                    Console.WriteLine("Expected to fail resuming non existing env {0}.\nException message: {1}", env.envId, apiException.Message);
                }
            }

            envStatusList.Add(new EnvStatus());
        }