Refactor IPAM model classes to use records for Address, Subnetwork, Vlan, Vrf, Section, Tag, Domain, Nameserver, and Session; enhance documentation and implement value equality for records.
This commit is contained in:
@@ -1,20 +1,24 @@
|
||||
namespace PS.IPAM.Cmdlets;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Management.Automation;
|
||||
using PS.IPAM;
|
||||
using PS.IPAM.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves L2 domain information from phpIPAM.
|
||||
/// </summary>
|
||||
[Cmdlet(VerbsCommon.Get, "L2Domain", DefaultParameterSetName = "ByID")]
|
||||
[OutputType(typeof(Domain))]
|
||||
public class GetL2DomainCmdlet : PSCmdlet
|
||||
public class GetL2DomainCmdlet : BaseCmdlet
|
||||
{
|
||||
[Parameter(
|
||||
Mandatory = false,
|
||||
ValueFromPipeline = true,
|
||||
ValueFromPipelineByPropertyName = true,
|
||||
Position = 0,
|
||||
ParameterSetName = "ByID")]
|
||||
ParameterSetName = "ByID",
|
||||
HelpMessage = "The L2 domain ID.")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public int? Id { get; set; }
|
||||
|
||||
@@ -23,28 +27,18 @@ public class GetL2DomainCmdlet : PSCmdlet
|
||||
try
|
||||
{
|
||||
var identifiers = new List<string>();
|
||||
|
||||
if (Id.HasValue)
|
||||
{
|
||||
identifiers.Add(Id.Value.ToString());
|
||||
}
|
||||
|
||||
var result = RequestHelper.InvokeRequest("GET", controllers.l2domains, types.Domain, null, null, identifiers.Count > 0 ? identifiers.ToArray() : null)
|
||||
.GetAwaiter().GetResult();
|
||||
var result = RequestHelper.InvokeRequest(
|
||||
"GET", ApiController.L2Domains, ModelType.Domain, null, null,
|
||||
identifiers.Count > 0 ? identifiers.ToArray() : null
|
||||
).GetAwaiter().GetResult();
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
if (result is System.Collections.IEnumerable enumerable && !(result is string))
|
||||
{
|
||||
foreach (var item in enumerable)
|
||||
{
|
||||
WriteObject(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteObject(result);
|
||||
}
|
||||
}
|
||||
WriteResult(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user