internal TrafficManagerDefinition(XElement xml, TrafficManagerProfile parent)
 {
     var ns = XmlNamespaces.WindowsAzure;
     Version = (string)xml.Element(ns + "Version");
     DnsTtlInSeconds = (int)xml.Element(ns + "DnsOptions").Element(ns + "TimeToLiveInSeconds");
     Enabled = (string)xml.Element(ns + "Status") != "Disabled";
     Monitors = xml.Element(ns + "Monitors").Elements(ns + "Monitor").Select(xe => new TrafficManagerMonitor(xe)).ToList();
     Policy = new TrafficManagerPolicy(xml.Element(ns + "Policy"));
     Parent = parent;
 }
        AzureRestClient GetRestClient(TrafficManagerProfile profile, string pathSuffix = null)
        {
            string servicePath = "/" + profile.Name + "/definitions";

            if (!string.IsNullOrEmpty(pathSuffix))
            {
                servicePath += pathSuffix;
            }
            return(profile.GetRestClient(servicePath));
        }
        internal TrafficManagerDefinition(XElement xml, TrafficManagerProfile parent)
        {
            var ns = XmlNamespaces.WindowsAzure;

            Version         = (string)xml.Element(ns + "Version");
            DnsTtlInSeconds = (int)xml.Element(ns + "DnsOptions").Element(ns + "TimeToLiveInSeconds");
            Enabled         = (string)xml.Element(ns + "Status") != "Disabled";
            Monitors        = xml.Element(ns + "Monitors").Elements(ns + "Monitor").Select(xe => new TrafficManagerMonitor(xe)).ToList();
            Policy          = new TrafficManagerPolicy(xml.Element(ns + "Policy"));
            Parent          = parent;
        }
        internal async Task CreateAsync(TrafficManagerProfile parent)
        {
            Contract.Requires(Parent == null);
            Contract.Requires(parent != null);

            var ns = XmlNamespaces.WindowsAzure;
            var content = new XElement(ns + "Definition",
                new XElement(ns + "DnsOptions", new XElement (ns + "TimeToLiveInSeconds", DnsTtlInSeconds)),
                new XElement (ns + "Monitors", Monitors.Select (m => m.ToXml())),
                Policy.ToXml());

            var response = await GetRestClient(parent).PostWithXmlResponseAsync(content);
            Version = (string)response.Element(ns + "Version");
            Parent = parent;
        }
        internal async Task CreateAsync(TrafficManagerProfile parent)
        {
            Contract.Requires(Parent == null);
            Contract.Requires(parent != null);

            var ns      = XmlNamespaces.WindowsAzure;
            var content = new XElement(ns + "Definition",
                                       new XElement(ns + "DnsOptions", new XElement(ns + "TimeToLiveInSeconds", DnsTtlInSeconds)),
                                       new XElement(ns + "Monitors", Monitors.Select(m => m.ToXml())),
                                       Policy.ToXml());

            var response = await GetRestClient(parent).PostWithXmlResponseAsync(content);

            Version = (string)response.Element(ns + "Version");
            Parent  = parent;
        }
Beispiel #6
0
 public TrafficManagerTests()
 {
     Debug.WriteLine("Creating traffic manager profile");
     Profile = new TrafficManagerProfile("test-" + Guid.NewGuid().ToString("N"), Parent.CloudService.Name + ".trafficmanager.net");
     Subscription.CreateTrafficManagerProfileAsync (Profile).Wait();
 }
Beispiel #7
0
 public Task CreateTrafficManagerProfileAsync(TrafficManagerProfile profile) { return profile.CreateAsync(this); }
 AzureRestClient GetRestClient(TrafficManagerProfile profile, string pathSuffix = null)
 {
     string servicePath = "/" + profile.Name + "/definitions";
     if (!string.IsNullOrEmpty(pathSuffix)) servicePath += pathSuffix;
     return profile.GetRestClient(servicePath);
 }