private List<ScheduleDetail> doList(WorkflowId workflow) throws IOException, UnauthenticatedException, NotFoundException, UnauthorizedException { String path = String.format("apps/%s/workflows/%s/schedules", workflow.getApplication(), workflow.getProgram()); URL url = config.resolveNamespacedURLV3(workflow.getNamespaceId(), path); HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND); if (HttpURLConnection.HTTP_NOT_FOUND == response.getResponseCode()) { throw new NotFoundException(workflow); } ObjectResponse<List<ScheduleDetail>> objectResponse = ObjectResponse.fromJsonBody(response, LIST_SCHEDULE_DETAIL_TYPE, GSON); return objectResponse.getResponseObject(); }
/** * Get the next scheduled run time of the program. A program may contain multiple schedules. * This method returns the next scheduled runtimes for all the schedules. This method only takes + into account schedules based on time. Schedules based on data are ignored. * * @param workflow Id of the Workflow for which to fetch next run times. * @return list of Scheduled runtimes for the Workflow. Empty list if there are no schedules. */ public List<ScheduledRuntime> nextRuntimes(WorkflowId workflow) throws IOException, UnauthenticatedException, NotFoundException, UnauthorizedException { String path = String.format("apps/%s/workflows/%s/nextruntime", workflow.getApplication(), workflow.getProgram()); URL url = config.resolveNamespacedURLV3(workflow.getNamespaceId(), path); HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND); if (HttpURLConnection.HTTP_NOT_FOUND == response.getResponseCode()) { throw new NotFoundException(workflow); } ObjectResponse<List<ScheduledRuntime>> objectResponse = ObjectResponse.fromJsonBody( response, new TypeToken<List<ScheduledRuntime>>() { }.getType(), GSON); return objectResponse.getResponseObject(); }