agent: logicalName to queryparams instead of path

This commit is contained in:
Aaron Greenspan
2021-01-12 14:57:09 -07:00
committed by Aiden McClelland
parent 4da4fd66a3
commit c25295500b
3 changed files with 14 additions and 6 deletions

View File

@@ -37,8 +37,7 @@
/v0/apps/#AppId/backup/restore RestoreBackupR POST
/v0/apps/#AppId/autoconfig/#AppId AutoconfigureR POST
/v0/disks ListDisksR GET
/v0/disks/#Text EjectDiskR DELETE
/v0/disks DisksR GET DELETE
/v0/update UpdateAgentR POST
/v0/wifi WifiR GET POST

View File

@@ -95,11 +95,17 @@ postRestoreBackupR appId = disableEndpointOnFailedUpdate $ do
& handleS9ErrC
& runM
getListDisksR :: Handler (JSONResponse [AppMgr.DiskInfo])
getListDisksR = fmap JSONResponse . runM . handleS9ErrC $ listDisksLogic
getDisksR :: Handler (JSONResponse [AppMgr.DiskInfo])
getDisksR = fmap JSONResponse . runM . handleS9ErrC $ listDisksLogic
deleteEjectDiskR :: Text -> Handler ()
deleteEjectDiskR t = runM . handleS9ErrC $ ejectDiskLogic t
deleteDisksR :: Handler ()
deleteDisksR = handleS9ErrT $ do
logicalName <- lookupGetParam "logicalName" >>= orThrow400
runM . handleS9ErrC $ ejectDiskLogic logicalName
where
orThrow400 = \case
Nothing -> throwE $ ParamsE "logicalName"
Just p -> pure p
-- Logic

View File

@@ -52,6 +52,7 @@ data S9Error =
| WifiOrphaningE
| NoPasswordExistsE
| HostsParamsE Text
| ParamsE Text
| MissingFileE SystemPath
| ClientCryptographyE Text
| TTLExpirationE Text
@@ -138,6 +139,7 @@ toError = \case
TTLExpirationE desc -> ErrorResponse REGISTRATION_ERROR [i|TTL Expiration failure: #{desc}|]
EnvironmentValE appId -> ErrorResponse SYNCHRONIZATION_ERROR [i|Could not read environment values for #{appId}|]
HostsParamsE key -> ErrorResponse REGISTRATION_ERROR [i|Missing or invalid parameter #{key}|]
ParamsE key -> ErrorResponse INVALID_REQUEST [i|Missing or invalid parameter #{key}|]
InternalE msg -> ErrorResponse INTERNAL_ERROR msg
BackupE appId reason -> ErrorResponse BACKUP_ERROR [i|Backup failed for #{appId}: #{reason}|]
BackupPassInvalidE -> ErrorResponse BACKUP_ERROR [i|Password provided for backups is invalid|]
@@ -242,6 +244,7 @@ toStatus = \case
TTLExpirationE _ -> status403
EnvironmentValE _ -> status500
HostsParamsE _ -> status400
ParamsE _ -> status400
BackupE _ _ -> status500
BackupPassInvalidE -> status403
InternalE _ -> status500