Isard.ps1
# https://gitlab.com/isard/isardvdi/-/tree/main/api/src/api/schemas function Connect-Isard { param( [switch] $Web ) if ($Web) { Start-Process "https://pilotfp.gencat.isardvdi.com" exit } $token = Get-IsardToken #Write-Host $token # TODO authorization cookie $response = Invoke-WebRequest -Uri "https://pilotfp.gencat.isardvdi.com/api/v3/desktop/start/ba4d3752-7dd5-49e2-8fd9-b237eaeea4f5" $data = $response.Content | ConvertFrom-Json Write-Host $data } function New-Isard { $api = Invoke-RestMethod -Uri https://pilotfp.gencat.isardvdi.com/api/v3/user Write-Host $api } ##### Private # https://gitlab.com/isard/isardvdi/-/blob/main/api/src/api/views/AuthenticationView.py function Get-IsardToken { $tokenFile = Get-IsardPath -Name token if (Test-Path $tokenFile) { return (Get-Content $tokenFile) } $username = Read-Host "Username" $password = Read-Host "Password" -AsSecureString $password = (New-Object PSCredential 0, $password).GetNetworkCredential().Password $result = curl.exe -s -F username=$username -F password=$password "https://pilotfp.gencat.isardvdi.com/authentication/login?provider=form&category_id=db79b78a-5408-4ff9-9853-a1172b7eadb2" # TODO check token lenght match, better solution if ($result.StartsWith("invalid")) { Write-host -ForegroundColor red $result exit } $result | Out-File $tokenFile return $result } function Get-IsardPath { param( [string] $Name ) $path = Get-BoxPath -Path "isard" if ($Name) { $path = Join-Path $path $Name } return $path } |