org.jenkinsci.plugins.skytap
Class SkytapUtils

java.lang.Object
  extended by org.jenkinsci.plugins.skytap.SkytapUtils

public class SkytapUtils
extends Object


Constructor Summary
SkytapUtils()
           
 
Method Summary
static org.apache.http.client.methods.HttpDelete buildHttpDeleteRequest(String requestUrl, String AuthToken)
          This method returns an http delete request object, given a url and the encoded Skytap authorization token.
static org.apache.http.client.methods.HttpGet buildHttpGetRequest(String requestUrl, String AuthToken)
          This method packages an http get request object, given a url and the encoded Skytap authorization token.
static org.apache.http.client.methods.HttpPost buildHttpPostRequest(String requestUrl, String AuthToken)
          This method packages an http post request object, given a url and the encoded Skytap authorization token.
static org.apache.http.client.methods.HttpPut buildHttpPutRequest(String requestUrl, String AuthToken)
          This method returns an http put request object, given a url and the encoded Skytap authorization token.
static void checkResponseForErrors(String response)
          Utility method to extract errors, if any, from the Skytap json response, and throw an exception which can be handled by the caller.
static String convertFileNameToFullPath(hudson.model.AbstractBuild build, String savefile)
          Prepends the workspace path to a save file name as a default if user has not provided a full path.
static String executeHttpDeleteRequest(org.apache.http.client.methods.HttpDelete hd)
          Utility method used to execute an http delete.
static String executeHttpRequest(org.apache.http.client.methods.HttpRequestBase hr)
          Utility method to execute any type of http request (except delete), to catch any exceptions thrown and return the response string.
static String expandEnvVars(hudson.model.AbstractBuild build, String targetString)
          This method is used to enable Jenkins variable expansion.
static String getAuthCredentials(hudson.model.AbstractBuild build)
          Retrieves user id and auth key from the project build environment, encodes and returns encoded credential string to the user.
static com.google.gson.JsonObject getJsonObjectFromFile(String filepath)
          This is a utility method used to get the json object in json file used for configs, templates, etc.
static String getNetworkIdFromName(String confId, String netName, String authCredential)
          Executes a Skytap API call in order to get the network id of the network whose name was provided by the user.
static String getRuntimeId(String usersId, String usersFile)
          This method is used to obtain an id.
static String getValueFromJsonResponseBody(String jsonRespBody, String key)
          This is a utility method to help retrieve a json element from the response body.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SkytapUtils

public SkytapUtils()
Method Detail

expandEnvVars

public static String expandEnvVars(hudson.model.AbstractBuild build,
                                   String targetString)
This method is used to enable Jenkins variable expansion. The user would include Jenkins variables such as ${BUILD_ID} and these are resolved at runtime, with the expanded string being used for all plugin actions.

Parameters:
build -
targetString -
Returns:

getJsonObjectFromFile

public static com.google.gson.JsonObject getJsonObjectFromFile(String filepath)
This is a utility method used to get the json object in json file used for configs, templates, etc.

Parameters:
filepath -
Returns:

getValueFromJsonResponseBody

public static String getValueFromJsonResponseBody(String jsonRespBody,
                                                  String key)
This is a utility method to help retrieve a json element from the response body.

Parameters:
jsonRespBody -
Returns:

getAuthCredentials

public static String getAuthCredentials(hudson.model.AbstractBuild build)
Retrieves user id and auth key from the project build environment, encodes and returns encoded credential string to the user.

Parameters:
AbstractBuild -
Returns:
String

buildHttpGetRequest

public static org.apache.http.client.methods.HttpGet buildHttpGetRequest(String requestUrl,
                                                                         String AuthToken)
This method packages an http get request object, given a url and the encoded Skytap authorization token.

Parameters:
requestUrl -
AuthToken -
Returns:

buildHttpPostRequest

public static org.apache.http.client.methods.HttpPost buildHttpPostRequest(String requestUrl,
                                                                           String AuthToken)
This method packages an http post request object, given a url and the encoded Skytap authorization token.

Parameters:
requestUrl -
AuthToken -
Returns:

buildHttpPutRequest

public static org.apache.http.client.methods.HttpPut buildHttpPutRequest(String requestUrl,
                                                                         String AuthToken)
This method returns an http put request object, given a url and the encoded Skytap authorization token.

Parameters:
requestUrl -
AuthToken -
Returns:

buildHttpDeleteRequest

public static org.apache.http.client.methods.HttpDelete buildHttpDeleteRequest(String requestUrl,
                                                                               String AuthToken)
This method returns an http delete request object, given a url and the encoded Skytap authorization token.

Parameters:
requestUrl -
AuthToken -
Returns:

executeHttpRequest

public static String executeHttpRequest(org.apache.http.client.methods.HttpRequestBase hr)
                                 throws SkytapException
Utility method to execute any type of http request (except delete), to catch any exceptions thrown and return the response string.

Parameters:
hr -
Returns:
Throws:
SkytapException
IOException
org.apache.http.ParseException

executeHttpDeleteRequest

public static String executeHttpDeleteRequest(org.apache.http.client.methods.HttpDelete hd)
Utility method used to execute an http delete. Returns the status line which can be parsed as desired by the caller.

Parameters:
hd -
Returns:

checkResponseForErrors

public static void checkResponseForErrors(String response)
                                   throws SkytapException
Utility method to extract errors, if any, from the Skytap json response, and throw an exception which can be handled by the caller.

Parameters:
response -
Throws:
SkytapException

getRuntimeId

public static String getRuntimeId(String usersId,
                                  String usersFile)
                           throws FileNotFoundException
This method is used to obtain an id. If a file was provided, it extracts the id from there. Otherwise it just uses the id provided by the user.

Parameters:
confId -
Returns:
runtimeConfigurationId
Throws:
FileNotFoundException

convertFileNameToFullPath

public static String convertFileNameToFullPath(hudson.model.AbstractBuild build,
                                               String savefile)
Prepends the workspace path to a save file name as a default if user has not provided a full path.

Parameters:
build -
savefile -
Returns:
fullpath

getNetworkIdFromName

public static String getNetworkIdFromName(String confId,
                                          String netName,
                                          String authCredential)
                                   throws SkytapException
Executes a Skytap API call in order to get the network id of the network whose name was provided by the user.

Parameters:
confId -
netName -
Returns:
Throws:
SkytapException


Copyright © 2004-2013. All Rights Reserved.