Search in sources :

Example 1 with GetReservedWorker

use of org.datatransferproject.types.client.transfer.GetReservedWorker in project data-transfer-project by google.

the class GetReservedWorkerAction method handle.

@Override
public ReservedWorker handle(GetReservedWorker workerRequest) {
    String id = workerRequest.getId();
    UUID jobId = decodeJobId(id);
    PortabilityJob job = jobStore.findJob(jobId);
    Preconditions.checkNotNull(job, "Couldn't lookup worker for job " + id + " because the job doesn't exist");
    if (job.jobAuthorization().state() != CREDS_ENCRYPTION_KEY_GENERATED) {
        monitor.debug(() -> format("Job %s has not entered state CREDS_ENCRYPTION_KEY_GENERATED yet", jobId), jobId);
        return new ReservedWorker(null);
    }
    monitor.debug(() -> format("Got job %s in state CREDS_ENCRYPTION_KEY_GENERATED, returning its public key", jobId), jobId, EventCode.API_GOT_RESERVED_WORKER);
    return new ReservedWorker(job.jobAuthorization().authPublicKey());
}
Also used : PortabilityJob(org.datatransferproject.spi.cloud.types.PortabilityJob) GetReservedWorker(org.datatransferproject.types.client.transfer.GetReservedWorker) ReservedWorker(org.datatransferproject.types.client.transfer.ReservedWorker) UUID(java.util.UUID)

Aggregations

UUID (java.util.UUID)1 PortabilityJob (org.datatransferproject.spi.cloud.types.PortabilityJob)1 GetReservedWorker (org.datatransferproject.types.client.transfer.GetReservedWorker)1 ReservedWorker (org.datatransferproject.types.client.transfer.ReservedWorker)1