@Test public void getProjectArchiveWithRedirect10Times() throws IOException, InterruptedException { String redirectUrl = String.format("https: for (int i = 0; i < 10; i++) { mockWebServer.enqueue(new MockResponse().setResponseCode(303).setHeader("Location", redirectUrl)); } try { client.getProjectArchive(Id.of("42"), "12345678-abcdef"); assertTrue(false); } catch (WebApplicationException e) { assertThat(mockWebServer.getRequestCount(), is(10)); assertThat(mockWebServer.takeRequest().getPath(), is("/api/projects/42/archive?revision=12345678-abcdef")); for (int i = 0; i < 10 - 1; i++) { assertThat(mockWebServer.takeRequest().getPath(), is("/redirect/pathname")); } } }
public InputStream getProjectArchive(Id projId, String revision) { WebTarget webTarget = target("/api/projects/{id}/archive") .resolveTemplate("id", projId) .queryParam("revision", revision); webTarget = addDisableDirectDownloadParam(webTarget); return withFollowingRedirect(webTarget, (wt, lastResponse) -> { Invocation.Builder request = wt.request(); if (!lastResponse.isPresent()) { request.headers(headers.get()); } return invokeWithRetry(request.buildGet()) .readEntity(InputStream.class); } ); }
DigdagClient implements AutoCloseable { public InputStream getProjectArchive(Id projId, String revision) { WebTarget webTarget = target("/api/projects/{id}/archive") .resolveTemplate("id", projId) .queryParam("revision", revision); webTarget = addDisableDirectDownloadParam(webTarget); return withFollowingRedirect(webTarget, (wt, lastResponse) -> { Invocation.Builder request = wt.request(); if (!lastResponse.isPresent()) { request.headers(headers.get()); } return invokeWithRetry(request.buildGet()) .readEntity(InputStream.class); } ); } }
DigdagClient implements AutoCloseable { public InputStream getProjectArchive(Id projId, String revision) { WebTarget webTarget = target("/api/projects/{id}/archive") .resolveTemplate("id", projId) .queryParam("revision", revision); webTarget = addDisableDirectDownloadParam(webTarget); return withFollowingRedirect(webTarget, (wt, lastResponse) -> { Invocation.Builder request = wt.request(); if (!lastResponse.isPresent()) { request.headers(headers.get()); } return invokeWithRetry(request.buildGet()) .readEntity(InputStream.class); } ); } private  DigdagClient(Builder builder); }
DigdagClient implements AutoCloseable { public InputStream getProjectArchive(Id projId, String revision) { WebTarget webTarget = target("/api/projects/{id}/archive") .resolveTemplate("id", projId) .queryParam("revision", revision); webTarget = addDisableDirectDownloadParam(webTarget); return withFollowingRedirect(webTarget, (wt, lastResponse) -> { Invocation.Builder request = wt.request(); if (!lastResponse.isPresent()) { request.headers(headers.get()); } return invokeWithRetry(request.buildGet()) .readEntity(InputStream.class); } ); } 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); }
DigdagClient implements AutoCloseable { public InputStream getProjectArchive(Id projId, String revision) { WebTarget webTarget = target("/api/projects/{id}/archive") .resolveTemplate("id", projId) .queryParam("revision", revision); webTarget = addDisableDirectDownloadParam(webTarget); return withFollowingRedirect(webTarget, (wt, lastResponse) -> { Invocation.Builder request = wt.request(); if (!lastResponse.isPresent()) { request.headers(headers.get()); } return invokeWithRetry(request.buildGet()) .readEntity(InputStream.class); } ); } 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);  }