public class SaltClient
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private AsyncHttpClient |
asyncHttpClient
The async connection factory object
|
private com.google.gson.Gson |
gson |
private java.net.URI |
uri |
| Constructor and Description |
|---|
SaltClient(java.net.URI url,
AsyncHttpClient asyncHttpClient)
Constructor for connecting to a given URL.
|
| Modifier and Type | Method and Description |
|---|---|
<R> java.util.concurrent.CompletionStage<R> |
call(Call<?> call,
Client client,
java.util.Optional<Target<?>> target,
java.util.Map<java.lang.String,java.lang.Object> custom,
com.google.gson.reflect.TypeToken<R> type,
AuthMethod auth) |
WebSocketEventStream |
events(Token token,
long sessionIdleTimeout,
long idleTimeout,
int maxMsgSize,
EventListener... listeners)
Returns a WebSocket @ClientEndpoint annotated object connected
to the /ws ServerEndpoint.
|
java.util.concurrent.CompletionStage<Token> |
login(java.lang.String username,
java.lang.String password,
AuthModule eauth)
Non-blocking version of login() returning a CompletionStage with the token.
|
java.util.concurrent.CompletionStage<java.lang.Boolean> |
logout()
Perform logout and clear the session token from the config.
|
<T> java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,java.lang.Object>> |
run(java.lang.String username,
java.lang.String password,
AuthModule eauth,
java.lang.String client,
Target<T> target,
java.lang.String function,
java.util.List<java.lang.Object> args,
java.util.Map<java.lang.String,java.lang.Object> kwargs)
Generic interface to start any execution command bypassing normal session handling.
|
<T> java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,Result<SSHRawResult>>> |
runRawSSHCommand(java.lang.String command,
Target<T> target,
SaltSSHConfig cfg)
Calls salt-ssh with a command in raw shell mode (commands bypass Salt and
gets executed as shell commands).
|
java.util.concurrent.CompletionStage<Stats> |
stats()
Query statistics from the CherryPy Server.
|
private final AsyncHttpClient asyncHttpClient
private final java.net.URI uri
private final com.google.gson.Gson gson
public SaltClient(java.net.URI url,
AsyncHttpClient asyncHttpClient)
asyncHttpClient - http client to use for the salt apiurl - the Salt API URLpublic java.util.concurrent.CompletionStage<Token> login(java.lang.String username, java.lang.String password, AuthModule eauth)
POST /login
username - the usernamepassword - the passwordeauth - the eauth typepublic java.util.concurrent.CompletionStage<java.lang.Boolean> logout()
POST /logout
public <T> java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,java.lang.Object>> run(java.lang.String username,
java.lang.String password,
AuthModule eauth,
java.lang.String client,
Target<T> target,
java.lang.String function,
java.util.List<java.lang.Object> args,
java.util.Map<java.lang.String,java.lang.Object> kwargs)
POST /run
T - type of the tgt property for this commandusername - the usernamepassword - the passwordeauth - the eauth typeclient - the clienttarget - the targetfunction - the function to executeargs - list of non-keyword argumentskwargs - map containing keyword argumentspublic <T> java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,Result<SSHRawResult>>> runRawSSHCommand(java.lang.String command, Target<T> target, SaltSSHConfig cfg)
T - type of the tgt property for this commandcommand - to be executedtarget - glob type, targets to be reached by the commandcfg - SaltSSH config holderpublic java.util.concurrent.CompletionStage<Stats> stats()
GET /stats
public WebSocketEventStream events(Token token, long sessionIdleTimeout, long idleTimeout, int maxMsgSize, EventListener... listeners) throws SaltException
The stream object supports the WebSocketEventStream interface which allows the caller
to register/unregister for stream event notifications as well as close the event
stream.
Note: login(String, String, AuthModule) or must be called prior
to calling this method.
GET /events
listeners - event listeners to be added before the stream is initializedidleTimeout - idle timeout to pass to the http client configmaxMsgSize - maximum event data size to acceptsessionIdleTimeout - session idle timeout to pass to the http client configtoken - salt session token to use for authenticationSaltException - in case of an error during websocket stream initializationpublic <R> java.util.concurrent.CompletionStage<R> call(Call<?> call, Client client, java.util.Optional<Target<?>> target, java.util.Map<java.lang.String,java.lang.Object> custom, com.google.gson.reflect.TypeToken<R> type, AuthMethod auth)