use of bio.terra.workspace.client.ApiClient in project terra-workspace-manager by DataBiosphere.
the class ClientTestUtils method buildClient.
private static ApiClient buildClient(@Nullable AccessToken accessToken, ServerSpecification server) throws IOException {
if (Strings.isNullOrEmpty(server.workspaceManagerUri)) {
throw new IllegalArgumentException("Workspace Manager Service URI cannot be empty");
}
// build the client object
ApiClient apiClient = new ApiClient();
apiClient.setBasePath(server.workspaceManagerUri);
if (accessToken != null) {
apiClient.setAccessToken(accessToken.getTokenValue());
}
return apiClient;
}
use of bio.terra.workspace.client.ApiClient in project terra-cli by DataBiosphere.
the class WorkspaceManagerService method cloneWorkspace.
/**
* Call the Workspace Manager POST "/api/workspaces/v1/{workspaceId}/clone" endpoint to clone a
* workspace.
*
* @param workspaceId - workspace ID to clone
* @param userFacingId - required userFacingId of new cloned workspace
* @param name - optional name of new cloned workspace
* @param description - optional description for new workspace
* @return object with information about the clone job success and destination workspace
*/
public CloneWorkspaceResult cloneWorkspace(UUID workspaceId, String userFacingId, @Nullable String name, @Nullable String description) {
var request = new CloneWorkspaceRequest().spendProfile(Context.getServer().getWsmDefaultSpendProfile()).userFacingId(userFacingId).displayName(name).description(description).location(null);
WorkspaceApi workspaceApi = new WorkspaceApi(apiClient);
CloneWorkspaceResult initialResult = callWithRetries(() -> workspaceApi.cloneWorkspace(request, workspaceId), "Error cloning workspace");
logger.debug("clone workspace initial result: {}", initialResult);
// poll until the workspace clone completes.
// TODO PF-745: return immediately and give some interface for checking on the job status
// and retrieving the result.
CloneWorkspaceResult cloneWorkspaceResult = handleClientExceptions(() -> HttpUtils.pollWithRetries(() -> workspaceApi.getCloneWorkspaceResult(workspaceId, initialResult.getJobReport().getId()), (result) -> isDone(result.getJobReport()), WorkspaceManagerService::isRetryable, CLONE_WORKSPACE_MAXIMUM_RETRIES, CLONE_WORKSPACE_RETRY_INTERVAL), "Error in cloning workspace.");
logger.debug("clone workspace polling result: {}", cloneWorkspaceResult);
throwIfJobNotCompleted(cloneWorkspaceResult.getJobReport(), cloneWorkspaceResult.getErrorReport());
return cloneWorkspaceResult;
}
Aggregations