本文整理汇总了C#中net.openstack.Core.Domain.CloudIdentity类的典型用法代码示例。如果您正苦于以下问题:C# CloudIdentity类的具体用法?C# CloudIdentity怎么用?C# CloudIdentity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudIdentity类属于net.openstack.Core.Domain命名空间,在下文中一共展示了CloudIdentity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateProvider
public void CreateProvider()
{
#region CreateProvider
var identity = new CloudIdentity { Username = "{username}", APIKey = "{apiKey}" };
var provider = new CloudIdentityProvider(identity);
#endregion
}
示例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: ListAllObjects
private static IEnumerable<ContainerObject> ListAllObjects(
IObjectStorageProvider provider,
string containerName,
int? blockSize = null,
string prefix = null,
string region = null,
bool useInternalUrl = false,
CloudIdentity identity = null)
{
if (blockSize <= 0)
throw new ArgumentOutOfRangeException("blockSize");
ContainerObject lastContainerObject = null;
do
{
string marker = lastContainerObject != null ? lastContainerObject.Name : null;
IEnumerable<ContainerObject> containerObjects =
provider.ListObjects(containerName, blockSize, marker, null, prefix, region, useInternalUrl, identity);
lastContainerObject = null;
foreach (ContainerObject containerObject in containerObjects)
{
lastContainerObject = containerObject;
yield return containerObject;
}
} while (lastContainerObject != null);
}
示例4: CloudFilesProvider
internal CloudFilesProvider(CloudIdentity defaultIdentity, ICloudIdentityProvider cloudIdentityProvider, IRestService restService, ICloudFilesValidator cloudFilesValidator, ICloudFilesMetadataProcessor cloudFilesMetadataProcessor, IEncodeDecodeProvider encodeDecodeProvider)
: base(defaultIdentity, cloudIdentityProvider, restService)
{
_cloudFilesValidator = cloudFilesValidator;
_cloudFilesMetadataProcessor = cloudFilesMetadataProcessor;
_encodeDecodeProvider = encodeDecodeProvider;
}
示例5: CreateProviderWithPassword
public void CreateProviderWithPassword()
{
#region CreateProviderWithPassword
var identity = new CloudIdentity { Username = "{username}", Password = "{password}" };
var provider = new CloudIdentityProvider(identity);
#endregion
}
示例6: 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);
}
示例7: FromCloudIdentity
public static AuthRequest FromCloudIdentity(CloudIdentity identity)
{
var creds = new AuthDetails();
if (string.IsNullOrWhiteSpace(identity.Password))
creds.APIKeyCredentials = new Credentials() { Username = identity.Username, APIKey = identity.APIKey};
else
creds.PasswordCredentials = new Credentials(){Username = identity.Username, Password = identity.Password};
return new AuthRequest { Credencials = creds };
}
示例8: CloudFilesAssetWorker
public CloudFilesAssetWorker(int readTimeout, int writeTimeout)
{
CloudIdentity identity = new CloudIdentity { Username = Config.Settings.Instance.CFUsername, APIKey = Config.Settings.Instance.CFApiKey };
IRestService restService = new CoreExt.ExtendedJsonRestServices(readTimeout, writeTimeout);
_provider = new CoreExt.ExtendedCloudFilesProvider(identity, Config.Settings.Instance.CFDefaultRegion, null, restService);
//warm up
_provider.GetAccountHeaders(useInternalUrl: Config.Settings.Instance.CFUseInternalURL, region: Config.Settings.Instance.CFDefaultRegion);
}
示例9: Init
public static void Init(TestContext context)
{
_testIdentity = new RackspaceCloudIdentity(Bootstrapper.Settings.TestIdentity);
var provider = new CloudServersProvider(_testIdentity);
_initImage = provider.ListImages(imageName: "CentOS 6.3").First();
_initFlavor = provider.ListFlavors().OrderBy(f => f.Id).First();
}
示例10: 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
}
示例11: ShowNetwork
public CloudNetwork ShowNetwork(string networkId, string region = null, CloudIdentity identity = null)
{
var urlPath = new Uri(string.Format("{0}/os-networksv2/{1}", GetServiceEndpoint(identity, region), networkId));
var response = ExecuteRESTRequest<CloudNetworkResponse>(identity, urlPath, HttpMethod.GET);
if (response == null || response.Data == null)
return null;
return response.Data.Network;
}
示例12: ResetApiKey
public void ResetApiKey()
{
var identity = new CloudIdentity { Username = "{username}", APIKey = "{apiKey}" };
var provider = new CloudIdentityProvider(identity);
#region ResetApiKey
UserCredential credential = provider.ResetApiKey("{userId}");
string newApiKey = credential.APIKey;
#endregion
}
示例13: ListNetworks
public IEnumerable<CloudNetwork> ListNetworks(string region = null, CloudIdentity identity = null)
{
var urlPath = new Uri(string.Format("{0}/os-networksv2", GetServiceEndpoint(identity, region)));
var response = ExecuteRESTRequest<ListCloudNetworksResponse>(identity, urlPath, HttpMethod.GET);
if (response == null || response.Data == null)
return null;
return response.Data.Networks;
}
示例14: ComputeTests
public ComputeTests()
{
_testIdentity = new CloudIdentity()
{
APIKey = ConfigurationManager.AppSettings["TestIdentityAPIKey"],
Password = ConfigurationManager.AppSettings["TestIdentityPassword"],
Region = ConfigurationManager.AppSettings["TestIdentityRegion"],
Username = ConfigurationManager.AppSettings["TestIdentityUserName"],
};
}
示例15: Rackspace
private string username; //private variable for username
#endregion Fields
#region Constructors
//Constructor accpeting the username, password or apikey
public Rackspace(string username, string apiKey)
{
this.username = username; //setting the username property
this.apiKey = apiKey; //setting the apikey property
//Creating an instance of CloudIdentity
identity = new CloudIdentity();
identity.Username = username;
identity.APIKey = apiKey;
}