Created
September 22, 2024 04:33
-
-
Save Calvindd2f/6539f82c374704b9c9022e78ef25e4ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #region Constants | |
| ################################# Define all constants here ################################### | |
| $DefaultHTTPTimeout = 960 #16 minutes, 1 minute more than server timeout so we don't timeout before the server. | |
| $DefaultMaxRetryTimes = 5 # In total we try 6 times. 1 original try, 5 retry attempts. | |
| $DefaultRetryIntervalInMilliSeconds = 2000 | |
| $DefaultRetryIntervalExponentBase = 2 | |
| $DefaultPageSize = 1000 | |
| $RetryableHTTPResponses = @([System.Net.HttpStatusCode]::Unauthorized, [System.Net.HttpStatusCode]::ServiceUnavailable, [System.Net.HttpStatusCode]::GatewayTimeout) | |
| $StringsForBooleanParsing = @('$true', '($true)', '$true)', '$false', '($false)', '$false)') | |
| ################################################################################################ | |
| #endregion | |
| #region Global variables | |
| ################################################################################################ | |
| function ShouldUse-EnvironmentVariableForAPIByDefault | |
| { | |
| if ($env:XI_API_KEY) | |
| { return $false } | |
| elseif ($XI_API_KEY) | |
| { | |
| $env:XI_API_KEY = $XI_API_KEY | |
| } | |
| else | |
| { return $true } | |
| } | |
| ################################################################################################ | |
| #endregion | |
| #region Constant Functions | |
| ################################################################################################ | |
| function const([string]$Name, [string]$Value) | |
| { | |
| New-Variable -Name $Name -Value $Value -Option Constant -Force -Scope Script | |
| } | |
| function print([string]$InputObject) | |
| { | |
| [console]::writeline([string]$InputObject) | |
| } | |
| ################################################################################################ | |
| #endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment