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/main/java/com/apify/client/user/User.java b/src/main/java/com/apify/client/user/User.java
index 17494d7..5818100 100644
--- a/src/main/java/com/apify/client/user/User.java
+++ b/src/main/java/com/apify/client/user/User.java
@@ -5,10 +5,20 @@
import tools.jackson.databind.JsonNode;
/**
- * An Apify user account. Private account details (available only for {@code me}) are typed below
- * where reasonably finite; {@link #getEffectivePlatformFeatures()} stays raw JSON (a fixed set of
- * feature-name keys, each with its own limits sub-object) and any other unmodelled field is still
- * reachable via {@link #getExtra()}.
+ * An Apify user account. {@link #getUsername()} is set, except for a request authenticated with an
+ * Apify Proxy password, and {@link #getProfile()} may be absent. The private fields ({@link
+ * #getId()}, {@link #getEmail()}, {@link #getProxy()}, {@link #getPlan()}, {@link
+ * #getEffectivePlatformFeatures()}, {@link #getCreatedAt()}, and {@link #getIsPaying()}) are set
+ * for {@code me}, and for another user only when the request uses a full-permission API token of
+ * that user or a token that impersonates it. {@link #getPlan()}, {@link #getEmail()}, and {@link
+ * #getProfile()} are omitted when {@code me} is requested from an Actor run. A request
+ * authenticated with an Apify Proxy password ({@code PROXY_PASSWORD} or {@code
+ * ACTOR_RUN_PROXY_PASSWORD}) gets reduced data on both endpoints: only {@link #getPlan()} (with
+ * just {@link UserPlan#getAvailableProxyGroups()}), {@link #getEffectivePlatformFeatures()}, and
+ * {@link #getIsPaying()} are set, and {@link #getId()} and {@link #getUsername()} are {@code null}.
+ * {@link #getEffectivePlatformFeatures()} stays raw JSON (a fixed set of feature-name keys, each
+ * with its own limits sub-object), and any other unmodeled field is still reachable via {@link
+ * #getExtra()}.
*/
public final class User extends ApifyResource {
private String id;
@@ -21,7 +31,7 @@ public final class User extends ApifyResource {
private Instant createdAt;
private Boolean isPaying;
- /** The unique user ID. */
+ /** The unique user ID. Private field; see the class description. */
public String getId() {
return id;
}
@@ -36,35 +46,38 @@ public UserProfile getProfile() {
return profile;
}
- /** The user's email address. Only present for {@code me}. */
+ /** The user's email address. Private field; see the class description. */
public String getEmail() {
return email;
}
- /** The user's Apify Proxy credentials and available proxy groups. Only present for {@code me}. */
+ /**
+ * The user's Apify Proxy credentials and available proxy groups. Private field; see the class
+ * description.
+ */
public UserProxy getProxy() {
return proxy;
}
- /** The user's subscription plan. Only present for {@code me}. */
+ /** The user's subscription plan. Private field; see the class description. */
public UserPlan getPlan() {
return plan;
}
/**
* The platform features actually available to the user right now (accounting for plan limits and
- * current usage), as raw JSON. Only present for {@code me}.
+ * current usage), as raw JSON. Private field; see the class description.
*/
public JsonNode getEffectivePlatformFeatures() {
return effectivePlatformFeatures;
}
- /** When the user account was created. Only present for {@code me}. */
+ /** When the user account was created. Private field; see the class description. */
public Instant getCreatedAt() {
return createdAt;
}
- /** Whether the user is on a paid plan. Only present for {@code me}. */
+ /** Whether the user is on a paid plan. Private field; see the class description. */
public Boolean getIsPaying() {
return isPaying;
}
diff --git a/src/main/java/com/apify/client/user/UserClient.java b/src/main/java/com/apify/client/user/UserClient.java
index 5bc9ff6..9284ac8 100644
--- a/src/main/java/com/apify/client/user/UserClient.java
+++ b/src/main/java/com/apify/client/user/UserClient.java
@@ -28,9 +28,9 @@ public UserClient(HttpClientCore http, String baseUrl, String id) {
}
/**
- * Fetches the user. For {@code me} it returns private account details (via {@link
- * User#getExtra()}); for other users it returns the public profile. Returns empty if the user
- * does not exist.
+ * Fetches the user: the public profile, plus the private account details for {@code me} or when a
+ * full-permission token of that user (or one that impersonates it) is used. Which fields are set
+ * is described on {@link User}. Returns empty if the user does not exist.
*/
public CompletableFuture> get() {
return ctx.getResource("", new QueryParams(), User.class);
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.
diff --git a/src/test/java/com/apify/client/ClientInputTest.java b/src/test/java/com/apify/client/ClientInputTest.java
index d3cf95f..b797fc5 100644
--- a/src/test/java/com/apify/client/ClientInputTest.java
+++ b/src/test/java/com/apify/client/ClientInputTest.java
@@ -241,6 +241,21 @@ void scheduleToleratesANullUiState() {
assertEquals("advanced", schedule.getUiState().get("mode").asString());
}
+ @Test
+ void userAuthenticatedWithAProxyPasswordHasOnlyTheReducedFields() {
+ MockTransport backend =
+ MockTransport.ofConstant(
+ 200,
+ "{\"data\":{\"plan\":{\"availableProxyGroups\":{\"GOOGLE_SERP\":200}},"
+ + "\"effectivePlatformFeatures\":{},\"isPaying\":true}}");
+ var user = client(backend).me().get().join().orElseThrow();
+ assertEquals(null, user.getId());
+ assertEquals(null, user.getUsername());
+ assertEquals(200, user.getPlan().getAvailableProxyGroups().get("GOOGLE_SERP").asLong());
+ assertTrue(user.getEffectivePlatformFeatures().isObject());
+ assertTrue(user.getIsPaying());
+ }
+
@Test
void aPendingRequestKeepsANullHandledAt() {
MockTransport backend =
diff --git a/src/test/java/com/apify/client/examples/GetAccount.java b/src/test/java/com/apify/client/examples/GetAccount.java
index 1d7dea5..ffe5f4b 100644
--- a/src/test/java/com/apify/client/examples/GetAccount.java
+++ b/src/test/java/com/apify/client/examples/GetAccount.java
@@ -20,7 +20,7 @@ public static void main(String[] args) {
}
System.out.println("Account ID: " + user.get().getId());
System.out.println("Username: " + user.get().getUsername());
- // email/plan/proxy/... are only populated for me() (not user(id)); any remaining unmodelled
+ // email/plan/proxy/... are private fields that are set for me(); any remaining unmodeled
// account field is still available via the untyped extras map that getExtra() returns.
System.out.println("Email: " + user.get().getEmail());
}
diff --git a/src/test/java/com/apify/client/integration/UserIntegrationTest.java b/src/test/java/com/apify/client/integration/UserIntegrationTest.java
index 658fa59..6e8d784 100644
--- a/src/test/java/com/apify/client/integration/UserIntegrationTest.java
+++ b/src/test/java/com/apify/client/integration/UserIntegrationTest.java
@@ -21,9 +21,8 @@ void getUserById() {
ApifyClient client = requireClient();
var me = client.me().get().join();
assertTrue(me.isPresent());
- // The account's own id is always a valid target for the by-id accessor (public profile view),
- // covering `ApifyClient.user(id)` in addition to the `me()` convenience already exercised
- // above.
+ // The account's own id is always a valid target for the by-id accessor, covering
+ // `ApifyClient.user(id)` in addition to the `me()` convenience already exercised above.
var byId = client.user(me.get().getId()).get().join();
assertTrue(byId.isPresent());
}