diff --git a/PSSailpoint/Configuration.ps1 b/PSSailpoint/Configuration.ps1 index fd38a6dd1..e4432a822 100644 --- a/PSSailpoint/Configuration.ps1 +++ b/PSSailpoint/Configuration.ps1 @@ -66,6 +66,14 @@ function Get-DefaultConfiguration { $Configuration["Experimental"] = $false } + if (!$Configuration.containsKey("ConsumerIdentifier")) { + $Configuration["ConsumerIdentifier"] = $null + } + + if (!$Configuration.containsKey("ConsumerVersion")) { + $Configuration["ConsumerVersion"] = $null + } + Return $Configuration } @@ -134,6 +142,8 @@ function Set-DefaultConfiguration { [System.Nullable[Int32]]$RetryIntervalSeconds, [System.Nullable[Boolean]]$Experimental, [System.Object]$Proxy, + [string]$ConsumerIdentifier, + [string]$ConsumerVersion, [switch]$PassThru ) @@ -184,6 +194,14 @@ function Set-DefaultConfiguration { $Script:Configuration['Experimental'] = $Experimental } + If ($ConsumerIdentifier) { + $Script:Configuration['ConsumerIdentifier'] = $ConsumerIdentifier + } + + If ($ConsumerVersion) { + $Script:Configuration['ConsumerVersion'] = $ConsumerVersion + } + If ($null -ne $Proxy) { If ($Proxy.GetType().FullName -ne "System.Net.SystemWebProxy" -and $Proxy.GetType().FullName -ne "System.Net.WebProxy" -and $Proxy.GetType().FullName -ne "System.Net.WebRequest+WebProxyWrapperOpaque") { throw "Incorrect Proxy type '$($Proxy.GetType().FullName)'. Must be System.Net.WebProxy or System.Net.SystemWebProxy or System.Net.WebRequest+WebProxyWrapperOpaque." diff --git a/sdk-resources/resources/api_client.mustache b/sdk-resources/resources/api_client.mustache index 7fdd0c7a7..134bfac1a 100644 --- a/sdk-resources/resources/api_client.mustache +++ b/sdk-resources/resources/api_client.mustache @@ -75,9 +75,15 @@ function Invoke-{{{apiNamePrefix}}}ApiClient { break } - # Add Custom Header - $HeaderParameters['X-SailPoint-SDK'] = "Powershell-{{packageVersion}}" - $HeaderParameters['User-Agent'] = "OpenAPI-Generator/{{{packageVersion}}}/ps" + # Build User-Agent header + $UserAgent = "SailPoint-SDK-PowerShell/{{{packageVersion}}}" + if ($Configuration["ConsumerIdentifier"] -and $Configuration["ConsumerVersion"]) { + $UserAgent = "$UserAgent ($($Configuration["ConsumerIdentifier"])/$($Configuration["ConsumerVersion"]))" + } + if ($IsWindows) { $OSPlatform = "windows" } elseif ($IsLinux) { $OSPlatform = "linux" } elseif ($IsMacOS) { $OSPlatform = "darwin" } else { $OSPlatform = "unknown" } + $OSArch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLower() + $UserAgent = "$UserAgent ($OSPlatform; $OSArch) PowerShell/$($PSVersionTable.PSVersion.ToString()) (openapi-generator/{{generatorVersion}})" + $HeaderParameters['User-Agent'] = $UserAgent $HasFormData = $False