Private/Assert-RyverApiConfig.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
function Assert-RyverApiConfig { <# .SYNOPSIS Validates the PSRyver REST API configuration. .DESCRIPTION Validates that the $Script:PSPRyver.RestApiBaseUri and $Script:PSPRyver.Authorization values are set to valid specifications, and throws terminating errors if not. .INPUTS None You cannot pipe input to this cmdlet. .NOTES - Troy Lindsay - Twitter: @troylindsay42 - GitHub: tlindsay42 .EXAMPLE Assert-RyverApiConfig Validates that the $Script:PSPRyver.RestApiBaseUri and $Script:PSPRyver.Authorization values are set to valid specifications, and throws terminating errors if not. .LINK https://tlindsay42.github.io/PSRyver/Private/Assert-RyverApiConfig/ .LINK https://github.com/tlindsay42/PSRyver/blob/master/PSRyver/Private/Assert-RyverApiConfig.ps1 .FUNCTIONALITY Ryver #> [CmdletBinding( HelpUri = 'https://tlindsay42.github.io/PSRyver/Private/Assert-RyverApiConfig/' )] [OutputType( [Void] )] param () begin { $function = $MyInvocation.MyCommand.Name Write-Verbose -Message "Beginning: '${function}'." } process { Write-Verbose -Message ( "Processing: '${function}' with ParameterSetName '$( $PSCmdlet.ParameterSetName )' and Parameters: " + ( $PSBoundParameters | Remove-SensitiveData | Format-Table -AutoSize | Out-String ) ) if ( $Script:PSRyver.RestApiBaseUri -notmatch '^https://\w+.ryver.com(?::443)?/api/1/odata.svc$' ) { throw "Invalid PSRyver RestApiBaseUri config value: '$( $Script:PSRyver.RestApiBaseUri )'. Please run 'Set-PSRyverConfig -RestApiBaseUri `$uri'." } if ( $Script:PSRyver.Authorization -notmatch '^Basic \S+$' ) { throw "Invalid PSRyver Authorization config value: '$( $Script:PSRyver.Authorization )'. Please run 'Set-PSRyverConfig -Credential ( Get-Credential )'." } } end { Write-Verbose -Message "Ending: '${function}'." } } |