DigdagClient implements AutoCloseable { public RestLogFileHandleCollection getLogFileHandlesOfAttempt(Id attemptId) { WebTarget webTarget = target("/api/logs/{id}/files") .resolveTemplate("id", attemptId); webTarget = addDisableDirectDownloadParam(webTarget); return doGet(RestLogFileHandleCollection.class, webTarget); } private  DigdagClient(Builder builder); static ObjectMapper objectMapper(); static Builder builder(); @Override void close(); Config newConfig(); RestProject getProject(String name); RestProjectCollection getProjects(); RestProject getProject(Id projId); void deleteProject(Id projId); RestRevisionCollection getRevisions(Id projId, Optional<Id> lastId); RestWorkflowDefinitionCollection getWorkflowDefinitions(); RestWorkflowDefinitionCollection getWorkflowDefinitions(Optional<Id> lastId); RestWorkflowDefinitionCollection getWorkflowDefinitions(Id projId); RestWorkflowDefinitionCollection getWorkflowDefinitions(Id projId, String revision); RestWorkflowDefinition getWorkflowDefinition(Id projId, String name); RestWorkflowDefinition getWorkflowDefinition(Id projId, String name, String revision); RestWorkflowDefinition getWorkflowDefinition(Id workflowId); RestWorkflowSessionTime getWorkflowTruncatedSessionTime(Id workflowId, LocalTimeOrInstant time); RestWorkflowSessionTime getWorkflowTruncatedSessionTime(Id workflowId, LocalTimeOrInstant time, SessionTimeTruncate mode); RestProject putProjectRevision(String projName, String revision, File body); RestProject putProjectRevision(String projName, String revision, File body, Optional<Instant> scheduleFrom); InputStream getProjectArchive(Id projId, String revision); RestScheduleCollection getSchedules(); RestScheduleCollection getSchedules(Optional<Id> lastId); RestScheduleCollection getSchedules(Id projectId, Optional<Id> lastId); RestSchedule getSchedule(Id projectId, String workflowName); RestSchedule getSchedule(Id id); RestSessionCollection getSessions(); RestSessionCollection getSessions(Optional<Id> lastId); RestSessionCollection getSessions(Id projectId); RestSessionCollection getSessions(Id projectId, Optional<Id> lastId, Optional<Integer> pageSize); RestSessionCollection getSessions(Id projectId, String workflowName); RestSessionCollection getSessions(Id projectId, String workflowName, Optional<Id> lastId, Optional<Integer> pageSize); RestSession getSession(Id sessionId); RestSessionAttemptCollection getSessionAttempts(Id sessionId, Optional<Id> lastId, Optional<Integer> pageSize); RestSessionAttemptCollection getSessionAttempts(Optional<Id> lastId, Optional<Integer> pageSize); RestSessionAttemptCollection getSessionAttempts(String projName, Optional<Id> lastId); RestSessionAttemptCollection getSessionAttempts(String projName, String workflowName, Optional<Id> lastId); RestSessionAttempt getSessionAttempt(Id attemptId); RestSessionAttemptCollection getSessionAttemptRetries(Id attemptId); RestTaskCollection getTasks(Id attemptId); RestLogFileHandleCollection getLogFileHandlesOfAttempt(Id attemptId); RestLogFileHandleCollection getLogFileHandlesOfTask(Id attemptId, String taskName); InputStream getLogFile(Id attemptId, RestLogFileHandle handle); InputStream getLogFile(Id attemptId, String fileName); RestSessionAttempt startSessionAttempt(RestSessionAttemptRequest request); void killSessionAttempt(Id attemptId); RestScheduleSummary skipSchedulesToTime(Id scheduleId, Instant untilTime, Optional<Instant> runTime, boolean dryRun); RestScheduleSummary skipSchedulesToTime(Id scheduleId, LocalDateTime untilTime, Optional<Instant> runTime, boolean dryRun); RestScheduleSummary skipSchedulesByCount(Id scheduleId, Instant fromTime, int count, Optional<Instant> runTime, boolean dryRun); RestSessionAttemptCollection backfillSchedule(Id scheduleId, Instant fromTime, String attemptName, Optional<Integer> count, boolean dryRun); RestScheduleSummary disableSchedule(Id scheduleId); RestScheduleSummary enableSchedule(Id scheduleId); Map<String, Object> getVersion(); RestVersionCheckResult checkClientVersion(String clientVersion); void setProjectSecret(Id projectId, String key, String value); void deleteProjectSecret(Id projectId, String key); RestSecretList listProjectSecrets(Id projectId); Config adminGetAttemptUserInfo(Id attemptId);  }
@Test public void getLogFileHandlesOfAttempt() throws Exception { RestLogFileHandleCollection expectedLogFileHandles = RestLogFileHandleCollection.builder() .addFiles( RestLogFileHandle.builder() .agentId("test-agent") .fileName("test-task-1.log") .fileSize(4711) .fileTime(Instant.now().truncatedTo(SECONDS)) .taskName("test-task-1") .build(), RestLogFileHandle.builder() .agentId("test-agent") .fileName("test-task-2.log") .fileSize(4712) .fileTime(Instant.now().truncatedTo(SECONDS)) .taskName("test-task-2") .build() ).build(); mockWebServer.enqueue(new MockResponse().setResponseCode(500)); mockWebServer.enqueue(new MockResponse() .setBody(objectMapper.writeValueAsString(expectedLogFileHandles)) .setHeader(CONTENT_TYPE, APPLICATION_JSON)); RestLogFileHandleCollection receivedLogFileHandles = client.getLogFileHandlesOfAttempt(Id.of("17")); assertThat(receivedLogFileHandles, is(expectedLogFileHandles)); assertThat(mockWebServer.getRequestCount(), is(2)); assertThat(mockWebServer.takeRequest().getPath(), is("/api/logs/17/files")); assertThat(mockWebServer.takeRequest().getPath(), is("/api/logs/17/files")); }