use of com.google.api.services.healthcare.v1.model.Operation in project google-cloud-intellij by GoogleCloudPlatform.
the class GoogleApiClientAppEngineAdminServiceTest method testCreateApplication.
@Test
public void testCreateApplication() throws IOException, GoogleApiException {
String operationId = "my-operation-id";
String operationName = "apps/-/operations/" + operationId;
Operation inProgressOperation = buildInProgressOperation(operationName);
when(appengineClientMock.getAppsCreateQuery().execute()).thenReturn(inProgressOperation);
final String locationId = "us-east1";
final String projectId = "my-project";
Map<String, Object> response = new HashMap<>();
response.put("name", projectId);
response.put("locationId", locationId);
Operation doneOperation = new Operation();
doneOperation.setName(operationName);
doneOperation.setDone(true);
doneOperation.setResponse(response);
// require polling several times
when(appengineClientMock.getAppsOperationsGetQuery().execute()).thenReturn(inProgressOperation).thenReturn(inProgressOperation).thenReturn(doneOperation);
Application result = service.createApplication(locationId, projectId, mock(Credential.class));
// ensure the 'getOperation' API call(s) were made correctly
verify(appengineClientMock.apps().operations(), atLeastOnce()).get(eq(projectId), eq(operationId));
// ensure the 'createApplication' API call was made with the correct args
verify(appengineClientMock.apps(), times(1)).create(argThat(application -> application.getId().equals(projectId) && application.getLocationId().equals(locationId)));
// ensure the 'createApplication' API call was only made once
verify(appengineClientMock.getAppsCreateQuery(), times(1)).execute();
assertEquals(projectId, result.getName());
assertEquals(locationId, result.getLocationId());
}
use of com.google.api.services.healthcare.v1.model.Operation in project google-cloud-intellij by GoogleCloudPlatform.
the class GoogleApiClientAppEngineAdminServiceTest method buildInProgressOperation.
private Operation buildInProgressOperation(String operationName) {
Operation inProgressOperation = new Operation();
inProgressOperation.setName(operationName);
inProgressOperation.setDone(false);
return inProgressOperation;
}
use of com.google.api.services.healthcare.v1.model.Operation in project java-docs-samples by GoogleCloudPlatform.
the class DicomStoreExport method dicomStoreExport.
public static void dicomStoreExport(String dicomStoreName, String gcsUri) throws IOException {
// String dicomStoreName =
// String.format(
// DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");
// String gcsUri = "gs://your-bucket-id/path/to/destination/dir"
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
// Configure where the store will be exported too.
GoogleCloudHealthcareV1DicomGcsDestination gcsDestination = new GoogleCloudHealthcareV1DicomGcsDestination().setUriPrefix(gcsUri);
ExportDicomDataRequest exportRequest = new ExportDicomDataRequest().setGcsDestination(gcsDestination);
// Create request and configure any parameters.
DicomStores.Export request = client.projects().locations().datasets().dicomStores().export(dicomStoreName, exportRequest);
// Execute the request, wait for the operation to complete, and process the results.
try {
Operation operation = request.execute();
while (operation.getDone() == null || !operation.getDone()) {
// Update the status of the operation with another request.
// Pause for 500ms between requests.
Thread.sleep(500);
operation = client.projects().locations().datasets().operations().get(operation.getName()).execute();
}
System.out.println("DICOM store export complete." + operation.getResponse());
} catch (Exception ex) {
System.out.printf("Error during request execution: %s", ex.toString());
ex.printStackTrace(System.out);
}
}
use of com.google.api.services.healthcare.v1.model.Operation in project java-docs-samples by GoogleCloudPlatform.
the class FhirStoreImport method fhirStoreImport.
public static void fhirStoreImport(String fhirStoreName, String gcsUri) throws IOException {
// String fhirStoreName =
// String.format(
// FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-id");
// String gcsUri = "gs://your-bucket-id/path/to/destination/dir"
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
// Configure where the store should be imported from.
GoogleCloudHealthcareV1FhirGcsSource gcsSource = new GoogleCloudHealthcareV1FhirGcsSource().setUri(gcsUri);
ImportResourcesRequest importRequest = new ImportResourcesRequest().setGcsSource(gcsSource);
// Create request and configure any parameters.
FhirStores.CloudHealthcareImport request = client.projects().locations().datasets().fhirStores().healthcareImport(fhirStoreName, importRequest);
// Execute the request, wait for the operation to complete, and process the results.
try {
Operation operation = request.execute();
while (operation.getDone() == null || !operation.getDone()) {
// Update the status of the operation with another request.
// Pause for 500ms between requests.
Thread.sleep(500);
operation = client.projects().locations().datasets().operations().get(operation.getName()).execute();
}
System.out.println("FHIR store import complete: " + operation.getResponse());
} catch (Exception ex) {
System.out.printf("Error during request execution: %s", ex.toString());
ex.printStackTrace(System.out);
}
}
use of com.google.api.services.healthcare.v1.model.Operation in project java-docs-samples by GoogleCloudPlatform.
the class DatasetDeIdentify method datasetDeIdentify.
public static void datasetDeIdentify(String srcDatasetName, String destDatasetName) throws IOException {
// String srcDatasetName =
// String.format(DATASET_NAME, "your-project-id", "your-region-id", "your-src-dataset-id");
// String destDatasetName =
// String.format(DATASET_NAME, "your-project-id", "your-region-id", "your-dest-dataset-id");
// Initialize the client, which will be used to interact with the service.
CloudHealthcare client = createClient();
// Configure what information needs to be De-Identified.
// For more information on de-identifying using tags, please see the following:
// https://cloud.google.com/healthcare/docs/how-tos/dicom-deidentify#de-identification_using_tags
TagFilterList tags = new TagFilterList().setTags(Arrays.asList("PatientID"));
DicomConfig dicomConfig = new DicomConfig().setKeepList(tags);
DeidentifyConfig config = new DeidentifyConfig().setDicom(dicomConfig);
// Create the de-identify request and configure any parameters.
DeidentifyDatasetRequest deidentifyRequest = new DeidentifyDatasetRequest().setDestinationDataset(destDatasetName).setConfig(config);
Datasets.Deidentify request = client.projects().locations().datasets().deidentify(srcDatasetName, deidentifyRequest);
// Execute the request, wait for the operation to complete, and process the results.
try {
Operation operation = request.execute();
while (operation.getDone() == null || !operation.getDone()) {
// Update the status of the operation with another request.
// Pause for 500ms between requests.
Thread.sleep(500);
operation = client.projects().locations().datasets().operations().get(operation.getName()).execute();
}
System.out.println("De-identified Dataset created. Response content: " + operation.getResponse());
} catch (Exception ex) {
System.out.printf("Error during request execution: %s", ex.toString());
ex.printStackTrace(System.out);
}
}
Aggregations