Search in sources :

Example 1 with RepositoryApi

use of bio.terra.datarepo.api.RepositoryApi in project jade-data-repo by DataBiosphere.

the class IngestFile method cleanup.

public void cleanup(Map<String, ApiClient> apiClients) throws Exception {
    // get the ApiClient for the dataset creator
    ApiClient datasetCreatorClient = apiClients.get(datasetCreator);
    ResourcesApi resourcesApi = new ResourcesApi(datasetCreatorClient);
    RepositoryApi repositoryApi = new RepositoryApi(datasetCreatorClient);
    // make the delete request and wait for the job to finish
    JobModel deleteDatasetJobResponse = repositoryApi.deleteDataset(datasetSummaryModel.getId());
    deleteDatasetJobResponse = DataRepoUtils.waitForJobToFinish(repositoryApi, deleteDatasetJobResponse);
    DataRepoUtils.expectJobSuccess(repositoryApi, deleteDatasetJobResponse, DeleteResponseModel.class);
    System.out.println("successfully deleted dataset: " + datasetSummaryModel.getName());
    // delete the profile
    resourcesApi.deleteProfile(billingProfileModel.getId());
    System.out.println("successfully deleted profile: " + billingProfileModel.getProfileName());
}
Also used : RepositoryApi(bio.terra.datarepo.api.RepositoryApi) ResourcesApi(bio.terra.datarepo.api.ResourcesApi) JobModel(bio.terra.datarepo.model.JobModel) ApiClient(bio.terra.datarepo.client.ApiClient)

Example 2 with RepositoryApi

use of bio.terra.datarepo.api.RepositoryApi in project jade-data-repo by DataBiosphere.

the class IngestFile method userJourney.

public void userJourney(ApiClient apiClient) throws Exception {
    RepositoryApi repositoryApi = new RepositoryApi(apiClient);
    String targetPath = "/testrunner/IngestFile/" + FileUtils.randomizeName("") + ".txt";
    FileLoadModel fileLoadModel = new FileLoadModel().sourcePath(sourceFileURI.toString()).description("IngestFile").mimeType("text/plain").targetPath(targetPath).profileId(datasetSummaryModel.getDefaultProfileId());
    JobModel ingestFileJobResponse = repositoryApi.ingestFile(datasetSummaryModel.getId(), fileLoadModel);
    ingestFileJobResponse = DataRepoUtils.waitForJobToFinish(repositoryApi, ingestFileJobResponse);
    FileModel fileModel = DataRepoUtils.expectJobSuccess(repositoryApi, ingestFileJobResponse, FileModel.class);
    System.out.println("successfully ingested file: " + fileModel.getPath() + ", id: " + fileModel.getFileId() + ", size: " + fileModel.getSize());
}
Also used : FileModel(bio.terra.datarepo.model.FileModel) RepositoryApi(bio.terra.datarepo.api.RepositoryApi) JobModel(bio.terra.datarepo.model.JobModel) FileLoadModel(bio.terra.datarepo.model.FileLoadModel)

Example 3 with RepositoryApi

use of bio.terra.datarepo.api.RepositoryApi in project jade-data-repo by DataBiosphere.

the class IngestFile method setup.

public void setup(Map<String, ApiClient> apiClients) throws Exception {
    // pick the first user to be the dataset creator
    List<String> apiClientList = new ArrayList<>(apiClients.keySet());
    datasetCreator = apiClientList.get(0);
    // get the ApiClient for the dataset creator
    ApiClient datasetCreatorClient = apiClients.get(datasetCreator);
    ResourcesApi resourcesApi = new ResourcesApi(datasetCreatorClient);
    RepositoryApi repositoryApi = new RepositoryApi(datasetCreatorClient);
    // create a new profile
    billingProfileModel = DataRepoUtils.createProfile(resourcesApi, billingAccount, "profile-simple", true);
    System.out.println("successfully created profile: " + billingProfileModel.getProfileName());
    // make the create dataset request and wait for the job to finish
    JobModel createDatasetJobResponse = DataRepoUtils.createDataset(repositoryApi, billingProfileModel.getId(), "dataset-simple.json", true);
    // save a reference to the dataset summary model so we can delete it in cleanup()
    datasetSummaryModel = DataRepoUtils.expectJobSuccess(repositoryApi, createDatasetJobResponse, DatasetSummaryModel.class);
    System.out.println("successfully created dataset: " + datasetSummaryModel.getName());
}
Also used : ArrayList(java.util.ArrayList) RepositoryApi(bio.terra.datarepo.api.RepositoryApi) ResourcesApi(bio.terra.datarepo.api.ResourcesApi) JobModel(bio.terra.datarepo.model.JobModel) DatasetSummaryModel(bio.terra.datarepo.model.DatasetSummaryModel) ApiClient(bio.terra.datarepo.client.ApiClient)

Example 4 with RepositoryApi

use of bio.terra.datarepo.api.RepositoryApi in project jade-data-repo by DataBiosphere.

the class RetrieveDataset method cleanup.

public void cleanup(Map<String, ApiClient> apiClients) throws Exception {
    // get the ApiClient for the dataset creator
    ApiClient datasetCreatorClient = apiClients.get(datasetCreator);
    ResourcesApi resourcesApi = new ResourcesApi(datasetCreatorClient);
    RepositoryApi repositoryApi = new RepositoryApi(datasetCreatorClient);
    // make the delete dataset request and wait for the job to finish
    JobModel deleteDatasetJobResponse = repositoryApi.deleteDataset(datasetSummaryModel.getId());
    deleteDatasetJobResponse = DataRepoUtils.waitForJobToFinish(repositoryApi, deleteDatasetJobResponse);
    DataRepoUtils.expectJobSuccess(repositoryApi, deleteDatasetJobResponse, DeleteResponseModel.class);
    System.out.println("successfully deleted dataset: " + datasetSummaryModel.getName());
    // delete the profile
    resourcesApi.deleteProfile(billingProfileModel.getId());
    System.out.println("successfully deleted profile: " + billingProfileModel.getProfileName());
}
Also used : RepositoryApi(bio.terra.datarepo.api.RepositoryApi) ResourcesApi(bio.terra.datarepo.api.ResourcesApi) JobModel(bio.terra.datarepo.model.JobModel) ApiClient(bio.terra.datarepo.client.ApiClient)

Example 5 with RepositoryApi

use of bio.terra.datarepo.api.RepositoryApi in project jade-data-repo by DataBiosphere.

the class RetrieveDataset method setup.

public void setup(Map<String, ApiClient> apiClients) throws Exception {
    // pick the first user to be the dataset creator
    List<String> apiClientList = new ArrayList<>(apiClients.keySet());
    datasetCreator = apiClientList.get(0);
    // get the ApiClient for the dataset creator
    ApiClient datasetCreatorClient = apiClients.get(datasetCreator);
    ResourcesApi resourcesApi = new ResourcesApi(datasetCreatorClient);
    RepositoryApi repositoryApi = new RepositoryApi(datasetCreatorClient);
    // create a new profile
    billingProfileModel = DataRepoUtils.createProfile(resourcesApi, billingAccount, "profile-simple", true);
    System.out.println("successfully created profile: " + billingProfileModel.getProfileName());
    // make the create dataset request and wait for the job to finish
    JobModel createDatasetJobResponse = DataRepoUtils.createDataset(repositoryApi, billingProfileModel.getId(), "dataset-simple.json", true);
    // save a reference to the dataset summary model so we can delete it in cleanup()
    datasetSummaryModel = DataRepoUtils.expectJobSuccess(repositoryApi, createDatasetJobResponse, DatasetSummaryModel.class);
    System.out.println("successfully created dataset: " + datasetSummaryModel.getName());
}
Also used : ArrayList(java.util.ArrayList) RepositoryApi(bio.terra.datarepo.api.RepositoryApi) ResourcesApi(bio.terra.datarepo.api.ResourcesApi) JobModel(bio.terra.datarepo.model.JobModel) DatasetSummaryModel(bio.terra.datarepo.model.DatasetSummaryModel) ApiClient(bio.terra.datarepo.client.ApiClient)

Aggregations

RepositoryApi (bio.terra.datarepo.api.RepositoryApi)7 JobModel (bio.terra.datarepo.model.JobModel)5 ResourcesApi (bio.terra.datarepo.api.ResourcesApi)4 ApiClient (bio.terra.datarepo.client.ApiClient)4 DatasetSummaryModel (bio.terra.datarepo.model.DatasetSummaryModel)2 ArrayList (java.util.ArrayList)2 ApiException (bio.terra.datarepo.client.ApiException)1 DatasetModel (bio.terra.datarepo.model.DatasetModel)1 FileLoadModel (bio.terra.datarepo.model.FileLoadModel)1 FileModel (bio.terra.datarepo.model.FileModel)1 DataRepoInternalServerErrorException (bio.terra.workspace.service.datarepo.exception.DataRepoInternalServerErrorException)1 Traced (io.opencensus.contrib.spring.aop.Traced)1