Class PrlDevopsHttpClient
- All Implemented Interfaces:
PrlDevopsApiClient
HttpClient-based implementation of PrlDevopsApiClient.
Construct via PrlDevopsHttpClient.Builder:
PrlDevopsApiClient client = new PrlDevopsHttpClient.Builder()
.baseUrl("https://my-host:8080")
.bearerToken("secret-token")
.mode(ConnectionMode.HOST)
.build();
For orchestrator mode, no hostId is needed — the orchestrator
routes requests to the appropriate host internally:
PrlDevopsApiClient client = new PrlDevopsHttpClient.Builder()
.baseUrl("https://orchestrator:8080")
.bearerToken("secret-token")
.mode(ConnectionMode.ORCHESTRATOR)
.build();
Thread-safe: a single instance may be shared across threads.
-
Nested Class Summary
Nested Classes -
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
Description copied from interface:PrlDevopsApiClientClones the VM identified bysourceVmId.Maps to
PUT /api/v1/machines/{sourceVmId}/clone(host mode) orPUT /api/v1/orchestrator/machines/{sourceVmId}/clone(orchestrator mode).- Specified by:
cloneVmin interfacePrlDevopsApiClient- 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
Description copied from interface:PrlDevopsApiClientCreates 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 pollPrlDevopsApiClient.waitForVmReady(java.lang.String, java.lang.String, java.time.Duration, java.time.Duration)because the VM will be instoppedstate momentarily before transitioning torunning.- Specified by:
createVmFromCatalogin interfacePrlDevopsApiClient- Parameters:
request- Catalog VM creation parameters.- Returns:
CreateVmResponsecontaining the new VM's ID.- Throws:
PrlApiException- on HTTP error or network failure.
-
getVmStatus
Description copied from interface:PrlDevopsApiClientReturns 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).- Specified by:
getVmStatusin interfacePrlDevopsApiClient- Parameters:
vmId- ID of the VM to query.- Returns:
VmStatusResponsewithid,status, andip_configured.- Throws:
PrlApiException- on HTTP error or network failure.
-
startVm
Description copied from interface:PrlDevopsApiClientStarts 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 pollPrlDevopsApiClient.waitForVmReady(java.lang.String, java.lang.String, java.time.Duration, java.time.Duration)to know when the VM is ready.- Specified by:
startVmin interfacePrlDevopsApiClient- Parameters:
vmId- ID of the VM to start.- Throws:
PrlApiException- on HTTP error or network failure.
-
deleteVm
Description copied from interface:PrlDevopsApiClientDeletes 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.- Specified by:
deleteVmin interfacePrlDevopsApiClient- Parameters:
vmId- ID of the VM to delete.- Throws:
PrlApiException- on HTTP error or network failure.
-
executeCommand
Description copied from interface:PrlDevopsApiClientExecutes 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).- Specified by:
executeCommandin interfacePrlDevopsApiClient- 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.
-
waitForVmReady
public VmStatusResponse waitForVmReady(String vmId, String vmUser, Duration timeout, Duration interval) throws PrlApiException, PrlApiTimeoutException - Specified by:
waitForVmReadyin interfacePrlDevopsApiClient- Parameters:
vmUser- OS user used for the execute-API readiness probe.- Throws:
PrlApiExceptionPrlApiTimeoutException
-