Search in sources :

Example 1 with ApiResourceDescription

use of bio.terra.workspace.generated.model.ApiResourceDescription in project terra-workspace-manager by DataBiosphere.

the class MakeApiResourceDescriptionTest method mapReferencedBigQueryDatasetTest.

@Test
public void mapReferencedBigQueryDatasetTest() throws Exception {
    String projectId = RandomStringUtils.randomAlphabetic(12);
    String datasetName = RandomStringUtils.randomAlphabetic(12);
    var resource = new ReferencedBigQueryDatasetResource(workspaceId, resourceId, resourceName, description, cloning, projectId, datasetName);
    ApiResourceDescription resourceDescription = resourceController.makeApiResourceDescription(resource);
    validateWsmResource(resourceDescription);
    ApiResourceAttributesUnion union = resourceDescription.getResourceAttributes();
    ApiGcpBigQueryDatasetAttributes attributes = union.getGcpBqDataset();
    assertThat(attributes, is(notNullValue()));
    assertEquals(attributes.getDatasetId(), datasetName);
    assertEquals(attributes.getProjectId(), projectId);
}
Also used : ApiGcpBigQueryDatasetAttributes(bio.terra.workspace.generated.model.ApiGcpBigQueryDatasetAttributes) ApiResourceDescription(bio.terra.workspace.generated.model.ApiResourceDescription) ReferencedBigQueryDatasetResource(bio.terra.workspace.service.resource.referenced.cloud.gcp.bqdataset.ReferencedBigQueryDatasetResource) ApiResourceAttributesUnion(bio.terra.workspace.generated.model.ApiResourceAttributesUnion) BaseUnitTest(bio.terra.workspace.common.BaseUnitTest) Test(org.junit.jupiter.api.Test)

Example 2 with ApiResourceDescription

use of bio.terra.workspace.generated.model.ApiResourceDescription in project terra-workspace-manager by DataBiosphere.

the class MakeApiResourceDescriptionTest method mapReferencedGcsBucketTest.

@Test
public void mapReferencedGcsBucketTest() throws Exception {
    String bucketName = RandomStringUtils.randomAlphabetic(5).toLowerCase();
    var resource = new ReferencedGcsBucketResource(workspaceId, resourceId, resourceName, description, cloning, bucketName);
    ApiResourceDescription resourceDescription = resourceController.makeApiResourceDescription(resource);
    validateWsmResource(resourceDescription);
    ApiResourceAttributesUnion union = resourceDescription.getResourceAttributes();
    ApiGcpGcsBucketAttributes attributes = union.getGcpGcsBucket();
    assertThat(attributes, is(notNullValue()));
    assertEquals(attributes.getBucketName(), bucketName);
}
Also used : ReferencedGcsBucketResource(bio.terra.workspace.service.resource.referenced.cloud.gcp.gcsbucket.ReferencedGcsBucketResource) ApiResourceDescription(bio.terra.workspace.generated.model.ApiResourceDescription) ApiResourceAttributesUnion(bio.terra.workspace.generated.model.ApiResourceAttributesUnion) ApiGcpGcsBucketAttributes(bio.terra.workspace.generated.model.ApiGcpGcsBucketAttributes) BaseUnitTest(bio.terra.workspace.common.BaseUnitTest) Test(org.junit.jupiter.api.Test)

Example 3 with ApiResourceDescription

use of bio.terra.workspace.generated.model.ApiResourceDescription in project terra-workspace-manager by DataBiosphere.

the class MakeApiResourceDescriptionTest method mapReferencedDataRepoSnapshotTest.

@Test
public void mapReferencedDataRepoSnapshotTest() throws Exception {
    String snapshotId = UUID.randomUUID().toString();
    String instanceName = RandomStringUtils.randomAlphabetic(5);
    var resource = new ReferencedDataRepoSnapshotResource(workspaceId, resourceId, resourceName, description, cloning, instanceName, snapshotId);
    ApiResourceDescription resourceDescription = resourceController.makeApiResourceDescription(resource);
    validateWsmResource(resourceDescription);
    ApiResourceAttributesUnion union = resourceDescription.getResourceAttributes();
    ApiDataRepoSnapshotAttributes attributes = union.getGcpDataRepoSnapshot();
    assertThat(attributes, is(notNullValue()));
    assertEquals(attributes.getInstanceName(), instanceName);
    assertEquals(attributes.getSnapshot(), snapshotId);
}
Also used : ApiDataRepoSnapshotAttributes(bio.terra.workspace.generated.model.ApiDataRepoSnapshotAttributes) ApiResourceDescription(bio.terra.workspace.generated.model.ApiResourceDescription) ApiResourceAttributesUnion(bio.terra.workspace.generated.model.ApiResourceAttributesUnion) ReferencedDataRepoSnapshotResource(bio.terra.workspace.service.resource.referenced.cloud.gcp.datareposnapshot.ReferencedDataRepoSnapshotResource) BaseUnitTest(bio.terra.workspace.common.BaseUnitTest) Test(org.junit.jupiter.api.Test)

Example 4 with ApiResourceDescription

use of bio.terra.workspace.generated.model.ApiResourceDescription in project terra-workspace-manager by DataBiosphere.

the class MakeApiResourceDescriptionTest method mapReferencedBigQueryDataTableTest.

@Test
public void mapReferencedBigQueryDataTableTest() throws Exception {
    String projectId = RandomStringUtils.randomAlphabetic(12);
    String datasetName = RandomStringUtils.randomAlphabetic(12);
    String datatableName = RandomStringUtils.randomAlphabetic(12);
    var resource = new ReferencedBigQueryDataTableResource(workspaceId, resourceId, resourceName, description, cloning, projectId, datasetName, datatableName);
    ApiResourceDescription resourceDescription = resourceController.makeApiResourceDescription(resource);
    validateWsmResource(resourceDescription);
    ApiResourceAttributesUnion union = resourceDescription.getResourceAttributes();
    ApiGcpBigQueryDataTableAttributes attributes = union.getGcpBqDataTable();
    assertThat(attributes, is(notNullValue()));
    assertEquals(attributes.getDatasetId(), datasetName);
    assertEquals(attributes.getProjectId(), projectId);
    assertEquals(attributes.getDataTableId(), datatableName);
}
Also used : ApiGcpBigQueryDataTableAttributes(bio.terra.workspace.generated.model.ApiGcpBigQueryDataTableAttributes) ApiResourceDescription(bio.terra.workspace.generated.model.ApiResourceDescription) ApiResourceAttributesUnion(bio.terra.workspace.generated.model.ApiResourceAttributesUnion) ReferencedBigQueryDataTableResource(bio.terra.workspace.service.resource.referenced.cloud.gcp.bqdatatable.ReferencedBigQueryDataTableResource) BaseUnitTest(bio.terra.workspace.common.BaseUnitTest) Test(org.junit.jupiter.api.Test)

Example 5 with ApiResourceDescription

use of bio.terra.workspace.generated.model.ApiResourceDescription in project terra-workspace-manager by DataBiosphere.

the class ResourceController method makeApiResourceDescription.

// Convert a WsmResource into the API format for enumeration
@VisibleForTesting
public ApiResourceDescription makeApiResourceDescription(WsmResource wsmResource) {
    ApiResourceMetadata common = wsmResource.toApiMetadata();
    ApiResourceAttributesUnion union = wsmResource.toApiAttributesUnion();
    return new ApiResourceDescription().metadata(common).resourceAttributes(union);
}
Also used : ApiResourceMetadata(bio.terra.workspace.generated.model.ApiResourceMetadata) ApiResourceDescription(bio.terra.workspace.generated.model.ApiResourceDescription) ApiResourceAttributesUnion(bio.terra.workspace.generated.model.ApiResourceAttributesUnion) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

ApiResourceAttributesUnion (bio.terra.workspace.generated.model.ApiResourceAttributesUnion)6 ApiResourceDescription (bio.terra.workspace.generated.model.ApiResourceDescription)6 BaseUnitTest (bio.terra.workspace.common.BaseUnitTest)4 Test (org.junit.jupiter.api.Test)4 ApiResourceMetadata (bio.terra.workspace.generated.model.ApiResourceMetadata)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ControllerValidationUtils (bio.terra.workspace.common.utils.ControllerValidationUtils)1 ResourceApi (bio.terra.workspace.generated.controller.ResourceApi)1 ApiDataRepoSnapshotAttributes (bio.terra.workspace.generated.model.ApiDataRepoSnapshotAttributes)1 ApiGcpBigQueryDataTableAttributes (bio.terra.workspace.generated.model.ApiGcpBigQueryDataTableAttributes)1 ApiGcpBigQueryDatasetAttributes (bio.terra.workspace.generated.model.ApiGcpBigQueryDatasetAttributes)1 ApiGcpGcsBucketAttributes (bio.terra.workspace.generated.model.ApiGcpGcsBucketAttributes)1 ApiResourceList (bio.terra.workspace.generated.model.ApiResourceList)1 ApiResourceType (bio.terra.workspace.generated.model.ApiResourceType)1 ApiStewardshipType (bio.terra.workspace.generated.model.ApiStewardshipType)1 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)1 AuthenticatedUserRequestFactory (bio.terra.workspace.service.iam.AuthenticatedUserRequestFactory)1 SamConstants (bio.terra.workspace.service.iam.model.SamConstants)1 WsmResourceService (bio.terra.workspace.service.resource.WsmResourceService)1 StewardshipType (bio.terra.workspace.service.resource.model.StewardshipType)1