Search in sources :

Example 1 with ApiProperty

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

the class WorkspaceApiController method buildWorkspaceDescription.

private ApiWorkspaceDescription buildWorkspaceDescription(Workspace workspace) {
    ApiGcpContext gcpContext = gcpCloudContextService.getGcpCloudContext(workspace.getWorkspaceId()).map(GcpCloudContext::toApi).orElse(null);
    ApiAzureContext azureContext = azureCloudContextService.getAzureCloudContext(workspace.getWorkspaceId()).map(AzureCloudContext::toApi).orElse(null);
    // Convert the property map to API format
    ApiProperties apiProperties = new ApiProperties();
    workspace.getProperties().forEach((k, v) -> apiProperties.add(new ApiProperty().key(k).value(v)));
    // When we have another cloud context, we will need to do a similar retrieval for it.
    return new ApiWorkspaceDescription().id(workspace.getWorkspaceId()).spendProfile(workspace.getSpendProfileId().map(SpendProfileId::getId).orElse(null)).stage(workspace.getWorkspaceStage().toApiModel()).gcpContext(gcpContext).azureContext(azureContext).displayName(workspace.getDisplayName().orElse(null)).description(workspace.getDescription().orElse(null)).properties(apiProperties);
}
Also used : ApiProperty(bio.terra.workspace.generated.model.ApiProperty) ApiProperties(bio.terra.workspace.generated.model.ApiProperties) ApiGcpContext(bio.terra.workspace.generated.model.ApiGcpContext) ApiWorkspaceDescription(bio.terra.workspace.generated.model.ApiWorkspaceDescription) SpendProfileId(bio.terra.workspace.service.spendprofile.SpendProfileId) ApiAzureContext(bio.terra.workspace.generated.model.ApiAzureContext)

Example 2 with ApiProperty

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

the class WorkspaceApiController method propertyMapFromApi.

// Convert properties list into a map
private Map<String, String> propertyMapFromApi(ApiProperties properties) {
    Map<String, String> propertyMap = new HashMap<>();
    if (properties != null) {
        for (ApiProperty property : properties) {
            ControllerValidationUtils.validatePropertyKey(property.getKey());
            propertyMap.put(property.getKey(), property.getValue());
        }
    }
    return propertyMap;
}
Also used : ApiProperty(bio.terra.workspace.generated.model.ApiProperty) HashMap(java.util.HashMap)

Aggregations

ApiProperty (bio.terra.workspace.generated.model.ApiProperty)2 ApiAzureContext (bio.terra.workspace.generated.model.ApiAzureContext)1 ApiGcpContext (bio.terra.workspace.generated.model.ApiGcpContext)1 ApiProperties (bio.terra.workspace.generated.model.ApiProperties)1 ApiWorkspaceDescription (bio.terra.workspace.generated.model.ApiWorkspaceDescription)1 SpendProfileId (bio.terra.workspace.service.spendprofile.SpendProfileId)1 HashMap (java.util.HashMap)1