@@ -156,21 +156,7 @@ function global:Connect-SGWServer {
156156}
157157"@
158158
159- # determine StorageGRID Version
160- Try {
161- $Response = Invoke-RestMethod - Method GET - Uri " https://$Name /api/versions" - TimeoutSec 10 - ContentType " application/json"
162- $APIVersion = $Response.APIVersion -split " \." | select - first 1
163- }
164- Catch {
165- $ResponseBody = ParseExceptionBody $_.Exception.Response
166- if ($ResponseBody -match " apiVersion" ) {
167- $APIVersion = ($ResponseBody | ConvertFrom-Json ).APIVersion -split " \." | select - first 1
168- }
169- elseif ($_.Exception.Message -match " trust relationship" ) {
170- Write-Error $_.Exception.Message
171- Write-Information " Certificate of the server is not trusted. Use --insecure switch if you want to skip certificate verification."
172- }
173- }
159+ $APIVersion = (Get-SGWVersions - Uri " https://$Name " | Sort | select - Last 1 ) -replace " \..*" , " "
174160
175161 if (! $APIVersion ) {
176162 Write-Error " API Version could not be retrieved via https://$Name /api/versions"
@@ -927,6 +913,139 @@ function Global:Get-SGWTopologyHealth {
927913
928914# # config ##
929915
916+ <#
917+ . SYNOPSIS
918+ Retrieves global configuration and token information
919+ . DESCRIPTION
920+ Retrieves global configuration and token information
921+ #>
922+ function Global :Get-SGWConfig {
923+ [CmdletBinding ()]
924+
925+ PARAM (
926+ [parameter (Mandatory = $False ,
927+ Position = 0 ,
928+ HelpMessage = " StorageGRID Webscale Management Server object. If not specified, global CurrentSGWServer object will be used." )][PSCustomObject ]$Server
929+ )
930+
931+ Begin {
932+ if (! $Server ) {
933+ $Server = $Global :CurrentSGWServer
934+ }
935+ if (! $Server ) {
936+ Throw " No StorageGRID Webscale Management Server management server found. Please run Connect-SGWServer to continue."
937+ }
938+ }
939+
940+ Process {
941+ $Uri = $Server.BaseURI + " /grid/config"
942+ $Method = " GET"
943+
944+ try {
945+ $Result = Invoke-RestMethod - WebSession $Server.Session - Method $Method - Uri $Uri - Headers $Server.Headers
946+ }
947+ catch {
948+ $ResponseBody = ParseExceptionBody $_.Exception.Response
949+ Write-Error " $Method to $Uri failed with Exception $ ( $_.Exception.Message ) `n $responseBody "
950+ }
951+
952+ Write-Output $Result.data
953+ }
954+ }
955+
956+ <#
957+ . SYNOPSIS
958+ Changes the global management API and UI configuration
959+ . DESCRIPTION
960+ Changes the global management API and UI configuration
961+ #>
962+ function Global :Update-SGWConfigManagement {
963+ [CmdletBinding ()]
964+
965+ PARAM (
966+ [parameter (Mandatory = $True ,
967+ Position = 0 ,
968+ HelpMessage = " Minimum API Version." )][Int ][ValidateSet (1 , 2 )]$MinApiVersion ,
969+ [parameter (Mandatory = $False ,
970+ Position = 1 ,
971+ HelpMessage = " StorageGRID Webscale Management Server object. If not specified, global CurrentSGWServer object will be used." )][PSCustomObject ]$Server
972+ )
973+
974+
975+ Begin {
976+ if (! $Server ) {
977+ $Server = $Global :CurrentSGWServer
978+ }
979+ if (! $Server ) {
980+ Throw " No StorageGRID Webscale Management Server management server found. Please run Connect-SGWServer to continue."
981+ }
982+ if ($Server.APIVersion -lt 2 ) {
983+ Throw " Cmdlet not supported on server with API Version less than 2.0"
984+ }
985+ }
986+
987+ Process {
988+ $Uri = $Server.BaseURI + " /grid/config/management"
989+ $Method = " PUT"
990+
991+ $Body = @ {minApiVersion = $MinApiVersion } | ConvertTo-Json
992+ Write-Verbose " Body: $Body "
993+
994+ try {
995+ $Result = Invoke-RestMethod - WebSession $Server.Session - Method $Method - Uri $Uri - Headers $Server.Headers - Body $Body
996+ }
997+ catch {
998+ $ResponseBody = ParseExceptionBody $_.Exception.Response
999+ Write-Error " $Method to $Uri failed with Exception $ ( $_.Exception.Message ) `n $responseBody "
1000+ }
1001+
1002+ Write-Output $Result.data
1003+ }
1004+ }
1005+
1006+ <#
1007+ . SYNOPSIS
1008+ Retrieves the global management API and UI configuration
1009+ . DESCRIPTION
1010+ Retrieves the global management API and UI configuration
1011+ #>
1012+ function Global :Get-SGWConfigManagement {
1013+ [CmdletBinding ()]
1014+
1015+ PARAM (
1016+ [parameter (Mandatory = $False ,
1017+ Position = 0 ,
1018+ HelpMessage = " StorageGRID Webscale Management Server object. If not specified, global CurrentSGWServer object will be used." )][PSCustomObject ]$Server
1019+ )
1020+
1021+ Begin {
1022+ if (! $Server ) {
1023+ $Server = $Global :CurrentSGWServer
1024+ }
1025+ if (! $Server ) {
1026+ Throw " No StorageGRID Webscale Management Server management server found. Please run Connect-SGWServer to continue."
1027+ }
1028+ if ($Server.APIVersion -lt 2 ) {
1029+ Throw " Cmdlet not supported on server with API Version less than 2.0"
1030+ }
1031+ }
1032+
1033+ Process {
1034+ $Uri = $Server.BaseURI + " /grid/config/management"
1035+ $Method = " GET"
1036+
1037+ try {
1038+ $Result = Invoke-RestMethod - WebSession $Server.Session - Method $Method - Uri $Uri - Headers $Server.Headers
1039+ }
1040+ catch {
1041+ $ResponseBody = ParseExceptionBody $_.Exception.Response
1042+ Write-Error " $Method to $Uri failed with Exception $ ( $_.Exception.Message ) `n $responseBody "
1043+ }
1044+
1045+ Write-Output $Result.data
1046+ }
1047+ }
1048+
9301049<#
9311050 . SYNOPSIS
9321051 Retrieve StorageGRID Product Version
@@ -967,6 +1086,59 @@ function Global:Get-SGWProductVersion {
9671086 }
9681087}
9691088
1089+ <#
1090+ . SYNOPSIS
1091+ Retrieves the major versions of the management API supported by the product release
1092+ . DESCRIPTION
1093+ Retrieves the major versions of the management API supported by the product release
1094+ #>
1095+ function Global :Get-SGWVersions {
1096+ [CmdletBinding ()]
1097+
1098+ PARAM (
1099+ [parameter (Mandatory = $False ,
1100+ Position = 0 ,
1101+ HelpMessage = " StorageGRID Webscale Management Server object. If not specified, global CurrentSGWServer object will be used." )][PSCustomObject ]$Server ,
1102+ [parameter (Mandatory = $False ,
1103+ Position = 1 ,
1104+ HelpMessage = " Uri of the StorageGRID Server" )][String ]$Uri
1105+ )
1106+
1107+ Begin {
1108+ if ($Uri ) {
1109+ $Server = @ {BaseURI = " $Uri /api/v2" ;APIVersion = 2 }
1110+ }
1111+ if (! $Server ) {
1112+ $Server = $Global :CurrentSGWServer
1113+ }
1114+ if (! $Server ) {
1115+ Throw " No StorageGRID Webscale Management Server management server found. Please run Connect-SGWServer to continue."
1116+ }
1117+ }
1118+
1119+ Process {
1120+ $Uri = $Server.BaseURI + " /versions"
1121+ $Method = " GET"
1122+
1123+ Try {
1124+ $Response = Invoke-RestMethod - WebSession $Server.Session - Method $Method - Uri $Uri - Headers $Server.Headers
1125+ $APIVersions = $Response.APIVersion
1126+ }
1127+ Catch {
1128+ $ResponseBody = ParseExceptionBody $_.Exception.Response
1129+ if ($ResponseBody -match " apiVersion" ) {
1130+ $APIVersions = ($ResponseBody | ConvertFrom-Json ).APIVersion
1131+ }
1132+ elseif ($_.Exception.Message -match " trust relationship" ) {
1133+ Write-Error $_.Exception.Message
1134+ Write-Information " Certificate of the server is not trusted. Use --insecure switch if you want to skip certificate verification."
1135+ }
1136+ }
1137+
1138+ Write-Output $APIVersions
1139+ }
1140+ }
1141+
9701142# # dns-servers ##
9711143
9721144<#
0 commit comments