當前位置: 首頁>>代碼示例>>C#>>正文


C# Rackspace.CloudIdentityProvider類代碼示例

本文整理匯總了C#中net.openstack.Providers.Rackspace.CloudIdentityProvider的典型用法代碼示例。如果您正苦於以下問題:C# CloudIdentityProvider類的具體用法?C# CloudIdentityProvider怎麽用?C# CloudIdentityProvider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CloudIdentityProvider類屬於net.openstack.Providers.Rackspace命名空間,在下文中一共展示了CloudIdentityProvider類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Should_Authenticate_Test_Admin_Identity

        public void Should_Authenticate_Test_Admin_Identity()
        {
            IIdentityProvider serviceProvider = new CloudIdentityProvider(_testAdminIdentity);
            var userAccess = serviceProvider.Authenticate();

            Assert.IsNotNull(userAccess);
        }
開發者ID:amitgandhinz,項目名稱:openstack.net,代碼行數:7,代碼來源:IdentityTests.cs

示例2: FindAService

        public void FindAService()
        {
            var identity = new CloudIdentity { Username = "{username}", APIKey = "{api-key}" };
            IIdentityProvider identityProvider = new CloudIdentityProvider(identity);
            var service = new ContentDeliveryNetworkService(identityProvider, "DFW");

            IPage<Service> currentPage = service.ListServices();

            Service myService;
            do
            {
                myService = currentPage.FirstOrDefault(x => x.Name == "MyService");
                if (myService != null)
                    break;

                currentPage = currentPage.GetNextPage();
            } while (currentPage.Any());

            if (myService == null)
            {
                Console.Error.WriteLine("Could not find MyService!");
                return;
            }

            Console.WriteLine("MyService: {0}", myService.Status);
        }
開發者ID:charlyraffellini,項目名稱:openstack.net,代碼行數:26,代碼來源:ContentDeliveryNetworkExample.cs

示例3: CreateProvider

 public void CreateProvider()
 {
     #region CreateProvider
     var identity = new CloudIdentity { Username = "{username}", APIKey = "{apiKey}" };
     var provider = new CloudIdentityProvider(identity);
     #endregion
 }
開發者ID:charlyraffellini,項目名稱:openstack.net,代碼行數:7,代碼來源:IdentityProviderExamples.cs

示例4: CreateServer_Click

        protected void CreateServer_Click(object sender, EventArgs e)
        {
            try
            {
                CloudIdentityProvider identityProvider = new net.openstack.Providers.Rackspace.CloudIdentityProvider();
                CloudServersProvider CloudServersProvider = new net.openstack.Providers.Rackspace.CloudServersProvider();

                var identity = new RackspaceCloudIdentity { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };

                if (RegionDFW.Checked)
                {
                    CloudServersProvider.CreateServer(CSName.Text, null, CSFlavorsDDL.Text, null, null, "dfw", identity);
                }
                else if (RegionORD.Checked)
                {
                    CloudServersProvider.CreateServer(CSName.Text, null, CSFlavorsDDL.Text, null, null, "ord", identity);
                }
                else
                {
                    LblInfo.Text = "Please select DFW or ORD not both.";
                }
            }
            catch (Exception ex)
            {
                Error.Text = "Something went terribly wrong! See below for more info. <br /> <br />" + ex.ToString();
            }
        }
開發者ID:ravikamachi,項目名稱:OpenStackDotNet-Test,代碼行數:27,代碼來源:CloudServers.aspx.cs

示例5: ListCloudServerIpAddresses_Click

        protected void ListCloudServerIpAddresses_Click(object sender, EventArgs e)
        {
            try
            {
                CloudIdentityProvider identityProvider = new net.openstack.Providers.Rackspace.CloudIdentityProvider();
                CloudServersProvider CloudServersProvider = new net.openstack.Providers.Rackspace.CloudServersProvider();

                var identity = new RackspaceCloudIdentity { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };

                if (RegionDFW.Checked)
                {
                    var serveripaddressdetails = CloudServersProvider.ListAddresses(CSImageListDDL.SelectedValue, "dfw", identity);
                }
                else if (RegionORD.Checked)
                {
                    var serveripaddressdetails = CloudServersProvider.ListAddresses(CSImageListDDL.SelectedValue, "dfw", identity);

                    CFResultsGrid.DataSource = serveripaddressdetails;
                    CFResultsGrid.DataBind();
                }
                else
                {
                    LblInfo.Text = "Please select DFW or ORD not both.";
                }
            }
            catch (Exception ex)
            {
                Error.Text = "Something went terribly wrong! See below for more info. <br /> <br />" + ex.ToString();
            }
        }
開發者ID:ravikamachi,項目名稱:OpenStackDotNet-Test,代碼行數:30,代碼來源:CloudServers.aspx.cs

示例6: TestValidateToken

        public void TestValidateToken()
        {
            IIdentityProvider provider = new CloudIdentityProvider(Bootstrapper.Settings.TestIdentity);
            UserAccess userAccess = provider.Authenticate();

            Assert.IsNotNull(userAccess);
            Assert.IsNotNull(userAccess.Token);
            Assert.IsNotNull(userAccess.Token.Id);

            try
            {
                UserAccess validated = provider.ValidateToken(userAccess.Token.Id);
                Assert.IsNotNull(validated);
                Assert.IsNotNull(validated.Token);
                Assert.AreEqual(userAccess.Token.Id, validated.Token.Id);

                Assert.IsNotNull(validated.User);
                Assert.AreEqual(userAccess.User.Id, validated.User.Id);
                Assert.AreEqual(userAccess.User.Name, validated.User.Name);
                Assert.AreEqual(userAccess.User.DefaultRegion, validated.User.DefaultRegion);
            }
            catch (UserNotAuthorizedException ex)
            {
                if (ex.Response.StatusCode != HttpStatusCode.Forbidden)
                    throw;

                Assert.Inconclusive("The service does not allow this user to access the Validate Token API.");
            }
        }
開發者ID:nick-o,項目名稱:openstack.net,代碼行數:29,代碼來源:UserIdentityTests.cs

示例7: CreateProviderWithPassword

 public void CreateProviderWithPassword()
 {
     #region CreateProviderWithPassword
     var identity = new CloudIdentity { Username = "{username}", Password = "{password}" };
     var provider = new CloudIdentityProvider(identity);
     #endregion
 }
開發者ID:charlyraffellini,項目名稱:openstack.net,代碼行數:7,代碼來源:IdentityProviderExamples.cs

示例8: CFProvidersCreateContainer

        protected void CFProvidersCreateContainer(string cfcreatecontainername, 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 CfCreateContainer = CloudFilesProvider.CreateContainer(cfcreatecontainername, dcregion, dcsnet);
        }
開發者ID:ravikamachi,項目名稱:OpenStackDotNet-Test,代碼行數:9,代碼來源:CloudFiles.aspx.cs

示例9: CFProvidersCreateObjectFromFile

        protected void CFProvidersCreateObjectFromFile(string cfcontainername, string cfcreateobjfilepath, string cfcreateobjfilename, int cfcreateobjchunksize, 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);

            CloudFilesProvider.CreateObjectFromFile(cfcontainername, cfcreateobjfilepath, cfcreateobjfilename, cfcreateobjchunksize, null, dcregion, null, dcsnet);
        }
開發者ID:ravikamachi,項目名稱:OpenStackDotNet-Test,代碼行數:9,代碼來源:CloudFiles.aspx.cs

示例10: CFProvidersDeleteContainerObject

        protected void CFProvidersDeleteContainerObject(string cfcontainername, string cfdeletecontainerobject, 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 Cfdeletecontainerobject = CloudFilesProvider.DeleteObject(cfcontainername, cfdeletecontainerobject, null, dcregion, dcsnet);
        }
開發者ID:ravikamachi,項目名稱:OpenStackDotNet-Test,代碼行數:9,代碼來源:CloudFiles.aspx.cs

示例11: Run

    public async Task Run(string username, string apiKey, string region)
    {
        // Configure authentication
        var identity = new CloudIdentity
        {
            Username = username,
            APIKey = apiKey
        };
        var identityService = new CloudIdentityProvider(identity);
        var networkService = new CloudNetworkService(identityService, region);

        Console.WriteLine("Creating Sample Network... ");
        var networkDefinition = new NetworkDefinition {Name = "Sample"};
        var sampleNetwork = await networkService.CreateNetworkAsync(networkDefinition);

        Console.WriteLine("Adding a subnet to Sample Network...");
        var subnetDefinition = new SubnetCreateDefinition(sampleNetwork.Id, IPVersion.IPv4, "192.0.2.0/24")
        {
            Name = "Sample"
        };
        var sampleSubnet = await networkService.CreateSubnetAsync(subnetDefinition);

        Console.WriteLine("Attaching a port to Sample Network...");
        var portDefinition = new PortCreateDefinition(sampleNetwork.Id)
        {
            Name = "Sample"
        };
        var samplePort = await networkService.CreatePortAsync(portDefinition);

        Console.WriteLine("Listing Networks...");
        var networks = await networkService.ListNetworksAsync();
        foreach (Network network in networks)
        {
            Console.WriteLine($"{network.Id}\t\t\t{network.Name}");
        }

        Console.WriteLine();
        Console.WriteLine("Sample Network Information:");
        Console.WriteLine();
        Console.WriteLine($"Network Id: {sampleNetwork.Id}");
        Console.WriteLine($"Network Name: {sampleNetwork.Name}");
        Console.WriteLine($"Network Status: {sampleNetwork.Status}");
        Console.WriteLine();
        Console.WriteLine($"Subnet Id: {sampleSubnet.Id}");
        Console.WriteLine($"Subnet Name: {sampleSubnet.Name}");
        Console.WriteLine($"Subnet IPs: {sampleSubnet.AllocationPools.First().Start} - {sampleSubnet.AllocationPools.First().End}");
        Console.WriteLine();
        Console.WriteLine($"Port Id: {samplePort.Id}");
        Console.WriteLine($"Port Name: {samplePort.Name}");
        Console.WriteLine($"Port Address: {samplePort.MACAddress}");
        Console.WriteLine($"Port Status: {samplePort.Status}");
        Console.WriteLine();

        Console.WriteLine("Deleting Sample Network...");
        await networkService.DeletePortAsync(samplePort.Id);
        await networkService.DeleteNetworkAsync(sampleNetwork.Id);
    }
開發者ID:rackspace,項目名稱:rackspace-net-sdk,代碼行數:57,代碼來源:CloudNetworkSamples.cs

示例12: Main

        public static void Main(string[] args)
        {
            if (args.Length < 2 || args.Length > 3)
            {
                Console.WriteLine("Usage: {0} username api_key [region (US|UK)]", Environment.CommandLine);
                Environment.Exit(1);
            }
            RackspaceImpersonationIdentity auth = new RackspaceImpersonationIdentity();
            auth.Username = args[0];
            auth.APIKey = args[1];

            if (args.Length == 3)
            {
                if (args[2] != "UK" && args[2] != "US")
                {
                    Console.WriteLine("region must be either US or UK", Environment.CommandLine);
                    Environment.Exit(1);
                }
                switch (args[2])
                {
                    case "UK": { auth.CloudInstance = CloudInstance.UK; }; break;
                    case "US": { auth.CloudInstance = CloudInstance.Default; }; break;
                }
            }
            else
            {
                auth.CloudInstance = CloudInstance.Default;
            }

            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);
            }

            var cloudServers = new CloudServersProvider(auth);
            var servers = cloudServers.ListServers();
            foreach (Server serv in servers)
            {
                var date = System.DateTime.Now;
                var success = serv.CreateSnapshot(serv.Name + "_" + date.Year + "-" + date.Month + "-" + date.Day);
                if (success)
                {
                    Console.WriteLine("Image for server {0} has been created successfully.", serv.Name);
                }
                else
                {
                    Console.WriteLine("Image for server {0} could not be created.", serv.Name);
                }
            }
        }
開發者ID:nick-o,項目名稱:CloudServersSnapshot,代碼行數:56,代碼來源:Program.cs

示例13: DeleteRoleFromUser

        public void DeleteRoleFromUser()
        {
            var identity = new CloudIdentity { Username = "{username}", APIKey = "{apiKey}" };
            var provider = new CloudIdentityProvider(identity);

            #region DeleteRoleFromUser
            User user = provider.GetUserByName("{username}", null);
            provider.DeleteRoleFromUser(user.Id, "{roleId}", null);
            #endregion
        }
開發者ID:charlyraffellini,項目名稱:openstack.net,代碼行數:10,代碼來源:IdentityProviderExamples.cs

示例14: ServiceTests

        public ServiceTests(ITestOutputHelper log)
        {
            _log = log;

            var identity = TestIdentityProvider.GetIdentityFromEnvironment();
            var authenticationProvider = new CloudIdentityProvider(identity)
            {
                ApplicationUserAgent = "CI-BOT"
            };
            _cdnService = new ContentDeliveryNetworkService(authenticationProvider, "DFW");
        }
開發者ID:jmcupidon,項目名稱:openstack.net,代碼行數:11,代碼來源:ServiceTests.cs

示例15: UpdateUser

        public void UpdateUser()
        {
            var identity = new CloudIdentity { Username = "{username}", APIKey = "{apiKey}" };
            var provider = new CloudIdentityProvider(identity);

            #region UpdateUser
            User user = provider.GetUserByName("{username}", null);
            user.Username = "{newUsername}";
            provider.UpdateUser(user, null);
            #endregion
        }
開發者ID:charlyraffellini,項目名稱:openstack.net,代碼行數:11,代碼來源:IdentityProviderExamples.cs


注:本文中的net.openstack.Providers.Rackspace.CloudIdentityProvider類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。