/// <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; }
/// <summary> /// Add or create a Region array to send to the GSLB service /// </summary> /// <param name="currenetGSLBRegionArray">The LoadBalanceAddress array to add the LoadBalanceAddress to or null to start a new array</param> /// <param name="poolGSLBAddresses">The pool of ip addresses for the added region</param> /// <param name="region">GSLB region location</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>An array of GSLBRegions to pass to update or create</returns> public net.dynect.api2.GSLBRegion[] AddGSLBRegion(net.dynect.api2.GSLBRegion[] currenetGSLBRegionArray, net.dynect.api2.GSLBAddress[] poolGSLBAddresses, GSLBRegionOption region, int serveCount, FailoverMode failoverMode, string failoverData) { net.dynect.api2.GSLBRegion[] retVal = null; int index = 0; if (currenetGSLBRegionArray == null) { retVal = new DynSoapWrapper.net.dynect.api2.GSLBRegion[1]; } else { retVal = new DynSoapWrapper.net.dynect.api2.GSLBRegion[currenetGSLBRegionArray.Length + 1]; for (index = 0; index < currenetGSLBRegionArray.Length; index++) { retVal[index] = currenetGSLBRegionArray[index]; } } retVal[index] = new DynSoapWrapper.net.dynect.api2.GSLBRegion(); retVal[index].failover_data = failoverMode == FailoverMode.global ? string.Empty : failoverData; retVal[index].failover_mode = failoverMode.ToString(); retVal[index].region_code = GSLBRegionToString(region); if (serveCount > 0) { retVal[index].serve_count = serveCount; retVal[index].serve_countSpecified = true; } else { retVal[index].serve_countSpecified = false; } retVal[index].pool = poolGSLBAddresses; return retVal; }