Search in sources :

Example 16 with Operation

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

the class FhirStoreExport method fhirStoreExport.

public static void fhirStoreExport(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 will be exported too.
    GoogleCloudHealthcareV1FhirGcsDestination gcsDestination = new GoogleCloudHealthcareV1FhirGcsDestination().setUriPrefix(gcsUri);
    ExportResourcesRequest exportRequest = new ExportResourcesRequest().setGcsDestination(gcsDestination);
    // Create request and configure any parameters.
    FhirStores.Export request = client.projects().locations().datasets().fhirStores().export(fhirStoreName, 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("Fhir store export complete." + operation.getResponse());
    } catch (Exception ex) {
        System.out.printf("Error during request execution: %s", ex.toString());
        ex.printStackTrace(System.out);
    }
}
Also used : FhirStores(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare) ExportResourcesRequest(com.google.api.services.healthcare.v1.model.ExportResourcesRequest) Operation(com.google.api.services.healthcare.v1.model.Operation) GoogleCloudHealthcareV1FhirGcsDestination(com.google.api.services.healthcare.v1.model.GoogleCloudHealthcareV1FhirGcsDestination) IOException(java.io.IOException)

Example 17 with Operation

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

the class DatasetCreate method datasetCreate.

public static void datasetCreate(String projectId, String regionId, String datasetId) throws IOException {
    // String projectId = "your-project-id";
    // String regionId = "us-central1";
    // String datasetId = "your-dataset-id";
    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();
    // Configure the dataset to be created.
    Dataset dataset = new Dataset();
    dataset.setTimeZone("America/Chicago");
    // Create request and configure any parameters.
    String parentName = String.format("projects/%s/locations/%s", projectId, regionId);
    Datasets.Create request = client.projects().locations().datasets().create(parentName, dataset);
    request.setDatasetId(datasetId);
    // Execute the request, wait for the operation to complete, and process the results.
    try {
        Operation operation = request.execute();
        System.out.println(operation.toPrettyString());
        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("Dataset created. Response content: " + operation.getResponse());
    } catch (Exception ex) {
        System.out.printf("Error during request execution: %s\n", ex.toString());
        ex.printStackTrace(System.out);
    }
}
Also used : Datasets(com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets) Dataset(com.google.api.services.healthcare.v1.model.Dataset) CloudHealthcare(com.google.api.services.healthcare.v1.CloudHealthcare) Operation(com.google.api.services.healthcare.v1.model.Operation) IOException(java.io.IOException)

Example 18 with Operation

use of com.google.api.services.cloudresourcemanager.v3.model.Operation in project terra-cloud-resource-lib by DataBiosphere.

the class ServiceUsageCowTest method listAndEnableServices.

@Test
public void listAndEnableServices() throws Exception {
    ServiceUsageCow serviceUsage = defaultServiceUsage();
    Project project = ProjectUtils.executeCreateProject();
    String projectName = projectIdToName(project.getProjectId());
    String storageServiceName = serviceName(project, STORAGE_SERVICE_ID);
    ListServicesResponse response1 = serviceUsage.services().list(projectName).setFilter(ENABLED_FILTER).execute();
    assertNull(response1.getServices());
    Operation operation = serviceUsage.services().batchEnable(projectName, new BatchEnableServicesRequest().setServiceIds(ImmutableList.of(STORAGE_SERVICE_ID))).execute();
    OperationTestUtils.pollAndAssertSuccess(serviceUsage.operations().operationCow(operation), Duration.ofSeconds(5), Duration.ofSeconds(60));
    ListServicesResponse response2 = serviceUsage.services().list(projectName).setFilter(ENABLED_FILTER).execute();
    List<String> services2 = response2.getServices().stream().map(Service::getName).collect(Collectors.toList());
    assertThat(services2, Matchers.hasItem(storageServiceName));
}
Also used : Project(com.google.api.services.cloudresourcemanager.v3.model.Project) ListServicesResponse(com.google.api.services.serviceusage.v1beta1.model.ListServicesResponse) Operation(com.google.api.services.serviceusage.v1beta1.model.Operation) BatchEnableServicesRequest(com.google.api.services.serviceusage.v1beta1.model.BatchEnableServicesRequest) Test(org.junit.jupiter.api.Test)

Example 19 with Operation

use of com.google.api.services.cloudresourcemanager.v3.model.Operation in project terra-cloud-resource-lib by DataBiosphere.

the class ServiceUsageUtils method enableServices.

/**
 * Enables batch services for a project.
 *
 * @param projectId: The projectId to enable services on.
 * @param services: Services to be enabled. See {@link BatchEnableServicesRequest}
 */
public static void enableServices(String projectId, List<String> services) throws Exception {
    Operation operation = getServiceUsageCow().services().batchEnable(projectIdToName(projectId), new BatchEnableServicesRequest().setServiceIds(services)).execute();
    OperationTestUtils.pollAndAssertSuccess(serviceUsageCow.operations().operationCow(operation), Duration.ofSeconds(5), Duration.ofSeconds(100));
}
Also used : Operation(com.google.api.services.serviceusage.v1beta1.model.Operation) BatchEnableServicesRequest(com.google.api.services.serviceusage.v1beta1.model.BatchEnableServicesRequest)

Example 20 with Operation

use of com.google.api.services.cloudresourcemanager.v3.model.Operation in project terra-cli by DataBiosphere.

the class GoogleNotebooks method stop.

public void stop(InstanceName instanceName) {
    try {
        Operation stopOperation = notebooks.instances().stop(instanceName).execute();
        pollForSuccess(stopOperation, "Error stopping notebook instance: ");
    } catch (InterruptedException | IOException e) {
        checkFor409BadState(e);
        throw new SystemException("Error stopping notebook instance", e);
    }
}
Also used : SystemException(bio.terra.cli.exception.SystemException) Operation(com.google.api.services.notebooks.v1.model.Operation) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)16 Test (org.junit.Test)9 Operation (io.adminshell.aas.v3.model.Operation)7 StepResult (bio.terra.stairway.StepResult)6 GoogleJsonResponseException (com.google.api.client.googleapis.json.GoogleJsonResponseException)6 CloudHealthcare (com.google.api.services.healthcare.v1.CloudHealthcare)6 Operation (com.google.api.services.healthcare.v1.model.Operation)6 Project (com.google.api.services.cloudresourcemanager.v3.model.Project)5 Operation (com.google.api.services.notebooks.v1.model.Operation)5 MessageBus (de.fraunhofer.iosb.ilt.faaast.service.messagebus.MessageBus)5 Operation (com.google.api.services.appengine.v1.model.Operation)4 Create (com.google.api.services.container.v1beta1.Container.Projects.Locations.Clusters.Create)4 Operation (com.google.api.services.container.v1beta1.model.Operation)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 Get (com.google.api.services.container.v1beta1.Container.Projects.Locations.Clusters.Get)3 Operation (com.google.api.services.serviceusage.v1beta1.model.Operation)3 AssetConnectionManager (de.fraunhofer.iosb.ilt.faaast.service.assetconnection.AssetConnectionManager)3