use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class RemoteCopyAction method execute.
@Action(name = "Remote Copy Action", description = REMOTE_COPY_ACTION_DESC, outputs = { @Output(value = RETURN_RESULT, description = RETURN_RESULT_REMOTE_COPY_DESC), @Output(value = RETURN_CODE, description = RETURN_CODE_DESC), @Output(value = EXCEPTION, description = EXCEPTION_DESC) }, responses = { @Response(text = SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = COMPARE_EQUAL, responseType = RESOLVED, description = SUCCESS_DESC), @Response(text = FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = COMPARE_EQUAL, responseType = ERROR, description = FAILURE_DESC) })
public Map<String, String> execute(@Param(value = SRC_HOST, description = SRC_HOST_DESC, required = true) String sourceHost, @Param(value = SRC_PORT, description = SRC_PORT_DESC) String sourcePort, @Param(value = SRC_USERNAME, description = SRC_USERNAME_DESC) String sourceUsername, @Param(value = SRC_PASSWORD, description = SRC_PASSWORD_DESC, encrypted = true) String sourcePassword, @Param(value = SRC_PRIVATE_KEY_FILE, description = SRC_PRIVATE_KEY_FILE_DESC) String sourcePrivateKeyFile, @Param(value = SRC_PATH, description = SRC_PATH_DESC, required = true) String sourcePath, @Param(value = SRC_PROTOCOL, description = SRC_PROTOCOL_DESC, required = true) String sourceProtocol, @Param(value = SRC_CHARACTER_SET, description = SRC_CHARACTER_SET_DESC) String sourceCharacterSet, @Param(value = DEST_HOST, description = DEST_HOST_DESC, required = true) String destinationHost, @Param(value = DEST_PORT, description = DEST_PORT_DESC) String destinationPort, @Param(value = DEST_USERNAME, description = DEST_USERNAME_DESC) String destinationUsername, @Param(value = DEST_PASSWORD, description = DEST_PASSWORD_DESC, encrypted = true) String destinationPassword, @Param(value = DEST_PRIVATE_KEY_FILE, description = DEST_PRIVATE_KEY_FILE_DESC) String destinationPrivateKeyFile, @Param(value = DEST_PATH, description = DEST_PATH_DESC, required = true) String destinationPath, @Param(value = DEST_PROTOCOL, description = DEST_PROTOCOL_DESC, required = true) String destinationProtocol, @Param(value = DEST_CHARACTER_SET, description = DEST_CHARACTER_SET_DESC) String destinationCharacterSet, @Param(value = CONNECTION_TIMEOUT, description = CONNECTION_TIMEOUT_DESC) String connectionTimeout, @Param(value = EXECUTION_TIMEOUT, description = EXECUTION_TIMEOUT_DESC) String executionTimeout) {
sourceCharacterSet = defaultIfEmpty(sourceCharacterSet, CHARACTER_SET_UTF8);
destinationCharacterSet = defaultIfEmpty(destinationCharacterSet, CHARACTER_SET_UTF8);
connectionTimeout = defaultIfEmpty(connectionTimeout, DEFAULT_CONNECTION_TIMEOUT);
executionTimeout = defaultIfEmpty(executionTimeout, DEFAULT_EXECUTION_TIMEOUT);
final List<String> exceptionMessages = verifyRemoteCopyInputs(sourceHost, sourcePort, sourcePath, sourceProtocol, sourceCharacterSet, destinationHost, destinationPort, destinationPath, destinationProtocol, destinationCharacterSet, connectionTimeout, executionTimeout);
if (!exceptionMessages.isEmpty()) {
return getFailureResultsMap(StringUtilities.join(exceptionMessages, NEW_LINE));
}
RemoteCopyInputs inputs = new RemoteCopyInputs.RemoteCopyBuilder().sourceHost(sourceHost).sourcePort(sourcePort).sourceUsername(sourceUsername).sourcePassword(sourcePassword).sourcePrivateKeyFile(sourcePrivateKeyFile).sourcePath(sourcePath).sourceProtocol(sourceProtocol).sourceCharacterSet(sourceCharacterSet).destinationHost(destinationHost).destinationPort(destinationPort).destinationUsername(destinationUsername).destinationPassword(destinationPassword).destinationPrivateKeyFile(destinationPrivateKeyFile).destinationPath(destinationPath).destinationProtocol(destinationProtocol).destinationCharacterSet(destinationCharacterSet).connectionTimeout(connectionTimeout).executionTimeout(executionTimeout).build();
return new RemoteCopyService().execute(inputs);
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class Put method execute.
@Action(name = "FTP Put Operation", outputs = { @Output(value = RETURN_RESULT, description = RETURN_RESULT_DESC), @Output(value = RETURN_CODE, description = RETURN_CODE_DESC), @Output(value = EXCEPTION, description = EXCEPTION_DESC), @Output(value = FTP_REPLY_CODE, description = FTP_REPLY_CODE_DESC), @Output(value = FTP_SESSION_LOG, description = FTP_SESSION_LOG_DESC) }, responses = { @Response(text = SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = COMPARE_EQUAL, responseType = RESOLVED, description = SUCCESS_DESC), @Response(text = FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = COMPARE_EQUAL, responseType = ERROR, description = FAILURE_DESC) })
public Map<String, String> execute(@Param(value = HOST_NAME, description = HOSTNAME_DESC) String hostName, @Param(value = PORT, description = PORT_DESC) String port, @Param(value = LOCAL_FILE, description = LOCAL_FILE_DESC) String localFile, @Param(value = REMOTE_FILE, description = REMOTE_FILE_DESC) String remoteFile, @Param(value = USER, description = USER_DESC) String user, @Param(value = PASSWORD, description = PASSWORD_DESC) String password, @Param(value = TYPE, description = TYPE_DESC) String type, @Param(value = PASSIVE, description = PASSIVE_DESC) String passive, @Param(value = CHARACTER_SET, description = CHARACTER_SET_DESC) String characterSet) {
hostName = defaultIfEmpty(hostName, EMPTY);
port = defaultIfEmpty(port, PORT_21);
localFile = defaultIfEmpty(localFile, EMPTY);
remoteFile = defaultIfEmpty(remoteFile, EMPTY);
user = defaultIfEmpty(user, EMPTY);
password = defaultIfEmpty(password, EMPTY);
type = defaultIfEmpty(type, BINARY_FILE_TYPE);
passive = defaultIfEmpty(passive, BOOLEAN_FALSE);
passive = passive.toLowerCase();
characterSet = defaultIfEmpty(characterSet, CHARACTER_SET_LATIN1);
final List<String> exceptionMessages = verifyInputsFTP(hostName, port, localFile, remoteFile, user, password, type, passive, characterSet);
if (!exceptionMessages.isEmpty()) {
// REPLY CODE = 501 SYNTAX ERROR IN PARAMETERS OR ARGUMENTS
Map<String, String> result = getFailureResultsMap(StringUtilities.join(exceptionMessages, NEW_LINE));
result.put(FTP_REPLY_CODE, "501");
result.put(FTP_SESSION_LOG, "");
return result;
}
return new FTPService().ftpOperation(FTPInputs.builder().hostname(hostName).port(port).localFile(localFile).remoteFile(remoteFile).user(user).password(password).type(type).passive(passive).characterSet(characterSet).build(), FTPOperation.PUT);
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class SCPCopyFile method execute.
@Action(name = "SCP Copy File", description = SCP_COPY_FILE_ACTION_DESC, outputs = { @Output(value = RETURN_RESULT, description = RETURN_RESULT_DESC), @Output(value = RETURN_CODE, description = RETURN_CODE_DESC), @Output(value = EXCEPTION, description = EXCEPTION_DESC) }, responses = { @Response(text = SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = COMPARE_EQUAL, responseType = RESOLVED, description = SUCCESS_DESC), @Response(text = FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = COMPARE_EQUAL, responseType = ERROR, description = FAILURE_DESC) })
public Map<String, String> execute(@Param(value = HOST, description = HOST_DESC, required = true) String host, @Param(value = PORT, description = PORT_DESC) String port, @Param(value = USERNAME, description = USERNAME_DESC, required = true) String username, @Param(value = PASSWORD, description = PASSWORD_DESC, encrypted = true) String password, @Param(value = LOCAL_FILE, description = LOCAL_FILE_DESC, required = true) String localFile, @Param(value = COPY_ACTION, description = COPY_ACTION_DESC, required = true) String copyAction, @Param(value = REMOTE_FILE, description = REMOTE_FILE_DESC, required = true) String remoteFile, @Param(value = PROXY_HOST, description = PROXY_HOST_DESC) String proxyHost, @Param(value = PROXY_PORT, description = PROXY_PORT_DESC) String proxyPort, @Param(value = PROXY_USERNAME, description = PROXY_USERNAME_DESC) String proxyUsername, @Param(value = PROXY_PASSWORD, description = PROXY_PASSWORD_DESC, encrypted = true) String proxyPassword, @Param(value = KNOWN_HOSTS_POLICY, description = KNOWN_HOSTS_POLICY_DESC) String knownHostsPolicy, @Param(value = KNOWN_HOSTS_PATH, description = KNOWN_HOSTS_PATH_DESC) String knownHostsPath, @Param(value = PRIVATE_KEY, description = PRIVATE_KEY_DESC) String privateKey, @Param(value = CONNECTION_TIMEOUT, description = CONNECTION_TIMEOUT_DESC) String connectionTimeout, @Param(value = EXECUTION_TIMEOUT, description = EXECUTION_TIMEOUT_DESC) String executionTimeout) {
connectionTimeout = defaultIfEmpty(connectionTimeout, DEFAULT_CONNECTION_TIMEOUT);
executionTimeout = defaultIfEmpty(executionTimeout, DEFAULT_EXECUTION_TIMEOUT);
proxyHost = defaultIfEmpty(proxyHost, EMPTY);
proxyPort = defaultIfEmpty(proxyPort, String.valueOf(DEFAULT_PROXY_PORT));
port = defaultIfEmpty(port, String.valueOf(DEFAULT_PORT));
knownHostsPolicy = defaultIfEmpty(knownHostsPolicy, DEFAULT_KNOWN_HOSTS_POLICY);
knownHostsPath = defaultIfEmpty(knownHostsPath, DEFAULT_KNOWN_HOSTS_PATH.toString());
privateKey = defaultIfEmpty(privateKey, EMPTY);
final List<String> exceptionMessages = verifySCPCopyFileInputs(host, port, localFile, copyAction, remoteFile, connectionTimeout, executionTimeout, knownHostsPolicy);
if (!exceptionMessages.isEmpty()) {
return getFailureResultsMap(StringUtilities.join(exceptionMessages, NEW_LINE));
}
SCPCopyFileInputs inputs = new SCPCopyFileInputs.SCPCopyFileInputsBuilder().host(host).port(port).username(username).password(password).localFile(localFile).copyAction(copyAction).remoteFile(remoteFile).privateKey(privateKey).connectionTimeout(connectionTimeout).executionTimeout(executionTimeout).proxyHost(proxyHost).proxyPort(proxyPort).proxyUsername(proxyUsername).proxyPassword(proxyPassword).knownHostsPath(knownHostsPath).knownHostsPolicy(knownHostsPolicy).build();
return new SCPService().executeSCPCopyFile(inputs);
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class GetLaunchPermissionForImageAction method execute.
/**
* Describes the launch permission of the specified AMI.
*
* @param endpoint Optional - Endpoint to which request will be sent.
* Example: "https://ec2.amazonaws.com"
* @param identity Username of your account or the Access Key ID.
* @param credential Password of the user or the Secret Access Key that correspond to the identity input.
* @param proxyHost Optional - Proxy server used to access the web site. If empty no proxy will be used.
* @param proxyPort Optional - Proxy server port.
* @param proxyUsername Optional - proxy server user name.
* @param proxyPassword Optional - proxy server password associated with the proxyUsername input value.
* @param headers Optional - string containing the headers to use for the request separated by new line (CRLF).
* The header name-value pair will be separated by ":".
* Format: Conforming with HTTP standard for headers (RFC 2616)
* Examples: "Accept:text/plain"
* @param queryParams Optional - string containing query parameters that will be appended to the URL. The names
* and the values must not be URL encoded because if they are encoded then a double encoded
* will occur. The separator between name-value pairs is "&" symbol. The query name will be
* separated from query value by "=".
* Examples: "parameterName1=parameterValue1¶meterName2=parameterValue2"
* @param version Optional - Version of the web service to made the call against it.
* Example: "2016-04-01"
* Default: "2016-04-01"
* @param imageId ID of the specified image to retrieve launch permission for.
* @return A map with strings as keys and strings as values that contains: outcome of the action, returnCode of the
* operation, or failure message and the exception if there is one
*/
@Action(name = "Get Launch Permission for Image", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.SUCCESS_RETURN_CODE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.FAILURE_RETURN_CODE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR) })
public Map<String, String> execute(@Param(value = ENDPOINT) String endpoint, @Param(value = IDENTITY, required = true) String identity, @Param(value = CREDENTIAL, required = true, encrypted = true) String credential, @Param(value = PROXY_HOST) String proxyHost, @Param(value = PROXY_PORT) String proxyPort, @Param(value = PROXY_USERNAME) String proxyUsername, @Param(value = PROXY_PASSWORD, encrypted = true) String proxyPassword, @Param(value = HEADERS) String headers, @Param(value = QUERY_PARAMS) String queryParams, @Param(value = VERSION) String version, @Param(value = IMAGE_ID, required = true) String imageId) {
try {
version = getDefaultStringInput(version, IMAGES_DEFAULT_API_VERSION);
final CommonInputs inputs = new CommonInputs.Builder().withEndpoint(endpoint, EC2_API, EMPTY).withIdentity(identity).withCredential(credential).withProxyHost(proxyHost).withProxyPort(proxyPort).withProxyUsername(proxyUsername).withProxyPassword(proxyPassword).withHeaders(headers).withQueryParams(queryParams).withVersion(version).withAction(DESCRIBE_IMAGE_ATTRIBUTE).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
final CustomInputs customInputs = new CustomInputs.Builder().withAttribute(LAUNCH_PERMISSION).withImageId(imageId).build();
return new QueryApiExecutor().execute(inputs, customInputs);
} catch (Exception exception) {
return ExceptionProcessor.getExceptionResult(exception);
}
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class RemoveLaunchPermissionsFromImageAction method execute.
/**
* Removes launch permission of the specified AMI.
* Note:
* AWS Marketplace product codes cannot be modified. Images with an AWS Marketplace product code cannot be made public.
*
* @param endpoint Optional - Endpoint to which request will be sent.
* Example: "https://ec2.amazonaws.com"
* @param identity Username of your account or the Access Key ID.
* @param credential Password of the user or the Secret Access Key that correspond to the identity
* input.
* @param proxyHost Optional - Proxy server used to access the web site. If empty no proxy will be used.
* @param proxyPort Optional - Proxy server port.
* @param proxyUsername Optional - proxy server user name.
* @param proxyPassword Optional - proxy server password associated with the proxyUsername input value.
* @param headers Optional - string containing the headers to use for the request separated by new line (CRLF).
* The header name-value pair will be separated by ":".
* Format: Conforming with HTTP standard for headers (RFC 2616)
* Examples: "Accept:text/plain"
* @param queryParams Optional - string containing query parameters that will be appended to the URL. The names
* and the values must not be URL encoded because if they are encoded then a double encoded
* will occur. The separator between name-value pairs is "&" symbol. The query name will be
* separated from query value by "=".
* Examples: "parameterName1=parameterValue1¶meterName2=parameterValue2"
* @param version Optional - Version of the web service to made the call against it.
* Example: "2016-04-01"
* Default: "2016-04-01"
* @param delimiter Optional - The delimiter that will be used - Default: ","
* @param imageId ID of the specified image to remove launch permission for.
* @param userIdsString Optional - A string that contains: none, one or more user IDs separated by delimiter.
* Default: ""
* @param userGroupsString Optional - A string that contains: none, one or more user groups separated by delimiter.
* Default: ""
* @return A map with strings as keys and strings as values that contains: outcome of the action, returnCode of the
* operation, or failure message and the exception if there is one
*/
@Action(name = "Remove Launch Permissions To Image", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.SUCCESS_RETURN_CODE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.FAILURE_RETURN_CODE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR) })
public Map<String, String> execute(@Param(value = ENDPOINT) String endpoint, @Param(value = IDENTITY, required = true) String identity, @Param(value = CREDENTIAL, required = true, encrypted = true) String credential, @Param(value = PROXY_HOST) String proxyHost, @Param(value = PROXY_PORT) String proxyPort, @Param(value = PROXY_USERNAME) String proxyUsername, @Param(value = PROXY_PASSWORD, encrypted = true) String proxyPassword, @Param(value = HEADERS) String headers, @Param(value = QUERY_PARAMS) String queryParams, @Param(value = VERSION) String version, @Param(value = DELIMITER) String delimiter, @Param(value = IMAGE_ID, required = true) String imageId, @Param(value = USER_IDS_STRING) String userIdsString, @Param(value = USER_GROUPS_STRING) String userGroupsString) {
try {
version = getDefaultStringInput(version, IMAGES_DEFAULT_API_VERSION);
final CommonInputs inputs = new CommonInputs.Builder().withEndpoint(endpoint, EC2_API, EMPTY).withIdentity(identity).withCredential(credential).withProxyHost(proxyHost).withProxyPort(proxyPort).withProxyUsername(proxyUsername).withProxyPassword(proxyPassword).withHeaders(headers).withQueryParams(queryParams).withVersion(version).withDelimiter(delimiter).withAction(MODIFY_IMAGE_ATTRIBUTE).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
final CustomInputs customInputs = new CustomInputs.Builder().withAttribute(LAUNCH_PERMISSION).withOperationType(REMOVE_OPERATION_TYPE).withImageId(imageId).build();
final ImageInputs imageInputs = new ImageInputs.Builder().withUserIdsString(userIdsString).withUserGroupsString(userGroupsString).build();
return new QueryApiExecutor().execute(inputs, customInputs, imageInputs);
} catch (Exception exception) {
return ExceptionProcessor.getExceptionResult(exception);
}
}
Aggregations