use of bio.terra.workspace.model.WorkspaceDescription in project terra-cli by DataBiosphere.
the class Workspace method get.
/**
* Fetch an existing workspace, with resources populated
*
* @param id workspace id
*/
public static Workspace get(UUID id) {
// call WSM to fetch the existing workspace object and backing Google context
WorkspaceDescription loadedWorkspace = WorkspaceManagerService.fromContext().getWorkspace(id);
logger.info("Loaded workspace: {}", loadedWorkspace);
// convert the WSM object to a CLI object
Workspace workspace = new Workspace(loadedWorkspace);
workspace.populateResources();
return workspace;
}
use of bio.terra.workspace.model.WorkspaceDescription in project terra-cli by DataBiosphere.
the class Workspace method create.
/**
* Create a new workspace and set it as the current workspace.
*
* @param name optional display name
* @param description optional description
*/
public static Workspace create(String name, String description) {
// call WSM to create the workspace object and backing Google context
WorkspaceDescription createdWorkspace = WorkspaceManagerService.fromContext().createWorkspace(name, description);
logger.info("Created workspace: {}", createdWorkspace);
// convert the WSM object to a CLI object
Workspace workspace = new Workspace(createdWorkspace);
// update the global context with the current workspace
Context.setWorkspace(workspace);
// fetch the pet SA email for the user + this workspace
// do this here so we have them stored locally before the user tries to run an app in the
// workspace. this is so we pay the cost of a SAM round-trip ahead of time, instead of slowing
// down an app call
Context.requireUser().fetchPetSaEmail();
return workspace;
}
use of bio.terra.workspace.model.WorkspaceDescription in project terra-workspace-manager by DataBiosphere.
the class WorkspaceLifecycle method doUserJourney.
@Override
public void doUserJourney(TestUserSpecification testUser, WorkspaceApi workspaceApi) throws ApiException {
UUID workspaceId = UUID.randomUUID();
CreateWorkspaceRequestBody requestBody = new CreateWorkspaceRequestBody().id(workspaceId).stage(WorkspaceStageModel.MC_WORKSPACE);
workspaceApi.createWorkspace(requestBody);
ClientTestUtils.assertHttpSuccess(workspaceApi, "CREATE workspace");
WorkspaceDescription workspaceDescription = workspaceApi.getWorkspace(workspaceId);
ClientTestUtils.assertHttpSuccess(workspaceApi, "GET workspace");
assertThat(workspaceDescription.getId(), equalTo(workspaceId));
assertThat(workspaceDescription.getStage(), equalTo(WorkspaceStageModel.MC_WORKSPACE));
UpdateWorkspaceRequestBody updateBody = new UpdateWorkspaceRequestBody().displayName(workspaceName).description(workspaceDescriptionString);
WorkspaceDescription updatedDescription = workspaceApi.updateWorkspace(updateBody, workspaceId);
ClientTestUtils.assertHttpSuccess(workspaceApi, "PATCH workspace");
assertThat(updatedDescription.getDisplayName(), equalTo(workspaceName));
assertThat(updatedDescription.getDescription(), equalTo(workspaceDescriptionString));
workspaceApi.deleteWorkspace(workspaceId);
ClientTestUtils.assertHttpSuccess(workspaceApi, "DELETE workspace");
}
use of bio.terra.workspace.model.WorkspaceDescription in project terra-cli by DataBiosphere.
the class WorkspaceManagerService method getWorkspace.
/**
* Call the Workspace Manager GET "/api/workspaces/v1/{id}" endpoint to fetch an existing
* workspace.
*
* @param workspaceId the id of the workspace to fetch
* @return the Workspace Manager workspace description object
*/
public WorkspaceDescription getWorkspace(UUID workspaceId) {
WorkspaceDescription workspaceWithContext = callWithRetries(() -> new WorkspaceApi(apiClient).getWorkspace(workspaceId), "Error fetching workspace");
String googleProjectId = (workspaceWithContext.getGcpContext() == null) ? null : workspaceWithContext.getGcpContext().getProjectId();
logger.info("Workspace context: {}, project id: {}", workspaceWithContext.getId(), googleProjectId);
return workspaceWithContext;
}
use of bio.terra.workspace.model.WorkspaceDescription in project terra-cli by DataBiosphere.
the class Workspace method update.
/**
* Update the mutable properties of the current workspace.
*
* @param name optional display name
* @param description optional description
* @throws UserActionableException if there is no current workspace
*/
public Workspace update(@Nullable String name, @Nullable String description) {
// call WSM to update the existing workspace object
WorkspaceDescription updatedWorkspace = WorkspaceManagerService.fromContext().updateWorkspace(id, name, description);
logger.info("Updated workspace: {}", updatedWorkspace);
// convert the WSM object to a CLI object
Workspace workspace = new Workspace(updatedWorkspace);
// update the global context with the current workspace
Context.setWorkspace(workspace);
return workspace;
}
Aggregations