/// <summary> /// The create server farm. /// </summary> /// <param name="networkId"> /// The network id. /// </param> /// <param name="name"> /// The name. /// </param> /// <param name="predictor"> /// The predictor. /// </param> /// <param name="rServerId"> /// The r server id. /// </param> /// <param name="rServerPort"> /// The r server port. /// </param> /// <param name="probeId"> /// The probe id. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public async Task <Status> CreateServerFarm( string networkId, string name, ServerFarmPredictorType predictor, string rServerId, int rServerPort = 0, string probeId = null) { var newserverfarm = new NewServerFarm { name = name, predictor = predictor, }; var realserver = new NewServerFarmRealServer { id = rServerId }; if (rServerPort > 0) { realserver.port = rServerPort.ToString(CultureInfo.InvariantCulture); } newserverfarm.realServer = new[] { realserver }; if (!string.IsNullOrEmpty(probeId)) { newserverfarm.probeId = probeId; } Status status = await this._apiClient.PostAsync <NewServerFarm, Status>( ApiUris.CreateOrGetVipServerFarm(this._apiClient.OrganizationId, networkId), newserverfarm); return(status); }
/// <summary> /// Create a server farm from network VIP /// </summary> /// <param name="client"> /// The <see cref="IComputeApiClient"/> object. /// </param> /// <param name="networkId"> /// The network id /// </param> /// <param name="name"> /// The server farm name /// </param> /// <param name="predictor"> /// The server farm predictor /// </param> /// <param name="rServerId"> /// The first real server Id /// </param> /// <param name="rServerPort"> /// The first real server port /// </param> /// <param name="probeId"> /// The probe id /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public static async Task<Status> CreateServerFarm(this IComputeApiClient client, string networkId, string name, ServerFarmPredictorType predictor, string rServerId, int rServerPort = 0, string probeId = null) { var newserverfarm = new NewServerFarm { name = name, predictor = predictor, }; var realserver = new NewServerFarmRealServer {id = rServerId}; if (rServerPort > 0) realserver.port = rServerPort.ToString(CultureInfo.InvariantCulture); newserverfarm.realServer = new[] {realserver}; if (!string.IsNullOrEmpty(probeId)) newserverfarm.probeId = probeId; Status status = await client.WebApi.ApiPostAsync<NewServerFarm, Status>( ApiUris.CreateOrGetVipServerFarm(client.Account.OrganizationId, networkId), newserverfarm); return status; }