/// <summary> /// Creates a new Global Server Load Balancing service /// </summary> /// <param name="zone">zone to create GSLB at</param> /// <param name="fqdn">address to create GSLB at</param> /// <param name="regions">a list of regions</param> /// <param name="autoRecover"> true if the service should come out of failover automatically when IPs come back up, false if the service should stay in failover until a user explicitly takes the service out of failover</param> /// <param name="notifyEvents">What events to send notifications on: ip - Send notifications when individual IPs change status, svc - Send notifications when the service state changes</param> /// <param name="monitorData">The health monitor for the service</param> /// <param name="contactNickname">Name of contact to receive notifications</param> /// <param name="ttl">Time To Live in seconds of records in the service. Must be less than 1/2 of the Health Probe's monitoring interval.</param> /// <returns>The created service object if successfull</returns> public net.dynect.api2.GSLBData CreateGSLB(string zone, string fqdn, net.dynect.api2.GSLBRegion[] regions, Boolean autoRecover, MonitorNotificationEvent notifyEvents, net.dynect.api2.MonitorData monitorData, string contactNickname, TTLSeconds ttl) { if (sessionData == null) return null; net.dynect.api2.GSLBData retVal = null; try { net.dynect.api2.CreateGSLBRequestType request = new DynSoapWrapper.net.dynect.api2.CreateGSLBRequestType(); request.token = sessionData.token; request.fault_incompat = 1; request.fault_incompatSpecified = true; request.zone = zone; request.fqdn = fqdn; request.region = regions; request.auto_recover = autoRecover ? "Y" : "N"; request.notify_events = MonitorNotificationEventToString(notifyEvents); request.monitor = monitorData; request.contact_nickname = contactNickname; if (ttl == TTLSeconds.NONE) { request.ttlSpecified = false; } else { request.ttl = (int)ttl; request.ttlSpecified = true; } net.dynect.api2.CreateGSLBResponseType response = dynectWsdl.CreateGSLB(request); retVal = response.data; } catch (Exception ex) { ;// TODO: Do your custom error handling here.... } return retVal; }
/// <summary> /// Creates the load balance service on the node /// </summary> /// <param name="zone">The zone to attach the LoadBalance to</param> /// <param name="fqdn">The fqdb to attach the LoadBalance to</param> /// <param name="contactNickname">Name of contact to receive notifications</param> /// <param name="loadBalancePool">The IP Pool list for this service</param> /// <param name="monitorData">The health monitor for the service</param> /// <param name="autoRecover">True if service should come out of failover automatically when IPs come back up, False if the service should stay in failover until a user explicitly takes the service out of failover</param> /// <param name="ttl">Time To Live in seconds of records in the service. Must be less than 1/2 of the Health Probe's monitoring interval or "None" to not specify</param> /// <param name="notifyEvents">What events to send notifications on: ip - Send notifications when individual IPs change status, svc - Send notifications when the service state change</param> /// <param name="serveCount">How many records will be returned in each DNS response or -1 to not specify</param> /// <param name="failoverMode">Dynect default is 'global': ip - Failover to a particular IP, cname - Failover to a particular CNAME, global - Failover to the global IP address pool</param> /// <param name="failoverData">If failover_mode is 'ip', this should be an IPv4 address, If failover_mode is 'cname', this should be a CNAME, If failover_mode is 'global' this should be null or empty</param> /// <returns>The created load balance data or null if failed to create</returns> public net.dynect.api2.LoadBalanceData CreateLoadBalance(string zone, string fqdn, string contactNickname, net.dynect.api2.LoadBalanceAddress[] loadBalancePool, net.dynect.api2.MonitorData monitorData, Boolean autoRecover, TTLSeconds ttl, MonitorNotificationEvent notifyEvents, int serveCount, FailoverMode failoverMode, string failoverData) { if (sessionData == null) return null; net.dynect.api2.LoadBalanceData retVal = null; try { net.dynect.api2.CreateLoadBalanceRequestType request = new DynSoapWrapper.net.dynect.api2.CreateLoadBalanceRequestType(); request.token = sessionData.token; request.fault_incompat = 1; request.fault_incompatSpecified = true; request.zone = zone; request.fqdn = fqdn; request.failover_mode = failoverMode.ToString(); request.auto_recover = autoRecover ? "Y" : "N"; request.contact_nickname = contactNickname; request.failover_data = failoverMode == FailoverMode.global ? string.Empty : failoverData; request.monitor = monitorData; request.notify_events = MonitorNotificationEventToString(notifyEvents); request.pool = loadBalancePool; if (serveCount > -1) { request.serve_count = serveCount; request.serve_countSpecified = true; } else { request.serve_countSpecified = false; } if (ttl == TTLSeconds.NONE) { request.ttlSpecified = false; } else { request.ttl = (int)ttl; request.ttlSpecified = true; } net.dynect.api2.CreateLoadBalanceResponseType response = dynectWsdl.CreateLoadBalance(request); retVal = response.data; } catch (Exception ex) { ;// TODO: Do your custom error handling here.... } return retVal; }
public static string MonitorNotificationEventToString(MonitorNotificationEvent e) { switch(e) { case MonitorNotificationEvent.ip: return "ip"; case MonitorNotificationEvent.svc: return "svc"; case MonitorNotificationEvent.both: return "svc,ip"; case MonitorNotificationEvent.neither: return string.Empty; } return string.Empty; }