Last active
August 17, 2017 22:49
-
-
Save sauceaaron/7f06b0a5310f59020cefd2f03ae3511c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.google.gson.Gson; | |
| import com.google.gson.reflect.TypeToken; | |
| import com.saucelabs.saucerest.SauceREST; | |
| import java.lang.reflect.Type; | |
| import java.util.List; | |
| public class SauceConnectTunnelManager | |
| { | |
| private String SAUCE_USERNAME = System.getenv("SAUCE_USERNAME"); | |
| private String SAUCE_ACCESS_KEY = System.getenv("SAUCE_ACCESS_KEY"); | |
| SauceREST api; | |
| public SauceConnectTunnelManager(String SAUCE_USERNAME, String SAUCE_ACCESS_KEY) | |
| { | |
| SauceREST api = new SauceREST(SAUCE_USERNAME, SAUCE_ACCESS_KEY); | |
| } | |
| public void shutdownTunnel(String tunnelId) | |
| { | |
| api.deleteTunnel(tunnelId); | |
| } | |
| public void shutdownAllTunnels() | |
| { | |
| for (String tunnelId : getTunnelIds()) | |
| { | |
| shutdownTunnel(tunnelId); | |
| } | |
| } | |
| public List<String> getTunnelIds() | |
| { | |
| String tunnelsJson = api.getTunnels(); | |
| Gson gson = new Gson(); | |
| Type listType = new TypeToken<List<String>>(){}.getType(); | |
| List<String> tunnelIds = gson.fromJson(tunnelsJson, listType); | |
| return tunnelIds; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment