@@ -58,6 +58,55 @@ public CompletableFuture<Server> getServerById(String id) {
5858 });
5959 }
6060
61+ @ Override
62+ public CompletableFuture <Server > getServerByNumericalId (String groupName , int numericalId ) {
63+ return CompletableFuture .supplyAsync (() -> {
64+ try {
65+ ServerQuery query = ServerQuery .create ()
66+ .filterByServerGroupName (groupName )
67+ .filterByNumericalId (numericalId );
68+ ModelsListServersResponse serversResponse = executeQuery (query );
69+
70+ List <ModelsServerSummary > servers = serversResponse .getServers ();
71+ if (servers == null ) {
72+ return null ;
73+ }
74+
75+ for (ModelsServerSummary summary : servers ) {
76+ if (summary .getNumericalId () != null && summary .getNumericalId () == numericalId ) {
77+ return new ServerImpl (summary );
78+ }
79+ }
80+ throw new RuntimeException ("Server not found in group " + groupName + " with numerical ID " + numericalId );
81+
82+ } catch (ApiException e ) {
83+ throw new RuntimeException (e );
84+ }
85+ });
86+ }
87+
88+ @ Override
89+ public CompletableFuture <List <Server >> getServersByGroup (String groupName ) {
90+ return CompletableFuture .supplyAsync (() -> {
91+ try {
92+ ServerQuery query = ServerQuery .create ()
93+ .filterByServerGroupName (groupName );
94+ ModelsListServersResponse serversResponse = executeQuery (query );
95+
96+ List <ModelsServerSummary > servers = serversResponse .getServers ();
97+ if (servers == null ) {
98+ return List .of ();
99+ }
100+
101+ return servers .stream ()
102+ .<Server >map (ServerImpl ::new )
103+ .toList ();
104+ } catch (ApiException e ) {
105+ throw new RuntimeException (e );
106+ }
107+ });
108+ }
109+
61110 @ Override
62111 public CompletableFuture <List <Server >> getAllServers (@ Nullable ServerQuery query ) {
63112 return CompletableFuture .supplyAsync (() -> {
0 commit comments