Search in sources :

Example 1 with CloningInstructionsEnum

use of bio.terra.workspace.model.CloningInstructionsEnum in project terra-cli by DataBiosphere.

the class GcsBucketReferenced method addWithAllOptions.

@Test
@DisplayName("add a referenced bucket, specifying all options")
void addWithAllOptions() throws IOException {
    workspaceCreator.login();
    // `terra workspace set --id=$id`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + getWorkspaceId());
    // `terra resources add-ref gcs-bucket --name=$name --bucket-name=$bucketName --cloning=$cloning
    // --description=$description --format=json`
    String name = "addWithAllOptionsExceptLifecycle";
    CloningInstructionsEnum cloning = CloningInstructionsEnum.REFERENCE;
    String description = "add with all options except lifecycle";
    UFGcsBucket addedBucket = TestCommand.runAndParseCommandExpectSuccess(UFGcsBucket.class, "resource", "add-ref", "gcs-bucket", "--name=" + name, "--bucket-name=" + externalSharedBucket.getName(), "--cloning=" + cloning, "--description=" + description);
    // check that the properties match
    assertEquals(name, addedBucket.name, "add ref output matches name");
    assertEquals(externalSharedBucket.getName(), addedBucket.bucketName, "add ref output matches bucket name");
    assertEquals(cloning, addedBucket.cloningInstructions, "add ref output matches cloning");
    assertEquals(description, addedBucket.description, "add ref output matches description");
    // `terra resources describe --name=$name --format=json`
    UFGcsBucket describeResource = TestCommand.runAndParseCommandExpectSuccess(UFGcsBucket.class, "resource", "describe", "--name=" + name);
    // check that the properties match
    assertEquals(name, describeResource.name, "describe resource output matches name");
    assertEquals(externalSharedBucket.getName(), describeResource.bucketName, "describe resource output matches bucket name");
    assertEquals(cloning, describeResource.cloningInstructions, "describe output matches cloning");
    assertEquals(description, describeResource.description, "describe output matches description");
    // `terra resources delete --name=$name`
    TestCommand.runCommandExpectSuccess("resource", "delete", "--name=" + name, "--quiet");
}
Also used : CloningInstructionsEnum(bio.terra.workspace.model.CloningInstructionsEnum) UFGcsBucket(bio.terra.cli.serialization.userfacing.resource.UFGcsBucket) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with CloningInstructionsEnum

use of bio.terra.workspace.model.CloningInstructionsEnum in project terra-cli by DataBiosphere.

the class GcsBucketControlled method createWithAllOptionsExceptLifecycle.

@Test
@DisplayName("create a controlled bucket, specifying all options except lifecycle")
void createWithAllOptionsExceptLifecycle() throws IOException {
    workspaceCreator.login();
    // `terra workspace set --id=$id`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + getWorkspaceId());
    // `terra resources create gcs-bucket --name=$name --bucket-name=$bucketName --access=$access
    // --cloning=$cloning --description=$description --location=$location --storage=$storage
    // --format=json`
    String name = "createWithAllOptionsExceptLifecycle";
    String bucketName = UUID.randomUUID().toString();
    AccessScope access = AccessScope.PRIVATE_ACCESS;
    CloningInstructionsEnum cloning = CloningInstructionsEnum.REFERENCE;
    String description = "\"create with all options except lifecycle\"";
    String location = "US";
    GcsStorageClass storage = GcsStorageClass.NEARLINE;
    UFGcsBucket createdBucket = TestCommand.runAndParseCommandExpectSuccess(UFGcsBucket.class, "resource", "create", "gcs-bucket", "--name=" + name, "--bucket-name=" + bucketName, "--access=" + access, "--cloning=" + cloning, "--description=" + description, "--location=" + location, "--storage=" + storage);
    // check that the properties match
    assertEquals(name, createdBucket.name, "create output matches name");
    assertEquals(bucketName, createdBucket.bucketName, "create output matches bucket name");
    assertEquals(access, createdBucket.accessScope, "create output matches access");
    assertEquals(cloning, createdBucket.cloningInstructions, "create output matches cloning");
    assertEquals(description, createdBucket.description, "create output matches description");
    assertEquals(workspaceCreator.email.toLowerCase(), createdBucket.privateUserName.toLowerCase(), "create output matches private user name");
    Bucket createdBucketOnCloud = ExternalGCSBuckets.getStorageClient(workspaceCreator.getCredentialsWithCloudPlatformScope()).get(bucketName);
    assertNotNull(createdBucketOnCloud, "looking up bucket via GCS API succeeded");
    assertEquals(location, createdBucketOnCloud.getLocation(), "bucket location matches create input");
    assertEquals(storage.toString(), createdBucketOnCloud.getStorageClass().toString(), "bucket storage class matches create input");
    // `terra resources describe --name=$name --format=json`
    UFGcsBucket describeResource = TestCommand.runAndParseCommandExpectSuccess(UFGcsBucket.class, "resource", "describe", "--name=" + name);
    // check that the properties match
    assertEquals(name, describeResource.name, "describe resource output matches name");
    assertEquals(bucketName, describeResource.bucketName, "describe resource output matches bucket name");
    assertEquals(access, describeResource.accessScope, "describe output matches access");
    assertEquals(cloning, describeResource.cloningInstructions, "describe output matches cloning");
    assertEquals(description, describeResource.description, "describe output matches description");
    assertEquals(workspaceCreator.email.toLowerCase(), describeResource.privateUserName.toLowerCase(), "describe output matches private user name");
    // `terra resources delete --name=$name`
    TestCommand.runCommandExpectSuccess("resource", "delete", "--name=" + name, "--quiet");
}
Also used : CloningInstructionsEnum(bio.terra.workspace.model.CloningInstructionsEnum) GcsStorageClass(bio.terra.cli.serialization.userfacing.input.GcsStorageClass) Bucket(com.google.cloud.storage.Bucket) UFGcsBucket(bio.terra.cli.serialization.userfacing.resource.UFGcsBucket) AccessScope(bio.terra.workspace.model.AccessScope) UFGcsBucket(bio.terra.cli.serialization.userfacing.resource.UFGcsBucket) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with CloningInstructionsEnum

use of bio.terra.workspace.model.CloningInstructionsEnum in project terra-cli by DataBiosphere.

the class BqDatasetControlled method createWithAllOptions.

@Test
@DisplayName("create a controlled dataset, specifying all options")
void createWithAllOptions() throws IOException {
    workspaceCreator.login();
    // `terra workspace set --id=$id --format=json`
    UFWorkspace workspace = TestCommand.runAndParseCommandExpectSuccess(UFWorkspace.class, "workspace", "set", "--id=" + getWorkspaceId());
    // `terra resources create bq-dataset --name=$name --dataset-id=$datasetId --access=$access
    // --cloning=$cloning --description=$description --location=$location --format=json`
    String name = "createWithAllOptions";
    String datasetId = randomDatasetId();
    AccessScope access = AccessScope.PRIVATE_ACCESS;
    CloningInstructionsEnum cloning = CloningInstructionsEnum.DEFINITION;
    String description = "\"create with all options\"";
    String location = "us-east1";
    UFBqDataset createdDataset = TestCommand.runAndParseCommandExpectSuccess(UFBqDataset.class, "resource", "create", "bq-dataset", "--name=" + name, "--dataset-id=" + datasetId, "--access=" + access, "--cloning=" + cloning, "--description=" + description, "--location=" + location);
    // check that the properties match
    assertEquals(name, createdDataset.name, "create output matches name");
    assertEquals(workspace.googleProjectId, createdDataset.projectId, "create output matches project id");
    assertEquals(datasetId, createdDataset.datasetId, "create output matches dataset id");
    assertEquals(access, createdDataset.accessScope, "create output matches access");
    assertEquals(cloning, createdDataset.cloningInstructions, "create output matches cloning");
    assertEquals(description, createdDataset.description, "create output matches description");
    assertEquals(workspaceCreator.email.toLowerCase(), createdDataset.privateUserName.toLowerCase(), "create output matches private user name");
    Dataset createdDatasetOnCloud = ExternalBQDatasets.getBQClient(workspaceCreator.getCredentialsWithCloudPlatformScope()).getDataset(DatasetId.of(workspace.googleProjectId, datasetId));
    assertNotNull(createdDatasetOnCloud, "looking up dataset via BQ API succeeded");
    assertEquals(location, createdDatasetOnCloud.getLocation(), "dataset location matches create input");
    // `terra resources describe --name=$name --format=json`
    UFBqDataset describeResource = TestCommand.runAndParseCommandExpectSuccess(UFBqDataset.class, "resource", "describe", "--name=" + name);
    // check that the properties match
    assertEquals(name, describeResource.name, "describe resource output matches name");
    assertEquals(datasetId, describeResource.datasetId, "describe resource output matches dataset id");
    assertEquals(access, describeResource.accessScope, "describe output matches access");
    assertEquals(cloning, describeResource.cloningInstructions, "describe output matches cloning");
    assertEquals(description, describeResource.description, "describe output matches description");
    assertEquals(workspaceCreator.email.toLowerCase(), describeResource.privateUserName.toLowerCase(), "describe output matches private user name");
    // `terra resources delete --name=$name`
    TestCommand.runCommandExpectSuccess("resource", "delete", "--name=" + name, "--quiet");
}
Also used : CloningInstructionsEnum(bio.terra.workspace.model.CloningInstructionsEnum) UFBqDataset(bio.terra.cli.serialization.userfacing.resource.UFBqDataset) UFBqDataset(bio.terra.cli.serialization.userfacing.resource.UFBqDataset) Dataset(com.google.cloud.bigquery.Dataset) UFWorkspace(bio.terra.cli.serialization.userfacing.UFWorkspace) AccessScope(bio.terra.workspace.model.AccessScope) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 4 with CloningInstructionsEnum

use of bio.terra.workspace.model.CloningInstructionsEnum in project terra-cli by DataBiosphere.

the class GcsObjectReferenced method addWithAllOptions.

@Test
@DisplayName("add a referenced object, specifying all options")
void addWithAllOptions() throws IOException {
    workspaceCreator.login();
    // `terra workspace set --id=$id`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + getWorkspaceId());
    // `terra resources add-ref gcs-object --name=$name --bucket-name=$bucketName
    // --object-name=$objectName --cloning=$cloning --description=$description --format=json`
    String name = "addWithAllOptions";
    CloningInstructionsEnum cloning = CloningInstructionsEnum.REFERENCE;
    String description = "add with all options";
    UFGcsObject addedBucketObjectReference = TestCommand.runAndParseCommandExpectSuccess(UFGcsObject.class, "resource", "add-ref", "gcs-object", "--name=" + name, "--description=" + description, "--cloning=" + cloning, "--bucket-name=" + externalBucket.getName(), "--object-name=" + externalBucketBlobName);
    // check that the properties match
    assertEquals(name, addedBucketObjectReference.name, "add ref output matches name");
    assertEquals(externalBucket.getName(), addedBucketObjectReference.bucketName, "add ref output matches bucket name");
    assertEquals(externalBucketBlobName, addedBucketObjectReference.objectName, "add ref output matches bucket object name");
    assertEquals(cloning, addedBucketObjectReference.cloningInstructions, "add ref output matches cloning");
    assertEquals(description, addedBucketObjectReference.description, "add ref output matches description");
    // `terra resources describe --name=$name --format=json`
    UFGcsObject describeResource = TestCommand.runAndParseCommandExpectSuccess(UFGcsObject.class, "resource", "describe", "--name=" + name);
    // check that the properties match
    assertEquals(name, describeResource.name, "describe resource output matches name");
    assertEquals(externalBucket.getName(), describeResource.bucketName, "describe resource output matches bucket name");
    assertEquals(externalBucketBlobName, describeResource.objectName, "describe resource output matches bucket object name");
    assertEquals(cloning, describeResource.cloningInstructions, "describe output matches cloning");
    assertEquals(description, describeResource.description, "describe output matches description");
    // `terra resources delete --name=$name`
    TestCommand.runCommandExpectSuccess("resource", "delete", "--name=" + name, "--quiet");
}
Also used : CloningInstructionsEnum(bio.terra.workspace.model.CloningInstructionsEnum) UFGcsObject(bio.terra.cli.serialization.userfacing.resource.UFGcsObject) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 5 with CloningInstructionsEnum

use of bio.terra.workspace.model.CloningInstructionsEnum in project terra-cli by DataBiosphere.

the class GitRepoReferenced method addWithAllOptions.

@Test
@DisplayName("add a referenced git repo, specifying all options")
void addWithAllOptions() throws IOException {
    workspaceCreator.login();
    // `terra workspace set --id=$id`
    TestCommand.runCommandExpectSuccess("workspace", "set", "--id=" + getWorkspaceId());
    // `terra resources add-ref git-repo --name=$name --repo-url=$repoUrl
    // --cloning=$cloning --description=$description --format=json`
    String name = "addWithAllOptions";
    CloningInstructionsEnum cloning = CloningInstructionsEnum.REFERENCE;
    String description = "add with all options";
    UFGitRepo gitRepoReference = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "add-ref", "git-repo", "--name=" + name, "--description=" + description, "--cloning=" + cloning, "--repo-url=" + GIT_REPO_SSH_URL);
    // check that the properties match
    assertEquals(name, gitRepoReference.name, "add ref output matches name");
    assertEquals(GIT_REPO_SSH_URL, gitRepoReference.gitRepoUrl, "add ref output matches git repo url");
    assertEquals(cloning, gitRepoReference.cloningInstructions, "add ref output matches cloning");
    assertEquals(description, gitRepoReference.description, "add ref output matches description");
    // `terra resources describe --name=$name --format=json`
    UFGitRepo describeResource = TestCommand.runAndParseCommandExpectSuccess(UFGitRepo.class, "resource", "describe", "--name=" + name);
    // check that the properties match
    assertEquals(name, describeResource.name, "describe resource output matches name");
    assertEquals(GIT_REPO_SSH_URL, describeResource.gitRepoUrl, "describe resource output matches git repo url");
    assertEquals(cloning, describeResource.cloningInstructions, "describe output matches cloning");
    assertEquals(description, describeResource.description, "describe output matches description");
    // `terra resources delete --name=$name`
    TestCommand.runCommandExpectSuccess("resource", "delete", "--name=" + name, "--quiet");
}
Also used : CloningInstructionsEnum(bio.terra.workspace.model.CloningInstructionsEnum) UFGitRepo(bio.terra.cli.serialization.userfacing.resource.UFGitRepo) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

CloningInstructionsEnum (bio.terra.workspace.model.CloningInstructionsEnum)8 DisplayName (org.junit.jupiter.api.DisplayName)8 Test (org.junit.jupiter.api.Test)8 UFBqDataset (bio.terra.cli.serialization.userfacing.resource.UFBqDataset)2 UFGcsBucket (bio.terra.cli.serialization.userfacing.resource.UFGcsBucket)2 AccessScope (bio.terra.workspace.model.AccessScope)2 UFWorkspace (bio.terra.cli.serialization.userfacing.UFWorkspace)1 GcsStorageClass (bio.terra.cli.serialization.userfacing.input.GcsStorageClass)1 UFBqTable (bio.terra.cli.serialization.userfacing.resource.UFBqTable)1 UFGcpNotebook (bio.terra.cli.serialization.userfacing.resource.UFGcpNotebook)1 UFGcsObject (bio.terra.cli.serialization.userfacing.resource.UFGcsObject)1 UFGitRepo (bio.terra.cli.serialization.userfacing.resource.UFGitRepo)1 Dataset (com.google.cloud.bigquery.Dataset)1 Bucket (com.google.cloud.storage.Bucket)1