forked from openstacknetsdk/openstack.net
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentDeliveryNetworkExample.cs
More file actions
68 lines (56 loc) · 2.17 KB
/
Copy pathContentDeliveryNetworkExample.cs
File metadata and controls
68 lines (56 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Linq;
using net.openstack.Core.Domain;
using net.openstack.Core.Providers;
using net.openstack.Providers.Rackspace;
using OpenStack;
using OpenStack.ContentDeliveryNetworks.v1;
using OpenStack.Synchronous;
namespace CSharpCodeSamples
{
public class ContentDeliveryNetworkExample
{
public async void FindAServiceAysnc()
{
var identity = new CloudIdentity {Username = "{username}", APIKey = "{api-key}"};
IIdentityProvider identityProvider = new CloudIdentityProvider(identity);
var service = new ContentDeliveryNetworkService(identityProvider, "DFW");
IPage<Service> currentPage = await service.ListServicesAsync();
Service myService;
do
{
myService = currentPage.FirstOrDefault(x => x.Name == "MyService");
if (myService != null)
break;
currentPage = await currentPage.GetNextPageAsync();
} while (currentPage.Any());
if (myService == null)
{
Console.Error.WriteLine("Could not find MyService!");
return;
}
Console.WriteLine("MyService: {0}", myService.Status);
}
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);
}
}
}