Added assembly name and root namespace to project file; updated session and vlan classes with new properties; modified module manifest to reference DLL and updated exported cmdlets; corrected property name in address class.
This commit is contained in:
43
classlib/Cmdlets/AssignTagCmdlet.cs
Normal file
43
classlib/Cmdlets/AssignTagCmdlet.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
namespace PS.IPAM.Cmdlets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Management.Automation;
|
||||
using PS.IPAM;
|
||||
using PS.IPAM.Helpers;
|
||||
|
||||
[Cmdlet("Assign", "Tag")]
|
||||
public class AssignTagCmdlet : PSCmdlet
|
||||
{
|
||||
[Parameter(
|
||||
Mandatory = true,
|
||||
ValueFromPipeline = true,
|
||||
ValueFromPipelineByPropertyName = true,
|
||||
Position = 0)]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public Address? AddressObject { get; set; }
|
||||
|
||||
[Parameter(
|
||||
Mandatory = true,
|
||||
Position = 1)]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public Tag? Tag { get; set; }
|
||||
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
try
|
||||
{
|
||||
var identifiers = new List<string> { AddressObject!.Id.ToString() };
|
||||
var body = new Dictionary<string, object>
|
||||
{
|
||||
{ "tag", Tag!.Id }
|
||||
};
|
||||
|
||||
RequestHelper.InvokeRequest("PATCH", controllers.addresses, null, null, body, identifiers.ToArray())
|
||||
.GetAwaiter().GetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteError(new ErrorRecord(ex, "AssignTagError", ErrorCategory.InvalidOperation, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user