Search in sources :

Example 1 with Operation

use of com.google.api.services.healthcare.v1.model.Operation in project beam by apache.

the class HttpHealthcareApiClient method importFhirResource.

@Override
public Operation importFhirResource(String fhirStore, String gcsSourcePath, @Nullable String contentStructure) throws IOException {
    GoogleCloudHealthcareV1FhirGcsSource gcsSrc = new GoogleCloudHealthcareV1FhirGcsSource();
    gcsSrc.setUri(gcsSourcePath);
    ImportResourcesRequest importRequest = new ImportResourcesRequest();
    importRequest.setGcsSource(gcsSrc).setContentStructure(contentStructure);
    return client.projects().locations().datasets().fhirStores().healthcareImport(fhirStore, importRequest).execute();
}
Also used : ImportResourcesRequest(com.google.api.services.healthcare.v1.model.ImportResourcesRequest) GoogleCloudHealthcareV1FhirGcsSource(com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1FhirGcsSource)

Example 2 with Operation

use of com.google.api.services.healthcare.v1.model.Operation in project beam by apache.

the class HttpHealthcareApiClient method deidentifyFhirStore.

@Override
public Operation deidentifyFhirStore(String sourcefhirStore, String destinationFhirStore, DeidentifyConfig deidConfig) throws IOException {
    DeidentifyFhirStoreRequest deidRequest = new DeidentifyFhirStoreRequest();
    deidRequest.setDestinationStore(destinationFhirStore);
    deidRequest.setConfig(deidConfig);
    return client.projects().locations().datasets().fhirStores().deidentify(sourcefhirStore, deidRequest).execute();
}
Also used : DeidentifyFhirStoreRequest(com.google.api.services.healthcare.v1.model.DeidentifyFhirStoreRequest)

Example 3 with Operation

use of com.google.api.services.healthcare.v1.model.Operation in project google-cloud-intellij by GoogleCloudPlatform.

the class GoogleApiClientAppEngineAdminService method createApplication.

@Override
public Application createApplication(@NotNull String locationId, @NotNull final String projectId, @NotNull final Credential credential) throws IOException, GoogleApiException {
    Application arg = new Application();
    arg.setId(projectId);
    arg.setLocationId(locationId);
    Apps.Create createRequest = GoogleApiClientFactory.getInstance().getAppEngineApiClient(credential).apps().create(arg);
    Operation operation;
    try {
        // make the initial request to create the application
        operation = createRequest.execute();
        // poll for updates while the application is being created
        boolean done = false;
        while (!done) {
            try {
                Thread.sleep(CREATE_APPLICATION_POLLING_INTERVAL_MS);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            operation = getOperation(projectId, operation.getName(), credential);
            if (operation.getDone() != null) {
                done = operation.getDone();
            }
        }
    } catch (GoogleJsonResponseException e) {
        throw GoogleApiException.from(e);
    }
    if (operation.getError() != null) {
        Status status = operation.getError();
        throw new GoogleApiException(status.getMessage(), status.getCode());
    } else {
        Application result = new Application();
        result.putAll(operation.getResponse());
        return result;
    }
}
Also used : Status(com.google.api.services.appengine.v1.model.Status) GoogleJsonResponseException(com.google.api.client.googleapis.json.GoogleJsonResponseException) Operation(com.google.api.services.appengine.v1.model.Operation) Application(com.google.api.services.appengine.v1.model.Application) Apps(com.google.api.services.appengine.v1.Appengine.Apps)

Example 4 with Operation

use of com.google.api.services.healthcare.v1.model.Operation in project google-cloud-intellij by GoogleCloudPlatform.

the class GoogleApiClientAppEngineAdminServiceTest method testCreateApplication_operationFailed.

@Test
public void testCreateApplication_operationFailed() throws IOException, GoogleApiException {
    String operationName = "apps/-/operations/12345";
    Operation inProgressOperation = buildInProgressOperation(operationName);
    when(appengineClientMock.getAppsCreateQuery().execute()).thenReturn(inProgressOperation);
    String errorMessage = "The operation failed.";
    int errorCode = 400;
    Status status = new Status();
    status.setMessage(errorMessage);
    status.setCode(errorCode);
    Operation failedOperation = new Operation();
    failedOperation.setError(status);
    failedOperation.setDone(true);
    failedOperation.setName(operationName);
    when(appengineClientMock.getAppsCreateQuery().execute()).thenReturn(inProgressOperation);
    when(appengineClientMock.getAppsOperationsGetQuery().execute()).thenReturn(failedOperation);
    try {
        service.createApplication("us-east", "my-project-id", mock(Credential.class));
    } catch (GoogleApiException expected) {
        assertEquals(errorCode, expected.getStatusCode());
        assertEquals(errorMessage, expected.getMessage());
        return;
    }
    fail();
}
Also used : Status(com.google.api.services.appengine.v1.model.Status) Credential(com.google.api.client.auth.oauth2.Credential) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Operation(com.google.api.services.appengine.v1.model.Operation) Test(org.junit.Test)

Example 5 with Operation

use of com.google.api.services.healthcare.v1.model.Operation in project java-docs-samples by GoogleCloudPlatform.

the class CheckLatestTransferOperationApiary method checkLatestTransferOperationApiary.

// Gets the requested transfer job and checks its latest operation
public static void checkLatestTransferOperationApiary(String projectId, String jobName) throws IOException {
    // Your Google Cloud Project ID
    // String projectId = "your-project-id";
    // The name of the job to check
    // String jobName = "myJob/1234567890";
    // Create Storage Transfer client
    GoogleCredentials credential = GoogleCredentials.getApplicationDefault();
    if (credential.createScopedRequired()) {
        credential = credential.createScoped(StoragetransferScopes.all());
    }
    Storagetransfer storageTransfer = new Storagetransfer.Builder(Utils.getDefaultTransport(), Utils.getDefaultJsonFactory(), new HttpCredentialsAdapter(credential)).build();
    // Get transfer job and check latest operation
    TransferJob transferJob = storageTransfer.transferJobs().get(jobName, projectId).execute();
    String latestOperationName = transferJob.getLatestOperationName();
    if (latestOperationName != null) {
        Operation latestOperation = storageTransfer.transferOperations().get(latestOperationName).execute();
        System.out.println("The latest operation for transfer job " + jobName + " is:");
        System.out.println(latestOperation.toPrettyString());
    } else {
        System.out.println("Transfer job " + jobName + " does not have an operation scheduled yet," + " try again once the job starts running.");
    }
}
Also used : HttpCredentialsAdapter(com.google.auth.http.HttpCredentialsAdapter) GoogleCredentials(com.google.auth.oauth2.GoogleCredentials) Operation(com.google.api.services.storagetransfer.v1.model.Operation) Storagetransfer(com.google.api.services.storagetransfer.v1.Storagetransfer) TransferJob(com.google.api.services.storagetransfer.v1.model.TransferJob)

Aggregations

IOException (java.io.IOException)13 Operation (io.adminshell.aas.v3.model.Operation)8 CloudHealthcare (com.google.api.services.healthcare.v1.CloudHealthcare)7 Operation (com.google.api.services.healthcare.v1.model.Operation)6 GoogleJsonResponseException (com.google.api.client.googleapis.json.GoogleJsonResponseException)5 Operation (com.google.api.services.notebooks.v1.model.Operation)5 Reference (io.adminshell.aas.v3.model.Reference)5 StepResult (bio.terra.stairway.StepResult)4 Operation (com.google.api.services.appengine.v1.model.Operation)4 ResourceNotFoundException (de.fraunhofer.iosb.ilt.faaast.service.exception.ResourceNotFoundException)4 MessageBus (de.fraunhofer.iosb.ilt.faaast.service.messagebus.MessageBus)4 OperationResult (de.fraunhofer.iosb.ilt.faaast.service.model.api.operation.OperationResult)4 List (java.util.List)4 Test (org.junit.Test)4 AIPlatformNotebooksCow (bio.terra.cloudres.google.notebooks.AIPlatformNotebooksCow)3 InstanceName (bio.terra.cloudres.google.notebooks.InstanceName)3 GcpCloudContext (bio.terra.workspace.service.workspace.model.GcpCloudContext)3 Status (com.google.api.services.appengine.v1.model.Status)3 Project (com.google.api.services.cloudresourcemanager.v3.model.Project)3 SystemException (bio.terra.cli.exception.SystemException)2