Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected Predicate<Integer> provideDropletTerminatedPredicate(final DigitalOcea

@Provides
@Named(TIMEOUT_IMAGE_AVAILABLE)
protected Predicate<Integer> provideImageAvailablePredicate(final DigitalOcean2Api api, Timeouts timeouts,
protected Predicate<Long> provideImageAvailablePredicate(final DigitalOcean2Api api, Timeouts timeouts,
PollPeriod pollPeriod) {
return retry(new ActionDonePredicate(api), timeouts.imageAvailable, pollPeriod.pollInitialPeriod,
pollPeriod.pollMaxPeriod);
Expand All @@ -138,14 +138,14 @@ protected Predicate<Region> provideRegionAvailablePredicate(final DigitalOcean2A
}

@Provides
protected Predicate<Integer> provideActionCompletedPredicate(final DigitalOcean2Api api, Timeouts timeouts,
protected Predicate<Long> provideActionCompletedPredicate(final DigitalOcean2Api api, Timeouts timeouts,
PollPeriod pollPeriod) {
return retry(new ActionDonePredicate(api), timeouts.imageAvailable, pollPeriod.pollInitialPeriod,
pollPeriod.pollMaxPeriod);
}

@VisibleForTesting
static class ActionDonePredicate implements Predicate<Integer> {
static class ActionDonePredicate implements Predicate<Long> {

private final DigitalOcean2Api api;

Expand All @@ -154,7 +154,7 @@ public ActionDonePredicate(DigitalOcean2Api api) {
}

@Override
public boolean apply(Integer input) {
public boolean apply(Long input) {
checkNotNull(input, "action id cannot be null");
Action current = api.actionApi().get(input);
switch (current.status()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ public class DigitalOcean2ImageExtension implements ImageExtension {
protected Logger logger = Logger.NULL;

private final DigitalOcean2Api api;
private final Predicate<Integer> imageAvailablePredicate;
private final Predicate<Long> imageAvailablePredicate;
private final Predicate<Integer> nodeRunningPredicate;
private final Function<ImageInRegion, Image> imageTransformer;
private final ListeningExecutorService userExecutor;

@Inject DigitalOcean2ImageExtension(DigitalOcean2Api api,
@Named(TIMEOUT_IMAGE_AVAILABLE) Predicate<Integer> imageAvailablePredicate,
@Named(TIMEOUT_IMAGE_AVAILABLE) Predicate<Long> imageAvailablePredicate,
@Named(TIMEOUT_NODE_RUNNING) Predicate<Integer> nodeRunningPredicate,
Function<ImageInRegion, Image> imageTransformer,
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static Status fromValue(String value) {
}
}

public abstract int id();
public abstract long id();
public abstract Status status();
public abstract String type();
public abstract Date startedAt();
Expand All @@ -61,7 +61,7 @@ public static Status fromValue(String value) {

@SerializedNames({ "id", "status", "type", "started_at", "completed_at", "resource_id", "resource_type",
"region", "region_slug" })
public static Action create(int id, Status status, String type, Date startedAt, Date completedAt, long resourceId,
public static Action create(long id, Status status, String type, Date startedAt, Date completedAt, long resourceId,
String resourceType, Region region, String regionSlug) {
return new AutoValue_Action(id, status, type, startedAt, completedAt, resourceId, resourceType, region,
regionSlug);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public abstract static class Links {

@AutoValue
public abstract static class ActionLink {
public abstract int id();
public abstract long id();
public abstract String rel();
public abstract URI href();

@SerializedNames({"id", "rel", "href"})
public static ActionLink create(int id, String rel, URI href) {
public static ActionLink create(long id, String rel, URI href) {
return new AutoValue_DropletCreate_Links_ActionLink(id, rel, href);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected IterableWithMarker<Action> fetchPageUsingOptions(ListOptions options,
@Path("/{id}")
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Action get(@PathParam("id") int id);
Action get(@PathParam("id") long id);

}

Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public void testActionStatusOk() {
replay(actionApi, api);

ActionDonePredicate predicate = new ActionDonePredicate(api);
assertTrue(predicate.apply(1));
assertFalse(predicate.apply(2));
assertTrue(predicate.apply(1L));
assertFalse(predicate.apply(2L));
}

public void testActionStatusError() {
Expand All @@ -61,7 +61,7 @@ public void testActionStatusError() {
ActionDonePredicate predicate = new ActionDonePredicate(api);

try {
predicate.apply(1);
predicate.apply(1L);
fail("Method should have thrown an IllegalStateException");
} catch (IllegalStateException ex) {
assertEquals(ex.getMessage(), "Resource is in invalid status: ERRORED");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

public class BaseDigitalOcean2ApiLiveTest extends BaseApiLiveTest<DigitalOcean2Api> {

private Predicate<Integer> actionCompleted;
private Predicate<Long> actionCompleted;
private Predicate<Integer> nodeTerminated;
private Predicate<Integer> nodeStopped;
private Predicate<Integer> nodeRunning;
Expand All @@ -64,7 +64,7 @@ public BaseDigitalOcean2ApiLiveTest() {

@Override protected DigitalOcean2Api create(Properties props, Iterable<Module> modules) {
Injector injector = newBuilder().modules(modules).overrides(props).buildInjector();
actionCompleted = injector.getInstance(Key.get(new TypeLiteral<Predicate<Integer>>(){}));
actionCompleted = injector.getInstance(Key.get(new TypeLiteral<Predicate<Long>>(){}));
nodeTerminated = injector.getInstance(Key.get(new TypeLiteral<Predicate<Integer>>(){},
Names.named(TIMEOUT_NODE_TERMINATED)));
nodeStopped = injector.getInstance(Key.get(new TypeLiteral<Predicate<Integer>>(){},
Expand All @@ -79,7 +79,7 @@ public BaseDigitalOcean2ApiLiveTest() {
.build();
}

protected void assertActionCompleted(int actionId) {
protected void assertActionCompleted(long actionId) {
assertTrue(actionCompleted.apply(actionId), String.format("Action %s did not complete in the configured timeout", actionId));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"links": {
"actions": [
{
"id": 35383956,
"id": 2512718872,
"rel": "create",
"href": "https://api.digitalocean.com/v2/actions/35383956"
"href": "https://api.digitalocean.com/v2/actions/2512718872"
}
]
}
Expand Down