/// <summary> /// Edits an ip address list. /// </summary> /// <param name="editIpAddressList">The ip address list details.</param> /// <returns>The response details.</returns> public async Task <ResponseType> EditIpAddressList(editIpAddressList editIpAddressList) { if (editIpAddressList.childIpAddressListIdSpecified && (editIpAddressList.childIpAddressListId == null || editIpAddressList.childIpAddressListId.Length == 0)) { editIpAddressList.childIpAddressListId = new string[] { null }; } if (editIpAddressList.ipAddressSpecified && (editIpAddressList.ipAddress == null || editIpAddressList.ipAddress.Length == 0)) { editIpAddressList.ipAddress = new editIpAddressListIpAddress[] { null }; } if (!string.IsNullOrWhiteSpace(editIpAddressList.description)) { editIpAddressList.descriptionSpecified = true; } return(await _api.PostAsync <editIpAddressList, ResponseType>( ApiUris.EditIpAddressList(_api.OrganizationId), editIpAddressList)); }
/// <summary> /// The process record method. /// </summary> protected override void ProcessRecord() { ResponseType response = null; base.ProcessRecord(); try { if (IpAddressList != null) { Id = Guid.Parse(IpAddressList.id); } var addresses = new editIpAddressListIpAddress[0]; if (IpAddress != null) { addresses = IpAddress.Select( x => new editIpAddressListIpAddress { begin = x.Begin, end = x.End, prefixSize = x.PrefixSize ?? 0, prefixSizeSpecified = x.PrefixSize.HasValue }).ToArray(); } if (ChildIpAddressList != null && ChildIpAddressList.Length > 0) { ChildIpAddressListId = ChildIpAddressList.Select(x => x.id).ToArray(); } var editIpAddressList = new editIpAddressList { id = Id.ToString(), description = _description, descriptionSpecified = _descriptionSpecified, childIpAddressListId = ChildIpAddressListId, childIpAddressListIdSpecified = _childIpAddressListIdSpecified, ipAddress = addresses.Length > 0 ? addresses : null, ipAddressSpecified = addresses.Length > 0 }; response = Connection.ApiClient.Networking.FirewallRule.EditIpAddressList(editIpAddressList).Result; } catch (AggregateException ae) { ae.Handle( e => { if (e is ComputeApiException) { WriteError(new ErrorRecord(e, "-2", ErrorCategory.InvalidOperation, Connection)); } else { // if (e is HttpRequestException) ThrowTerminatingError(new ErrorRecord(e, "-1", ErrorCategory.ConnectionError, Connection)); } return(true); }); } WriteObject(response); }