public class SauceREST extends Object implements Serializable
| Modifier and Type | Field and Description |
|---|---|
protected String |
accessKey
The access key to use when performing HTTP requests to the Sauce REST API.
|
protected String |
username
The username to use when performing HTTP requests to the Sauce REST API.
|
| Constructor and Description |
|---|
SauceREST(String username,
String accessKey)
Constructs a new instance of the SauceREST class.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAuthenticationProperty(HttpURLConnection connection)
Adds an Authorization request property to the HTTP connection.
|
protected URL |
buildURL(String endpoint)
Build the url to be
|
void |
deleteJob(String jobId)
Invokes the Sauce REST API to delete a completed job from Sauce.
|
void |
deleteTunnel(String tunnelId)
Invokes the Sauce REST API to delete a tunnel.
|
String |
doJSONPOST(URL url,
org.json.JSONObject body) |
void |
downloadLog(String jobId,
String location)
Downloads the log file for a Sauce Job to the filesystem.
|
void |
downloadVideo(String jobId,
String location)
Downloads the video for a Sauce Job to the filesystem.
|
protected String |
encodeAuthentication() |
boolean |
equals(Object obj) |
String |
getActivity()
Invokes the Sauce REST API to retrieve the activity details of the user.
|
String |
getBuildFullJobs(String build) |
String |
getBuildFullJobs(String build,
int limit)
Retrieve jobs associated with a build
|
String |
getConcurrency()
Invokes the Sauce REST API to retrieve the concurrency details of the user.
|
static String |
getExtraUserAgent() |
String |
getFullJobs()
Returns a String (in JSON format) representing the details for a Sauce job.
|
String |
getFullJobs(int limit)
Returns a String (in JSON format) representing the details for a Sauce job.
|
String |
getJobInfo(String jobId)
Returns a String (in JSON format) representing the details for a Sauce job.
|
String |
getJobs()
Returns a String (in JSON format) representing the details for a Sauce job.
|
String |
getJobs(int limit)
Returns a String (in JSON format) representing the details for a Sauce job.
|
String |
getJobs(int limit,
long to,
int from)
Returns a String (in JSON format) representing the details for a Sauce job.
|
String |
getPublicJobLink(String jobId)
Generates a link to the job page on Saucelabs.com, which can be accessed
without the user's credentials.
|
String |
getStoredFiles()
Returns a String (in JSON format) representing the stored files list
|
String |
getSupportedPlatforms(String automationApi)
Returns a String (in JSON format) representing the list of objects describing all the OS and browser platforms
currently supported on Sauce Labs.
|
String |
getTunnelInformation(String tunnelId)
Invokes the Sauce REST API to retrieve the details of the tunnel.
|
String |
getTunnels()
Invokes the Sauce REST API to retrieve the details of the tunnels currently associated with the user.
|
String |
getUser()
Returns a String (in JSON format) representing the basic account information
|
protected String |
getUserAgent() |
String |
getUsername()
Returns username assigned to this interface
|
void |
jobFailed(String jobId)
Marks a Sauce Job as 'failed'.
|
void |
jobPassed(String jobId)
Marks a Sauce Job as 'passed'.
|
HttpURLConnection |
openConnection(URL url)
Opens a connection to a url.
|
boolean |
recordCI(String platform,
String platformVersion)
Record CI Usage to Sauce Labs
|
String |
retrieveResults(String path)
Returns the HTTP response for invoking https://saucelabs.com/rest/v1/path.
|
String |
retrieveResults(URL restEndpoint) |
static void |
setExtraUserAgent(String extraUserAgent) |
void |
stopJob(String jobId)
Invokes the Sauce REST API to stop a running job.
|
void |
updateJobInfo(String jobId,
Map<String,Object> updates)
Invokes the Sauce REST API to update the details of a Sauce job, using the details included in the
updates
parameter. |
String |
uploadFile(File file)
Uploads a file to Sauce storage.
|
String |
uploadFile(File file,
String fileName)
Uploads a file to Sauce storage.
|
String |
uploadFile(File file,
String fileName,
Boolean overwrite)
Uploads a file to Sauce storage.
|
String |
uploadFile(InputStream is,
String fileName,
Boolean overwrite)
Uploads a file to Sauce storage.
|
protected String username
protected String accessKey
public static String getExtraUserAgent()
public static void setExtraUserAgent(String extraUserAgent)
public String getUsername()
protected URL buildURL(String endpoint)
endpoint - Endpoint url, example "info/platforms/appium"protected String getUserAgent()
public String doJSONPOST(URL url, org.json.JSONObject body) throws SauceException
SauceExceptionpublic void jobPassed(String jobId)
jobId - the Sauce Job Id, typically equal to the Selenium/WebDriver sessionIdpublic void jobFailed(String jobId)
jobId - the Sauce Job Id, typically equal to the Selenium/WebDriver sessionIdpublic void downloadVideo(String jobId, String location)
location field.jobId - the Sauce Job Id, typically equal to the Selenium/WebDriver sessionIdlocation - represents the base directory where the video should be downloaded topublic void downloadLog(String jobId, String location)
location field.jobId - the Sauce Job Id, typically equal to the Selenium/WebDriver sessionIdlocation - represents the base directory where the video should be downloaded topublic String retrieveResults(String path)
path - path to append to the urlpublic String getJobInfo(String jobId)
jobId - the Sauce Job id to retrievepublic String getFullJobs()
public String getFullJobs(int limit)
limit - Number of jobs to returnpublic String getJobs()
public String getJobs(int limit)
limit - Number of jobs to return(max of 500)public String getJobs(int limit, long to, int from)
limit - Number of jobs to return(max of 500)to - value in Epoch time format denoting the time to end the job list searhfrom - value in Epoch time format denoting the time to start the searchpublic String retrieveResults(URL restEndpoint)
restEndpoint - the URL to perform a HTTP GETprotected void addAuthenticationProperty(HttpURLConnection connection)
connection - HttpURLConnection instance which represents the current HTTP requestpublic void updateJobInfo(String jobId, Map<String,Object> updates)
updates
parameter.jobId - the Sauce job id to updateupdates - Map of attributes to updatepublic void stopJob(String jobId)
jobId - the Sauce Job idpublic void deleteJob(String jobId)
jobId - the Sauce Job idpublic HttpURLConnection openConnection(URL url) throws IOException
url - URL to connect toIOException - when a bad url is providedpublic String uploadFile(File file) throws IOException
file - the file to upload
-param fileName uses file.getName() to store in sauce
-param overwrite set to trueIOException - can be thrown when server returns an error (tcp or http status not in the 200 range)public String uploadFile(File file, String fileName) throws IOException
file - the file to uploadfileName - name of the file in sauce storage
-param overwrite set to trueIOException - can be thrown when server returns an error (tcp or http status not in the 200 range)public String uploadFile(File file, String fileName, Boolean overwrite) throws IOException
file - the file to uploadfileName - name of the file in sauce storageoverwrite - boolean flag to overwrite file in sauce storage if it existsIOException - can be thrown when server returns an error (tcp or http status not in the 200 range)public String uploadFile(InputStream is, String fileName, Boolean overwrite) throws IOException
is - Input stream of the file to be uploadedfileName - name of the file in sauce storageoverwrite - boolean flag to overwrite file in sauce storage if it existsIOException - can be thrown when server returns an error (tcp or http status not in the 200 range)public String getPublicJobLink(String jobId)
jobId - the Sauce Job Id, typically equal to the Selenium/WebDriver sessionIdprotected String encodeAuthentication()
public void deleteTunnel(String tunnelId)
tunnelId - Identifier of the tunnel to deletepublic String getTunnels()
public String getTunnelInformation(String tunnelId)
tunnelId - the Sauce Tunnel idpublic String getConcurrency()
public String getActivity()
public String getStoredFiles()
public String getUser()
public String getSupportedPlatforms(String automationApi)
automationApi - the automation API namepublic String getBuildFullJobs(String build, int limit)
build - Build Idlimit - Max jobs to returnpublic boolean recordCI(String platform, String platformVersion)
platform - Platform string. Such as "jenkins", "bamboo", "teamcity"platformVersion - Version string. Such as "1.1.1"Copyright © 2016 Sauce Labs. All rights reserved.