@@ -0,0 +1,2526 @@
+package com.suse.salt.netapi.examples;%0A%0Aimport com.suse.salt.netapi.calls.modules.Grains;%0Aimport com.suse.salt.netapi.calls.modules.Test;%0Aimport com.suse.salt.netapi.client.SaltClient;%0Aimport com.suse.salt.netapi.datatypes.target.Glob;%0Aimport com.suse.salt.netapi.datatypes.target.MinionList;%0Aimport com.suse.salt.netapi.datatypes.target.Target;%0Aimport com.suse.salt.netapi.exception.SaltException;%0Aimport com.suse.salt.netapi.results.Result;%0Aimport com.suse.salt.netapi.results.SSHResult;%0A%0Aimport java.net.URI;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.Optional;%0Aimport java.util.stream.Collectors;%0A%0A/**%0A * Example code calling salt modules via ssh.%0A */%0Apublic class SaltSSH %7B%0A%0A    private static final String SALT_API_URL = %22http://localhost:8000%22;%0A%0A    public static void main(String%5B%5D args) throws SaltException %7B%0A        // Init the client%0A        SaltClient client = new SaltClient(URI.create(SALT_API_URL));%0A%0A        // Ping all minions using a glob matcher%0A        Target%3CString%3E globTarget = new Glob(%22*%22);%0A        Map%3CString, Result%3CSSHResult%3CBoolean%3E%3E%3E minionResults = Test.ping().callSyncSSH(%0A                client, globTarget, Optional.of(%22/tmp/susemanager-roster%22));%0A%0A        System.out.println(%22--%3E Ping results:%5Cn%22);%0A        minionResults.forEach((minion, result) -%3E %7B%0A            System.out.println(minion + %22 -%3E %22 + result.fold(%0A                    error -%3E %22Error: %22 + error.toString()%0A                    ,%0A                    res -%3E res.getReturn().orElse(false)%0A            ));%0A        %7D);%0A%0A        // Get grains from a list of minions%0A        Target%3CList%3CString%3E%3E minionList = new MinionList(%22my.future.minion%22);%0A        Map%3CString, Result%3CSSHResult%3CMap%3CString, Object%3E%3E%3E%3E grainResults = Grains.%0A                items(false).callSyncSSH(client, minionList, Optional.of(%22/tmp/my-roster%22));%0A%0A        grainResults.forEach((minion, grains) -%3E %7B%0A            System.out.println(%22%5Cn--%3E Listing grains for '%22 + minion + %22':%5Cn%22);%0A            String grainsOutput = grains.fold(%0A                    error -%3E %22Error: %22 + error.toString(),%0A                    grainsMap -%3E %7B%0A                            grainsMap.getReturn().ifPresent(gmap -%3E gmap.entrySet().stream()%0A                                    .map(e -%3E e.getKey() + %22: %22 + e.getValue())%0A                                    .collect(Collectors.joining(%22%5Cn%22)));%0A                            return %22Minion did not return: %22 + minion;%0A                    %7D%0A            );%0A            System.out.println(grainsOutput);%0A        %7D);%0A    %7D%0A%7D%0A

Add salt-ssh example code