File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed
main/java/cloud/dnation/hetznerclient
java/cloud/dnation/hetznerclient Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 3030 * For full version, check <a href="https://docs.hetzner.cloud/">official documentation</a>
3131 */
3232public interface HetznerApi {
33+
34+ /**
35+ * Get/poll the status of an asynchronous API on the Hetzner Cloud.
36+ * <p>Normally, the rate limit of this API is higher and separate from the other API calls,
37+ * as it is preferred to poll the /actions endpoint to wait for an asynchronous action to complete.</p>
38+ * @param actionId the ID of the action whose status you want to poll
39+ * @return the full Action object, including its current status
40+ */
41+ @ GET ("/v1/actions/{id}" )
42+ Call <ActionResponse > getActionById (@ Path ("id" ) Long actionId );
43+
3344 /**
3445 * Get all images that matches given label expression.
3546 *
Original file line number Diff line number Diff line change @@ -51,6 +51,22 @@ public static void tearDownAfterClass() throws IOException {
5151 ws .close ();
5252 }
5353
54+ @ Test
55+ public void testGetActionById () throws IOException {
56+ ws .enqueue (new MockResponse ()
57+ .setBody (resourceAsString ("get-action-by-id.json" ))
58+ );
59+ Call <ActionResponse > call = api .getActionById (603984077612933L );
60+ ActionResponse result = call .execute ().body ();
61+ assertEquals ("delete_server" , result .getAction ().getCommand ());
62+ assertEquals (100 , result .getAction ().getProgress ().intValue ());
63+ assertEquals ("success" , result .getAction ().getStatus ());
64+ assertNull (result .getAction ().getError ());
65+ List <IdentifiableResource > relatedResources = result .getAction ().getResources ();
66+ assertEquals (1 , relatedResources .size ());
67+ assertEquals (117017457L , relatedResources .get (0 ).getId ().longValue ());
68+ }
69+
5470 @ Test
5571 public void testGetNetworkById () throws IOException {
5672 ws .enqueue (new MockResponse ()
Original file line number Diff line number Diff line change 1+ {
2+ "action" : {
3+ "id" : 603984077612933 ,
4+ "command" : " delete_server" ,
5+ "started" : " 2026-01-08T17:33:08Z" ,
6+ "finished" : " 2026-01-08T17:33:13Z" ,
7+ "progress" : 100 ,
8+ "status" : " success" ,
9+ "resources" : [
10+ {
11+ "id" : 117017457 ,
12+ "type" : " server"
13+ }
14+ ],
15+ "error" : null
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments