Interface PrlDevopsApiClient
- All Known Implementing Classes:
PrlDevopsHttpClient
All three core operations needed by the Jenkins plugin are declared here. Callers should depend on this interface, not on the concrete HTTP implementation, so the client can be mocked in upstream unit tests.
Every method throws PrlApiException for:
- non-2xx HTTP responses (carries the status code and parsed error body), or
- low-level network failures.
-
Method Summary
Modifier and TypeMethodDescriptioncloneVm(String sourceVmId, CloneRequest request) Clones the VM identified bysourceVmId.createVmFromCatalog(CreateVmRequest request) Creates a new VM from a Parallels DevOps catalog entry.voidDeletes a VM.executeCommand(String vmId, ExecuteRequest request) Executes a command on a running VM.getVmStatus(String vmId) Returns the lightweight status of a VM.voidStarts a VM that is in thestoppedstate.waitForVmReady(String vmId, String vmUser, Duration timeout, Duration interval)
-
Method Details
-
cloneVm
Clones the VM identified bysourceVmId.Maps to
PUT /api/v1/machines/{sourceVmId}/clone(host mode) orPUT /api/v1/orchestrator/machines/{sourceVmId}/clone(orchestrator mode).- Parameters:
sourceVmId- ID of the VM to clone.request- Clone options (clone name, destination path); fields are optional.- Returns:
CloneResponsecontaining the new VM's ID.- Throws:
PrlApiException- on HTTP error or network failure.
-
createVmFromCatalog
Creates a new VM from a Parallels DevOps catalog entry.Maps to
POST /api/v1/machines(host mode) orPOST /api/v1/orchestrator/machines(orchestrator mode).The request includes
startOnCreate: trueso the VM boots immediately after creation. Callers must still pollwaitForVmReady(java.lang.String, java.lang.String, java.time.Duration, java.time.Duration)because the VM will be instoppedstate momentarily before transitioning torunning.- Parameters:
request- Catalog VM creation parameters.- Returns:
CreateVmResponsecontaining the new VM's ID.- Throws:
PrlApiException- on HTTP error or network failure.
-
getVmStatus
Returns the lightweight status of a VM.Maps to
GET /api/v1/machines/{vmId}/status(host mode) orGET /api/v1/orchestrator/machines/{vmId}/status(orchestrator mode).- Parameters:
vmId- ID of the VM to query.- Returns:
VmStatusResponsewithid,status, andip_configured.- Throws:
PrlApiException- on HTTP error or network failure.
-
startVm
Starts a VM that is in thestoppedstate.Maps to
GET /api/v1/machines/{vmId}/start(host mode) orGET /api/v1/orchestrator/machines/{vmId}/start(orchestrator mode).The API accepts the request and begins booting; the VM transitions through
stopped → starting → running. Callers must subsequently pollwaitForVmReady(java.lang.String, java.lang.String, java.time.Duration, java.time.Duration)to know when the VM is ready.- Parameters:
vmId- ID of the VM to start.- Throws:
PrlApiException- on HTTP error or network failure.
-
deleteVm
Deletes a VM.Maps to
DELETE /api/v1/machines/{vmId}?force=true(host mode) orDELETE /api/v1/orchestrator/machines/{vmId}?force=true(orchestrator mode). Theforce=trueparameter allows deletion of a running VM without stopping it first. The API returns202 Acceptedwith no body.- Parameters:
vmId- ID of the VM to delete.- Throws:
PrlApiException- on HTTP error or network failure.
-
waitForVmReady
VmStatusResponse waitForVmReady(String vmId, String vmUser, Duration timeout, Duration interval) throws PrlApiException, PrlApiTimeoutException - Parameters:
vmUser- OS user used for the execute-API readiness probe.- Throws:
PrlApiExceptionPrlApiTimeoutException
-
executeCommand
Executes a command on a running VM.Maps to
PUT /api/v1/machines/{vmId}/execute(host mode) orPUT /api/v1/orchestrator/machines/{vmId}/execute(orchestrator mode).- Parameters:
vmId- ID of the VM to run the command on.request- Command, user, and environment variables.- Returns:
ExecuteResponsewith stdout and exit code.- Throws:
PrlApiException- on HTTP error or network failure.
-