mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-14 02:12:28 +00:00
Add TimeoutSeconds parameter and logic to Connect-NetboxAPI
- Updated `InvokeNetboxRequest` to use `NetboxConfig.Timeout` - Updated `Get-NetboxAPIDefinition` to use `NetboxConfig.Timeout`
This commit is contained in:
parent
802ab317f6
commit
22607fde48
3 changed files with 44 additions and 33 deletions
|
|
@ -24,8 +24,8 @@ function InvokeNetboxRequest {
|
||||||
|
|
||||||
[pscustomobject]$Body = $null,
|
[pscustomobject]$Body = $null,
|
||||||
|
|
||||||
[ValidateRange(0, 60)]
|
[ValidateRange(1, 65535)]
|
||||||
[uint16]$Timeout = 5,
|
[uint16]$Timeout = (Get-NetboxTimeout),
|
||||||
|
|
||||||
[ValidateSet('GET', 'PATCH', 'PUT', 'POST', 'DELETE', 'OPTIONS', IgnoreCase = $true)]
|
[ValidateSet('GET', 'PATCH', 'PUT', 'POST', 'DELETE', 'OPTIONS', IgnoreCase = $true)]
|
||||||
[string]$Method = 'GET',
|
[string]$Method = 'GET',
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,12 @@
|
||||||
.PARAMETER URI
|
.PARAMETER URI
|
||||||
The full URI for the resource such as "https://netbox.domain.com:8443"
|
The full URI for the resource such as "https://netbox.domain.com:8443"
|
||||||
|
|
||||||
|
.PARAMETER SkipCertificateCheck
|
||||||
|
A description of the SkipCertificateCheck parameter.
|
||||||
|
|
||||||
|
.PARAMETER TimeoutSeconds
|
||||||
|
The number of seconds before the HTTP call times out. Defaults to 30 seconds
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Connect-NetboxAPI -Hostname "netbox.domain.com"
|
PS C:\> Connect-NetboxAPI -Hostname "netbox.domain.com"
|
||||||
|
|
||||||
|
|
@ -52,7 +58,11 @@
|
||||||
[string]$URI,
|
[string]$URI,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[switch]$SkipCertificateCheck = $false
|
[switch]$SkipCertificateCheck = $false,
|
||||||
|
|
||||||
|
[ValidateNotNullOrEmpty()]
|
||||||
|
[ValidateRange(1, 65535)]
|
||||||
|
[uint16]$TimeoutSeconds = 30
|
||||||
)
|
)
|
||||||
|
|
||||||
if (-not $Credential) {
|
if (-not $Credential) {
|
||||||
|
|
@ -101,6 +111,7 @@
|
||||||
$null = Set-NetboxHostScheme -Scheme $uriBuilder.Scheme
|
$null = Set-NetboxHostScheme -Scheme $uriBuilder.Scheme
|
||||||
$null = Set-NetboxHostPort -Port $uriBuilder.Port
|
$null = Set-NetboxHostPort -Port $uriBuilder.Port
|
||||||
$null = Set-NetboxInvokeParams -invokeParams $invokeParams
|
$null = Set-NetboxInvokeParams -invokeParams $invokeParams
|
||||||
|
$null = Set-NetboxTimeout -TimeoutSeconds $TimeoutSeconds
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Write-Verbose "Verifying API connectivity..."
|
Write-Verbose "Verifying API connectivity..."
|
||||||
|
|
|
||||||
|
|
@ -25,5 +25,5 @@ function Get-NetboxAPIDefinition {
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters -SkipConnectedCheck
|
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters -SkipConnectedCheck
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Timeout 10
|
InvokeNetboxRequest -URI $URI
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue