/// <summary> /// The process record method. /// </summary> protected override void ProcessRecord() { ResponseType response = null; base.ProcessRecord(); try { if (NetworkDomain != null) { NetworkDomainId = NetworkDomain.id; } if (ChildIpAddressList != null && ChildIpAddressList.Length > 0) { ChildIpAddressListId = ChildIpAddressList.Select(x => x.id).ToArray(); } var ipAddressList = new createIpAddressList { networkDomainId = NetworkDomainId, name = Name, description = Description, ipVersion = IpVersion.ToString(), childIpAddressListId = ChildIpAddressListId, ipAddress = IpAddress != null ? IpAddress.Select(x => new IpAddressRangeType { begin = x.Begin, end = x.End, prefixSize = x.PrefixSize ?? 0, prefixSizeSpecified = x.PrefixSize.HasValue }).ToArray() : null, }; response = Connection.ApiClient.Networking.FirewallRule.CreateIpAddressList(ipAddressList).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); }
/// <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); }