mirror of
https://github.com/LukeHagar/plexjava.git
synced 2025-12-11 04:20:58 +00:00
ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.406.0
This commit is contained in:
@@ -32,27 +32,19 @@ import dev.plexapi.sdk.models.operations.StopTaskRequest;
|
||||
import dev.plexapi.sdk.models.operations.StopTaskRequestBuilder;
|
||||
import dev.plexapi.sdk.models.operations.StopTaskResponse;
|
||||
import dev.plexapi.sdk.models.operations.TaskName;
|
||||
import dev.plexapi.sdk.utils.BackoffStrategy;
|
||||
import dev.plexapi.sdk.utils.HTTPClient;
|
||||
import dev.plexapi.sdk.utils.HTTPRequest;
|
||||
import dev.plexapi.sdk.utils.Hook.AfterErrorContextImpl;
|
||||
import dev.plexapi.sdk.utils.Hook.AfterSuccessContextImpl;
|
||||
import dev.plexapi.sdk.utils.Hook.BeforeRequestContextImpl;
|
||||
import dev.plexapi.sdk.utils.Options;
|
||||
import dev.plexapi.sdk.utils.Retries.NonRetryableException;
|
||||
import dev.plexapi.sdk.utils.Retries;
|
||||
import dev.plexapi.sdk.utils.RetryConfig;
|
||||
import dev.plexapi.sdk.utils.Utils;
|
||||
import java.io.InputStream;
|
||||
import java.lang.Exception;
|
||||
import java.lang.String;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Butler is the task manager of the Plex Media Server Ecosystem.
|
||||
@@ -88,22 +80,6 @@ public class Butler implements
|
||||
* @throws Exception if the API call fails
|
||||
*/
|
||||
public GetButlerTasksResponse getButlerTasksDirect() throws Exception {
|
||||
return getButlerTasks(Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Butler tasks
|
||||
* Returns a list of butler tasks
|
||||
* @param options additional options
|
||||
* @return The response from the API call
|
||||
* @throws Exception if the API call fails
|
||||
*/
|
||||
public GetButlerTasksResponse getButlerTasks(
|
||||
Optional<Options> options) throws Exception {
|
||||
|
||||
if (options.isPresent()) {
|
||||
options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
|
||||
}
|
||||
String _baseUrl = Utils.templateUrl(
|
||||
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
|
||||
String _url = Utils.generateURL(
|
||||
@@ -119,62 +95,45 @@ public class Butler implements
|
||||
this.sdkConfiguration.securitySource.getSecurity());
|
||||
|
||||
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
||||
HTTPRequest _finalReq = _req;
|
||||
RetryConfig _retryConfig;
|
||||
if (options.isPresent() && options.get().retryConfig().isPresent()) {
|
||||
_retryConfig = options.get().retryConfig().get();
|
||||
} else if (this.sdkConfiguration.retryConfig.isPresent()) {
|
||||
_retryConfig = this.sdkConfiguration.retryConfig.get();
|
||||
} else {
|
||||
_retryConfig = RetryConfig.builder()
|
||||
.backoff(BackoffStrategy.builder()
|
||||
.initialInterval(500, TimeUnit.MILLISECONDS)
|
||||
.maxInterval(60000, TimeUnit.MILLISECONDS)
|
||||
.baseFactor((double)(1.5))
|
||||
.maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
|
||||
.retryConnectError(true)
|
||||
.build())
|
||||
.build();
|
||||
HttpRequest _r =
|
||||
sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"getButlerTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_req.build());
|
||||
HttpResponse<InputStream> _httpRes;
|
||||
try {
|
||||
_httpRes = _client.send(_r);
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"getButlerTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.of(_httpRes),
|
||||
Optional.empty());
|
||||
} else {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"getButlerTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_httpRes);
|
||||
}
|
||||
} catch (Exception _e) {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"getButlerTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.empty(),
|
||||
Optional.of(_e));
|
||||
}
|
||||
List<String> _statusCodes = new ArrayList<>();
|
||||
_statusCodes.add("5XX");
|
||||
Retries _retries = Retries.builder()
|
||||
.action(() -> {
|
||||
HttpRequest _r = null;
|
||||
try {
|
||||
_r = sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"getButlerTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_finalReq.build());
|
||||
} catch (Exception _e) {
|
||||
throw new NonRetryableException(_e);
|
||||
}
|
||||
try {
|
||||
return _client.send(_r);
|
||||
} catch (Exception _e) {
|
||||
return sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"getButlerTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.empty(),
|
||||
Optional.of(_e));
|
||||
}
|
||||
})
|
||||
.retryConfig(_retryConfig)
|
||||
.statusCodes(_statusCodes)
|
||||
.build();
|
||||
HttpResponse<InputStream> _httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"getButlerTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_retries.run());
|
||||
String _contentType = _httpRes
|
||||
.headers()
|
||||
.firstValue("Content-Type")
|
||||
@@ -278,27 +237,6 @@ public class Butler implements
|
||||
* @throws Exception if the API call fails
|
||||
*/
|
||||
public StartAllTasksResponse startAllTasksDirect() throws Exception {
|
||||
return startAllTasks(Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Start all Butler tasks
|
||||
* This endpoint will attempt to start all Butler tasks that are enabled in the settings. Butler tasks normally run automatically during a time window configured on the server's Settings page but can be manually started using this endpoint. Tasks will run with the following criteria:
|
||||
* 1. Any tasks not scheduled to run on the current day will be skipped.
|
||||
* 2. If a task is configured to run at a random time during the configured window and we are outside that window, the task will start immediately.
|
||||
* 3. If a task is configured to run at a random time during the configured window and we are within that window, the task will be scheduled at a random time within the window.
|
||||
* 4. If we are outside the configured window, the task will start immediately.
|
||||
*
|
||||
* @param options additional options
|
||||
* @return The response from the API call
|
||||
* @throws Exception if the API call fails
|
||||
*/
|
||||
public StartAllTasksResponse startAllTasks(
|
||||
Optional<Options> options) throws Exception {
|
||||
|
||||
if (options.isPresent()) {
|
||||
options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
|
||||
}
|
||||
String _baseUrl = Utils.templateUrl(
|
||||
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
|
||||
String _url = Utils.generateURL(
|
||||
@@ -314,62 +252,45 @@ public class Butler implements
|
||||
this.sdkConfiguration.securitySource.getSecurity());
|
||||
|
||||
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
||||
HTTPRequest _finalReq = _req;
|
||||
RetryConfig _retryConfig;
|
||||
if (options.isPresent() && options.get().retryConfig().isPresent()) {
|
||||
_retryConfig = options.get().retryConfig().get();
|
||||
} else if (this.sdkConfiguration.retryConfig.isPresent()) {
|
||||
_retryConfig = this.sdkConfiguration.retryConfig.get();
|
||||
} else {
|
||||
_retryConfig = RetryConfig.builder()
|
||||
.backoff(BackoffStrategy.builder()
|
||||
.initialInterval(500, TimeUnit.MILLISECONDS)
|
||||
.maxInterval(60000, TimeUnit.MILLISECONDS)
|
||||
.baseFactor((double)(1.5))
|
||||
.maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
|
||||
.retryConnectError(true)
|
||||
.build())
|
||||
.build();
|
||||
HttpRequest _r =
|
||||
sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"startAllTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_req.build());
|
||||
HttpResponse<InputStream> _httpRes;
|
||||
try {
|
||||
_httpRes = _client.send(_r);
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"startAllTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.of(_httpRes),
|
||||
Optional.empty());
|
||||
} else {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"startAllTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_httpRes);
|
||||
}
|
||||
} catch (Exception _e) {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"startAllTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.empty(),
|
||||
Optional.of(_e));
|
||||
}
|
||||
List<String> _statusCodes = new ArrayList<>();
|
||||
_statusCodes.add("5XX");
|
||||
Retries _retries = Retries.builder()
|
||||
.action(() -> {
|
||||
HttpRequest _r = null;
|
||||
try {
|
||||
_r = sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"startAllTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_finalReq.build());
|
||||
} catch (Exception _e) {
|
||||
throw new NonRetryableException(_e);
|
||||
}
|
||||
try {
|
||||
return _client.send(_r);
|
||||
} catch (Exception _e) {
|
||||
return sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"startAllTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.empty(),
|
||||
Optional.of(_e));
|
||||
}
|
||||
})
|
||||
.retryConfig(_retryConfig)
|
||||
.statusCodes(_statusCodes)
|
||||
.build();
|
||||
HttpResponse<InputStream> _httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"startAllTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_retries.run());
|
||||
String _contentType = _httpRes
|
||||
.headers()
|
||||
.firstValue("Content-Type")
|
||||
@@ -454,23 +375,6 @@ public class Butler implements
|
||||
* @throws Exception if the API call fails
|
||||
*/
|
||||
public StopAllTasksResponse stopAllTasksDirect() throws Exception {
|
||||
return stopAllTasks(Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop all Butler tasks
|
||||
* This endpoint will stop all currently running tasks and remove any scheduled tasks from the queue.
|
||||
*
|
||||
* @param options additional options
|
||||
* @return The response from the API call
|
||||
* @throws Exception if the API call fails
|
||||
*/
|
||||
public StopAllTasksResponse stopAllTasks(
|
||||
Optional<Options> options) throws Exception {
|
||||
|
||||
if (options.isPresent()) {
|
||||
options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
|
||||
}
|
||||
String _baseUrl = Utils.templateUrl(
|
||||
this.sdkConfiguration.serverUrl, this.sdkConfiguration.getServerVariableDefaults());
|
||||
String _url = Utils.generateURL(
|
||||
@@ -486,62 +390,45 @@ public class Butler implements
|
||||
this.sdkConfiguration.securitySource.getSecurity());
|
||||
|
||||
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
||||
HTTPRequest _finalReq = _req;
|
||||
RetryConfig _retryConfig;
|
||||
if (options.isPresent() && options.get().retryConfig().isPresent()) {
|
||||
_retryConfig = options.get().retryConfig().get();
|
||||
} else if (this.sdkConfiguration.retryConfig.isPresent()) {
|
||||
_retryConfig = this.sdkConfiguration.retryConfig.get();
|
||||
} else {
|
||||
_retryConfig = RetryConfig.builder()
|
||||
.backoff(BackoffStrategy.builder()
|
||||
.initialInterval(500, TimeUnit.MILLISECONDS)
|
||||
.maxInterval(60000, TimeUnit.MILLISECONDS)
|
||||
.baseFactor((double)(1.5))
|
||||
.maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
|
||||
.retryConnectError(true)
|
||||
.build())
|
||||
.build();
|
||||
HttpRequest _r =
|
||||
sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"stopAllTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_req.build());
|
||||
HttpResponse<InputStream> _httpRes;
|
||||
try {
|
||||
_httpRes = _client.send(_r);
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"stopAllTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.of(_httpRes),
|
||||
Optional.empty());
|
||||
} else {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"stopAllTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_httpRes);
|
||||
}
|
||||
} catch (Exception _e) {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"stopAllTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.empty(),
|
||||
Optional.of(_e));
|
||||
}
|
||||
List<String> _statusCodes = new ArrayList<>();
|
||||
_statusCodes.add("5XX");
|
||||
Retries _retries = Retries.builder()
|
||||
.action(() -> {
|
||||
HttpRequest _r = null;
|
||||
try {
|
||||
_r = sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"stopAllTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_finalReq.build());
|
||||
} catch (Exception _e) {
|
||||
throw new NonRetryableException(_e);
|
||||
}
|
||||
try {
|
||||
return _client.send(_r);
|
||||
} catch (Exception _e) {
|
||||
return sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"stopAllTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.empty(),
|
||||
Optional.of(_e));
|
||||
}
|
||||
})
|
||||
.retryConfig(_retryConfig)
|
||||
.statusCodes(_statusCodes)
|
||||
.build();
|
||||
HttpResponse<InputStream> _httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"stopAllTasks",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_retries.run());
|
||||
String _contentType = _httpRes
|
||||
.headers()
|
||||
.firstValue("Content-Type")
|
||||
@@ -636,29 +523,6 @@ public class Butler implements
|
||||
*/
|
||||
public StartTaskResponse startTask(
|
||||
TaskName taskName) throws Exception {
|
||||
return startTask(taskName, Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a single Butler task
|
||||
* This endpoint will attempt to start a single Butler task that is enabled in the settings. Butler tasks normally run automatically during a time window configured on the server's Settings page but can be manually started using this endpoint. Tasks will run with the following criteria:
|
||||
* 1. Any tasks not scheduled to run on the current day will be skipped.
|
||||
* 2. If a task is configured to run at a random time during the configured window and we are outside that window, the task will start immediately.
|
||||
* 3. If a task is configured to run at a random time during the configured window and we are within that window, the task will be scheduled at a random time within the window.
|
||||
* 4. If we are outside the configured window, the task will start immediately.
|
||||
*
|
||||
* @param taskName the name of the task to be started.
|
||||
* @param options additional options
|
||||
* @return The response from the API call
|
||||
* @throws Exception if the API call fails
|
||||
*/
|
||||
public StartTaskResponse startTask(
|
||||
TaskName taskName,
|
||||
Optional<Options> options) throws Exception {
|
||||
|
||||
if (options.isPresent()) {
|
||||
options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
|
||||
}
|
||||
StartTaskRequest request =
|
||||
StartTaskRequest
|
||||
.builder()
|
||||
@@ -682,62 +546,45 @@ public class Butler implements
|
||||
this.sdkConfiguration.securitySource.getSecurity());
|
||||
|
||||
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
||||
HTTPRequest _finalReq = _req;
|
||||
RetryConfig _retryConfig;
|
||||
if (options.isPresent() && options.get().retryConfig().isPresent()) {
|
||||
_retryConfig = options.get().retryConfig().get();
|
||||
} else if (this.sdkConfiguration.retryConfig.isPresent()) {
|
||||
_retryConfig = this.sdkConfiguration.retryConfig.get();
|
||||
} else {
|
||||
_retryConfig = RetryConfig.builder()
|
||||
.backoff(BackoffStrategy.builder()
|
||||
.initialInterval(500, TimeUnit.MILLISECONDS)
|
||||
.maxInterval(60000, TimeUnit.MILLISECONDS)
|
||||
.baseFactor((double)(1.5))
|
||||
.maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
|
||||
.retryConnectError(true)
|
||||
.build())
|
||||
.build();
|
||||
HttpRequest _r =
|
||||
sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"startTask",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_req.build());
|
||||
HttpResponse<InputStream> _httpRes;
|
||||
try {
|
||||
_httpRes = _client.send(_r);
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "4XX", "5XX")) {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"startTask",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.of(_httpRes),
|
||||
Optional.empty());
|
||||
} else {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"startTask",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_httpRes);
|
||||
}
|
||||
} catch (Exception _e) {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"startTask",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.empty(),
|
||||
Optional.of(_e));
|
||||
}
|
||||
List<String> _statusCodes = new ArrayList<>();
|
||||
_statusCodes.add("5XX");
|
||||
Retries _retries = Retries.builder()
|
||||
.action(() -> {
|
||||
HttpRequest _r = null;
|
||||
try {
|
||||
_r = sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"startTask",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_finalReq.build());
|
||||
} catch (Exception _e) {
|
||||
throw new NonRetryableException(_e);
|
||||
}
|
||||
try {
|
||||
return _client.send(_r);
|
||||
} catch (Exception _e) {
|
||||
return sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"startTask",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.empty(),
|
||||
Optional.of(_e));
|
||||
}
|
||||
})
|
||||
.retryConfig(_retryConfig)
|
||||
.statusCodes(_statusCodes)
|
||||
.build();
|
||||
HttpResponse<InputStream> _httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"startTask",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_retries.run());
|
||||
String _contentType = _httpRes
|
||||
.headers()
|
||||
.firstValue("Content-Type")
|
||||
@@ -824,25 +671,6 @@ public class Butler implements
|
||||
*/
|
||||
public StopTaskResponse stopTask(
|
||||
PathParamTaskName taskName) throws Exception {
|
||||
return stopTask(taskName, Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop a single Butler task
|
||||
* This endpoint will stop a currently running task by name, or remove it from the list of scheduled tasks if it exists. See the section above for a list of task names for this endpoint.
|
||||
*
|
||||
* @param taskName The name of the task to be started.
|
||||
* @param options additional options
|
||||
* @return The response from the API call
|
||||
* @throws Exception if the API call fails
|
||||
*/
|
||||
public StopTaskResponse stopTask(
|
||||
PathParamTaskName taskName,
|
||||
Optional<Options> options) throws Exception {
|
||||
|
||||
if (options.isPresent()) {
|
||||
options.get().validate(Arrays.asList(Options.Option.RETRY_CONFIG));
|
||||
}
|
||||
StopTaskRequest request =
|
||||
StopTaskRequest
|
||||
.builder()
|
||||
@@ -866,62 +694,45 @@ public class Butler implements
|
||||
this.sdkConfiguration.securitySource.getSecurity());
|
||||
|
||||
HTTPClient _client = this.sdkConfiguration.defaultClient;
|
||||
HTTPRequest _finalReq = _req;
|
||||
RetryConfig _retryConfig;
|
||||
if (options.isPresent() && options.get().retryConfig().isPresent()) {
|
||||
_retryConfig = options.get().retryConfig().get();
|
||||
} else if (this.sdkConfiguration.retryConfig.isPresent()) {
|
||||
_retryConfig = this.sdkConfiguration.retryConfig.get();
|
||||
} else {
|
||||
_retryConfig = RetryConfig.builder()
|
||||
.backoff(BackoffStrategy.builder()
|
||||
.initialInterval(500, TimeUnit.MILLISECONDS)
|
||||
.maxInterval(60000, TimeUnit.MILLISECONDS)
|
||||
.baseFactor((double)(1.5))
|
||||
.maxElapsedTime(3600000, TimeUnit.MILLISECONDS)
|
||||
.retryConnectError(true)
|
||||
.build())
|
||||
.build();
|
||||
HttpRequest _r =
|
||||
sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"stopTask",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_req.build());
|
||||
HttpResponse<InputStream> _httpRes;
|
||||
try {
|
||||
_httpRes = _client.send(_r);
|
||||
if (Utils.statusCodeMatches(_httpRes.statusCode(), "400", "401", "404", "4XX", "5XX")) {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"stopTask",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.of(_httpRes),
|
||||
Optional.empty());
|
||||
} else {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"stopTask",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_httpRes);
|
||||
}
|
||||
} catch (Exception _e) {
|
||||
_httpRes = sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"stopTask",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.empty(),
|
||||
Optional.of(_e));
|
||||
}
|
||||
List<String> _statusCodes = new ArrayList<>();
|
||||
_statusCodes.add("5XX");
|
||||
Retries _retries = Retries.builder()
|
||||
.action(() -> {
|
||||
HttpRequest _r = null;
|
||||
try {
|
||||
_r = sdkConfiguration.hooks()
|
||||
.beforeRequest(
|
||||
new BeforeRequestContextImpl(
|
||||
"stopTask",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_finalReq.build());
|
||||
} catch (Exception _e) {
|
||||
throw new NonRetryableException(_e);
|
||||
}
|
||||
try {
|
||||
return _client.send(_r);
|
||||
} catch (Exception _e) {
|
||||
return sdkConfiguration.hooks()
|
||||
.afterError(
|
||||
new AfterErrorContextImpl(
|
||||
"stopTask",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
Optional.empty(),
|
||||
Optional.of(_e));
|
||||
}
|
||||
})
|
||||
.retryConfig(_retryConfig)
|
||||
.statusCodes(_statusCodes)
|
||||
.build();
|
||||
HttpResponse<InputStream> _httpRes = sdkConfiguration.hooks()
|
||||
.afterSuccess(
|
||||
new AfterSuccessContextImpl(
|
||||
"stopTask",
|
||||
Optional.of(List.of()),
|
||||
sdkConfiguration.securitySource()),
|
||||
_retries.run());
|
||||
String _contentType = _httpRes
|
||||
.headers()
|
||||
.firstValue("Content-Type")
|
||||
|
||||
Reference in New Issue
Block a user