Skip to content

Commit

Permalink
add full_return flag for more information
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidd committed May 20, 2021
1 parent d127abb commit 396d44e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/com/suse/salt/netapi/calls/LocalCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.suse.salt.netapi.event.JobReturnEvent;
import com.suse.salt.netapi.event.RunnerReturnEvent;
import com.suse.salt.netapi.parser.JsonParser;
import com.suse.salt.netapi.results.FullReturn;
import com.suse.salt.netapi.results.Result;
import com.suse.salt.netapi.results.Return;
import com.suse.salt.netapi.results.SSHResult;
Expand Down Expand Up @@ -425,7 +426,8 @@ private CompletionStage<List<Map<String, Result<R>>>> callSyncHelperNonBlock(
Client clientType = batch.isPresent() ? Client.LOCAL_BATCH : Client.LOCAL;

Type xor = parameterizedType(null, Result.class, getReturnType().getType());
Type map = parameterizedType(null, Map.class, String.class, xor);
Type fullret = parameterizedType(null, FullReturn.class, xor);
Type map = parameterizedType(null, Map.class, String.class, fullret);
Type listType = parameterizedType(null, List.class, map);
Type wrapperType = parameterizedType(null, Return.class, listType);
TypeToken<Return<List<Map<String, Result<R>>>>> typeToken =
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/suse/salt/netapi/client/SaltClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ public <R> CompletionStage<R> call(Call<?> call, Client client, Optional<Target<
});

target.ifPresent(t -> props.putAll(t.getProps()));
props.put("full_return", true);
props.put("client", client.getValue());
props.putAll(call.getPayload());
props.putAll(custom);
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/suse/salt/netapi/results/FullReturn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.suse.salt.netapi.results;

public class FullReturn<T> {

private T ret;
private int retcode;
private String jid;

public int getRetcode() {
return retcode;
}

public String getJid() {
return jid;
}

public T getRet() {
return ret;
}

@Override
public String toString() {
return "FullReturn{" + "ret=" + ret + ", retcode=" + retcode + ", jid='" + jid + '\'' + '}';
}
}

0 comments on commit 396d44e

Please sign in to comment.