public void Should_Return_Container_List()
        {
            var provider = new CloudFilesProvider();
            var containerList = provider.ListContainers(identity: _testIdentity);

            Assert.IsNotNull(containerList);
            Assert.IsTrue(containerList.Any());
        }
        public void Should_Return_Container_List_With_Internal_Url()
        {
            var provider = new CloudFilesProvider();
            var containerList = provider.ListContainers(useInternalUrl:true, identity: _testIdentity);

            Assert.IsNotNull(containerList);
            Assert.IsTrue(containerList.Any());
        }
        protected void CFProviderListContainers(string dcregion, bool dcsnet = true)
        {
            var identity = new RackspaceCloudIdentity() { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };

            CloudIdentityProvider identityProvider = new net.openstack.Providers.Rackspace.CloudIdentityProvider(identity);
            CloudFilesProvider CloudFilesProvider = new net.openstack.Providers.Rackspace.CloudFilesProvider(identity);

            var CfContainers = CloudFilesProvider.ListContainers(null, null, null, dcregion, dcsnet);

            CFContainerDDL.DataSource = CfContainers;
            CFContainerDDL.DataTextField = "Name";
            CFContainerDDL.DataBind();
        }
Пример #4
0
        private IEnumerable<Container> ListContainers(CloudIdentity cloudIdentity, int? limit = null, string region = null, bool useInternalUrl = false) {
            var provider = new CloudFilesProvider(cloudIdentity);

            Container lastContainer = null;

            do {
                string marker = lastContainer != null ? lastContainer.Name : null;
                IEnumerable<Container> containerObjects = provider.ListContainers(limit, marker, null, region, useInternalUrl, cloudIdentity);
                lastContainer = null;
                foreach (Container containerObject in containerObjects) {
                    lastContainer = containerObject;
                    yield return containerObject;
                }
            } while (lastContainer != null);

        }
        public void Should_Return_Container_List_With_Limit()
        {
            var provider = new CloudFilesProvider();
            var containerList = provider.ListContainers(1, identity: _testIdentity);

            Assert.IsNotNull(containerList);
            Assert.AreEqual(1, containerList.Count());
        }
        public void Should_Return_Container_List_With_End_Marker_Lower_Case()
        {
            var provider = new CloudFilesProvider();
            var containerList = provider.ListContainers(null, null, "l", identity: _testIdentity);

            Assert.IsNotNull(containerList);
            Assert.IsTrue(containerList.Any());
        }
Пример #7
0
        public void Should_Purge_Objects_Before_Deleting_The_Conatiner()
        {
            var provider = new CloudFilesProvider(_testIdentity);

            provider.DeleteContainer(containerName2);

            var containers = provider.ListContainers();
            Assert.IsFalse(containers.Any(c => c.Name.Equals(containerName2)));
        }
Пример #8
0
        public void Should_Create_New_Test_Container_2()
        {
            var provider = new CloudFilesProvider(_testIdentity);

            provider.CreateContainer(containerName2);

            var containers = provider.ListContainers();
            Assert.IsTrue(containers.Any(c => c.Name.Equals(containerName2)));
        }
Пример #9
0
        public static void Main(string[] args)
        {
            Boolean containerExists = false;
            if (args.Length < 4 || args.Length > 5)
            {
                Console.WriteLine("Usage: {0} username api_key target_container path_to_file [region (US|UK)]", Environment.CommandLine);
                Environment.Exit(1);
            }
            RackspaceCloudIdentity auth = new RackspaceCloudIdentity();
            IEnumerable<Container> containerList = null;
            auth.Username = args[0];
            auth.APIKey = args[1];
            targetContainer = args[2];
            filePath = args[3];
            if (args.Length == 5)
            {
                if (args[4] != "UK" && args[4] != "US")
                {
                    Console.WriteLine("region must be either US or UK", Environment.CommandLine);
                    Environment.Exit(1);
                }
                switch (args[4])
                {
                    case "UK": {auth.CloudInstance = CloudInstance.UK;};break;
                    case "US": { auth.CloudInstance = CloudInstance.Default;}; break;
                }
            }

            try
            {
                IIdentityProvider identityProvider = new CloudIdentityProvider();
                var userAccess = identityProvider.Authenticate(auth);
            }
            catch (ResponseException ex2)
            {
                Console.WriteLine("Authentication failed with the following message: {0}",ex2.Message);
                Environment.Exit(1);
            }

            try
            {
                var cloudFilesProvider = new CloudFilesProvider(auth);
                containerList = cloudFilesProvider.ListContainers();

                foreach (Container container in containerList)
                {
                    if (container.Name == targetContainer)
                    {
                        containerExists = true;
                        break;
                    }
                }

                if (!containerExists)
                {
                    Console.WriteLine("Container \"{0}\" does not exist on the provided CloudFiles account.", targetContainer);
                    Environment.Exit(1);
                }
                if (!File.Exists(filePath))
                {
                    Console.WriteLine("The file specified ({0}) does not exist", filePath);
                    Environment.Exit(1);
                }
                cloudFilesProvider.CreateObjectFromFile(targetContainer, @filePath, Path.GetFileName(filePath));
            }
            catch (Exception ex2)
            {
                Console.WriteLine(ex2.Message);
                Environment.Exit(1);
            }
            Console.WriteLine("*SUCCESS* File: \"{0}\" uploaded to \"{1}\"", filePath, targetContainer);
        }