Delete Solr Config using Search Stax API
# "Please provide authentication information." | |
$uname = Read-Host -Prompt 'Username - ' | |
$password = Read-Host -AsSecureString -Prompt 'Password - ' | |
$password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($password)) | |
Write-Host "Asking for an authorization token for $uname..." | |
Write-Host | |
$body = @{ | |
username=$uname | |
password=$password | |
} | |
Remove-Variable PASSWORD | |
$body = $body | ConvertTo-Json | |
try { | |
$token = Invoke-RestMethod -uri "https://app.searchstax.com/api/rest/v2/obtain-auth-token/" -Method Post -Body $body -ContentType 'application/json' | |
$token = $token.token | |
Remove-Variable body | |
Write-Host "Obtained token" $token | |
Write-Host | |
$searchstaxUrl = 'https://app.searchstax.com' | |
$ACCOUNT = 'TODO' # <- CHANGE YOUR VALUE HERE | |
$uid = 'TODO' # <- CHANGE YOUR VALUE HERE | |
$NAME = 'sitecore_sitecore' # <- CHANGE YOUR VALUE HERE | |
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" | |
$headers.Add("Authorization", "Token $token") | |
#Delete Config | |
$RESULTS = Invoke-RestMethod -Method Delete -Headers $headers ` | |
-uri "https://app.searchstax.com/api/rest/v2/account/$ACCOUNT/deployment/$uid/zookeeper-config/$NAME/" | |
$RESULTS = $RESULTS | ConvertTo-Json | |
#return $token | |
} catch { | |
Write-Error -Message "Unable to get Auth Token. Error was: $_" -ErrorAction Stop | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment