resurrect(RunResurrectOptions options) {
/**
* Charges for a pay-per-event Actor run: records occurrences of a named event. Only meaningful
- * for runs of pay-per-event Actors.
+ * for runs of pay-per-event Actors. Call it from the Actor run itself, with the API token the run
+ * received at startup in the {@code APIFY_TOKEN} environment variable.
+ *
+ * To charge a request to a multi-tenant Server Actor, set {@link
+ * RunChargeOptions#requestId(String)} to the {@code X-Actor-Request-ID} header value of the
+ * request. See Charge
+ * for a request.
*
*
An idempotency key is always sent (generated if not provided), so a retried charge is
* applied at most once.
@@ -182,8 +189,7 @@ public CompletableFuture charge(RunChargeOptions options) {
body.put("requestId", requestId);
}
Map headers = Map.of(CHARGE_IDEMPOTENCY_HEADER, idempotencyKey);
- // Route through mergedParams like the run's other actions, so a last-run-seeded context charges
- // the same run its read methods resolve to (its pinned status/origin filters are preserved).
+ // Kept consistent with the other actions; there is no runs/last/charge endpoint.
String url = ctx.mergedParams(new QueryParams()).applyToUrl(ctx.subUrl("charge"));
return ctx.http
.call(
diff --git a/src/test/java/com/apify/client/ClientBehaviourRegressionTest.java b/src/test/java/com/apify/client/ClientBehaviourRegressionTest.java
index af28293..7c5c38f 100644
--- a/src/test/java/com/apify/client/ClientBehaviourRegressionTest.java
+++ b/src/test/java/com/apify/client/ClientBehaviourRegressionTest.java
@@ -103,6 +103,40 @@ void lastRunForwardsStatusFilterToNestedStorages() {
assertTrue(log.lastUrl.contains("origin=API"), log.lastUrl);
}
+ @Test
+ void lastRunAbortRebootAndMetamorphCallTheLastRunEndpointsWithTheFilters() {
+ // The spec documents runs/last/{abort,reboot,metamorph} for Actors and tasks, so these calls
+ // on a filtered last-run client must keep the pinned status and origin filters.
+ LastRunOptions filters = new LastRunOptions().status("RUNNING").origin("API");
+ String runBody = "{\"data\":{\"id\":\"run123\"}}";
+
+ MockTransport abort = MockTransport.ofConstant(200, runBody);
+ client(abort).actor("me/x").lastRun(filters).abort(null).join();
+ assertLastRunUrl(abort.lastUrl, "actors/me~x/runs/last/abort");
+
+ MockTransport reboot = MockTransport.ofConstant(200, runBody);
+ client(reboot).actor("me/x").lastRun(filters).reboot().join();
+ assertLastRunUrl(reboot.lastUrl, "actors/me~x/runs/last/reboot");
+
+ MockTransport metamorph = MockTransport.ofConstant(200, runBody);
+ client(metamorph)
+ .actor("me/x")
+ .lastRun(filters)
+ .metamorph("apify/other-actor", Map.of("foo", "bar"), new MetamorphOptions())
+ .join();
+ assertLastRunUrl(metamorph.lastUrl, "actors/me~x/runs/last/metamorph");
+
+ MockTransport taskAbort = MockTransport.ofConstant(200, runBody);
+ client(taskAbort).task("me/t").lastRun(filters).abort(null).join();
+ assertLastRunUrl(taskAbort.lastUrl, "actor-tasks/me~t/runs/last/abort");
+ }
+
+ private static void assertLastRunUrl(String url, String expectedPath) {
+ assertTrue(url.contains(expectedPath), url);
+ assertTrue(url.contains("status=RUNNING"), url);
+ assertTrue(url.contains("origin=API"), url);
+ }
+
@Test
void plainRunNestedStoragesCarryNoInheritedFilter() {
// A non-last-run client has no pinned params, so nested accessors stay filter-free.