本文整理汇总了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);
}
示例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);
}
示例3: CreateProvider
public void CreateProvider()
{
#region CreateProvider
var identity = new CloudIdentity { Username = "{username}", APIKey = "{apiKey}" };
var provider = new CloudIdentityProvider(identity);
#endregion
}
示例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();
}
}
示例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();
}
}
示例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.");
}
}
示例7: CreateProviderWithPassword
public void CreateProviderWithPassword()
{
#region CreateProviderWithPassword
var identity = new CloudIdentity { Username = "{username}", Password = "{password}" };
var provider = new CloudIdentityProvider(identity);
#endregion
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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
}
示例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");
}
示例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
}