use of com.google.api.services.healthcare.v1.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));
}
use of com.google.api.services.healthcare.v1.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(GoogleApiServiceusageV1Service::getName).collect(Collectors.toList());
assertThat(services2, Matchers.hasItem(storageServiceName));
}
use of com.google.api.services.healthcare.v1.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);
}
}
use of com.google.api.services.healthcare.v1.model.Operation in project terra-resource-buffer by DataBiosphere.
the class CreateConsumerDefinedQuotaForBigQueryDailyUsageStep method doStep.
/**
* Apply a Consumer Quota Override for the BigQuery Query Usage Quota.
*/
@Override
public StepResult doStep(FlightContext context) throws InterruptedException, RetryException {
Optional<Long> overrideValue = GoogleProjectConfigUtils.bigQueryDailyUsageOverrideValueMebibytes(gcpProjectConfig);
if (overrideValue.isEmpty()) {
// Do not apply any quota override
return StepResult.getStepResultSuccess();
}
long projectNumber = Optional.ofNullable(context.getWorkingMap().get(GOOGLE_PROJECT_NUMBER, Long.class)).orElseThrow();
QuotaOverride overridePerProjectPerDay = buildQuotaOverride(projectNumber, overrideValue.get());
// parent format and other details obtained by hitting the endpoint
// https://serviceusage.googleapis.com/v1beta1/projects/${PROJECT_NUMBER}/services/bigquery.googleapis.com/consumerQuotaMetrics
String parent = String.format("projects/%d/services/bigquery.googleapis.com/consumerQuotaMetrics/" + "bigquery.googleapis.com%%2Fquota%%2Fquery%%2Fusage/limits/%%2Fd%%2Fproject", projectNumber);
try {
// We are decreasing the quota by more than 10%, so we must tell Service Usage to bypass the
// check with the force flag.
Operation createOperation = serviceUsageCow.services().consumerQuotaMetrics().limits().consumerOverrides().create(parent, overridePerProjectPerDay).setForce(true).execute();
OperationCow<Operation> operationCow = serviceUsageCow.operations().operationCow(createOperation);
pollUntilSuccess(operationCow, Duration.ofSeconds(3), Duration.ofMinutes(5));
} catch (IOException e) {
throw new RetryException(e);
}
return StepResult.getStepResultSuccess();
}
use of com.google.api.services.healthcare.v1.model.Operation in project beam by apache.
the class HttpHealthcareApiClient method exportFhirResourceToGcs.
@Override
public Operation exportFhirResourceToGcs(String fhirStore, String gcsDestinationPrefix) throws IOException {
GoogleCloudHealthcareV1FhirGcsDestination gcsDst = new GoogleCloudHealthcareV1FhirGcsDestination();
gcsDst.setUriPrefix(gcsDestinationPrefix);
ExportResourcesRequest exportRequest = new ExportResourcesRequest();
exportRequest.setGcsDestination(gcsDst);
return client.projects().locations().datasets().fhirStores().export(fhirStore, exportRequest).execute();
}
Aggregations