Classes/Public/MoveSession.ps1
|
class MoveSession { ## A Name parameter to identify the session in other -MoveSessions functions [String]$Name # Move Server hostname [string]$MoveServer # Move Server hostname port [int]$MovePort # MoveVersion drives the selection of compatible APIs to use [string]$MoveVersion # Logged in Move User's Context (indicates loggedin-ness) [pscustomobject]$UserContext # Logged in user credential, used to refresh the session as Nutanix Move does not provide a refresh token [pscredential]$MoveSessionRefreshData # Token Expiry Date from Status.ExpiryDate API login response [datetime]$ExpirationDate # MoveWebSession Variable. Maintained by the Invoke-WebRequest function's capability $MoveWebSession ## Tracks non-changing items to reduce HTTP lookups, and increase speed of scripts. ## DataCache is expected to be a k/v pair, where the V could be another k/v pair, ## However, it's implementation will be more of the nature to hold the list of object calls from the API ## like 'credentials' = @(@{...},@{...}); 'actions' = @(@{...},@{...}) ## Get-Move* functions will cache unless a -NoCache switch is provided [hashtable]$DataCache ## Should PowerShell ignore the SSL Cert on the Move Server? [bool]$AllowInsecureSSL MoveSession() { $this.Name = 'Default' $this.AllowInsecureSSL = $false $this.DataCache = @{} $this.UserContext = $null $this.MovePort = 9669 $this.MoveWebSession = New-Object -Type Microsoft.PowerShell.Commands.WebRequestSession } MoveSession([String]$_name = 'Default') { $this.Name = $_name $this.AllowInsecureSSL = $false $this.DataCache = @{} $this.UserContext = $null $this.MovePort = 9669 $this.MoveWebSession = New-Object -Type Microsoft.PowerShell.Commands.WebRequestSession } MoveSession([String]$_name = 'Default', [String]$_server, [Bool]$_allowInsecureSSL = $false) { $this.Name = $_name $this.AllowInsecureSSL = $_allowInsecureSSL $this.MoveServer = $_server $this.MovePort = 443 $this.DataCache = @{} $this.UserContext = $null $this.MoveWebSession = New-Object -Type Microsoft.PowerShell.Commands.WebRequestSession } MoveSession([String]$_name = 'Default', [String]$_server, [int]$_port, [Bool]$_allowInsecureSSL = $false) { $this.Name = $_name $this.AllowInsecureSSL = $_allowInsecureSSL $this.MoveServer = $_server $this.MovePort = $_port $this.DataCache = @{} $this.UserContext = $null $this.MoveWebSession = New-Object -Type Microsoft.PowerShell.Commands.WebRequestSession } } |