use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class DetachVolumeAction method execute.
/**
* Detaches an EBS volume from an instance.
*
* <p>Note: Make sure to un-mount any file systems on the device within your operating system before detaching the volume.
* Failure to do so results in the volume being stuck in a busy state while detaching. If an Amazon EBS volume is the
* root device of an instance, it can't be detached while the instance is running. To detach the root volume, stop the
* instance first. When a volume with an AWS Marketplace product code is detached from an instance, the product code
* is no longer associated with the instance. For more information, see Detaching an Amazon EBS Volume in the Amazon
* Elastic Compute Cloud User Guide.
*
* @param endpoint Optional - Endpoint to which request will be sent.
* Default: "https://ec2.amazonaws.com"
* @param identity ID of the secret access key associated with your Amazon AWS or IAM account.
* Example: "AKIAIOSFODNN7EXAMPLE"
* @param credential Secret access key associated with your Amazon AWS or IAM account.
* Example: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
* @param proxyHost Optional - proxy server used to connect to Amazon API. If empty no proxy will be used.
* Default: ""
* @param proxyPort Optional - proxy server port. You must either specify values for both proxyHost and proxyPort
* inputs or leave them both empty.
* Default: ""
* @param proxyUsername Optional - proxy server user name.
* Default: ""
* @param proxyPassword Optional - proxy server password associated with the proxyUsername input value.
* Default: ""
* @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"
* Default: ""
* @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"
* Default: ""
* @param version Optional - Version of the web service to made the call against it.
* Example: "2016-11-15"
* Default: "2016-11-15"
* @param instanceId ID of the instance.
* @param volumeId ID of the EBS volume. The volume and instance must be within the same Availability Zone.
* @param deviceName Device name to expose to the instance.
* Example: "/dev/sdh", "xvdh"
* @param force Optional - forces detachment if the previous detachment attempt did not occur cleanly (for example,
* logging into an instance, un-mounting the volume, and detaching normally). This option can lead
* to data loss or a corrupted file system. Use this option only as a last resort to detach a volume
* from a failed instance. The instance won't have an opportunity to flush file system caches or file
* system metadata. If you use this option, you must perform file system check and repair procedures.
* Default: "false"
* @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 = "Detach Volume", 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 = INSTANCE_ID) String instanceId, @Param(value = VOLUME_ID, required = true) String volumeId, @Param(value = DEVICE_NAME) String deviceName, @Param(value = FORCE) String force) {
try {
version = getDefaultStringInput(version, VOLUMES_DEFAULT_API_VERSION);
final CommonInputs commonInputs = 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(DETACH_VOLUME).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
final CustomInputs customInputs = new CustomInputs.Builder().withVolumeId(volumeId).withInstanceId(instanceId).build();
final VolumeInputs volumeInputs = new VolumeInputs.Builder().withDeviceName(deviceName).withForce(force).build();
return new QueryApiExecutor().execute(commonInputs, customInputs, volumeInputs);
} catch (Exception e) {
return ExceptionProcessor.getExceptionResult(e);
}
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class TerminateInstancesAction method execute.
/**
* Shuts down one or more instances.
* Note: This operation is idempotent; if you terminate an instance more than once, each call succeeds.
* If you specify multiple instances and the request fails (for example, because of a single incorrect instance
* ID), none of the instances are terminated.
* Terminated instances remain visible after termination (for approximately one hour).
* By default, Amazon EC2 deletes all EBS volumes that were attached when the instance launched. Volumes attached
* after instance launch continue running.
* You can stop, start, and terminate EBS-backed instances. You can only terminate instance store-backed instances.
* What happens to an instance differs if you stop it or terminate it. For example, when you stop an instance,
* the root device and any other devices attached to the instance persist. When you terminate an instance, any
* attached EBS volumes with the DeleteOnTermination block device mapping parameter set to true are automatically
* deleted. For more information about the differences between stopping and terminating instances, see Instance
* Lifecycle in the Amazon Elastic Compute Cloud User Guide.
* For more information about troubleshooting, see Troubleshooting Terminating Your Instance in the Amazon Elastic
* Compute Cloud User Guide.
*
* @param endpoint Optional - Endpoint to which request will be sent.
* Default: "https://ec2.amazonaws.com"
* @param identity ID of the secret access key associated with your Amazon AWS or IAM account.
* Example: "AKIAIOSFODNN7EXAMPLE"
* @param credential Secret access key associated with your Amazon AWS or IAM account.
* Example: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
* @param proxyHost Optional - proxy server used to connect to Amazon API. If empty no proxy will be used.
* Default: ""
* @param proxyPort Optional - proxy server port. You must either specify values for both proxyHost and
* proxyPort inputs or leave them both empty.
* Default: ""
* @param proxyUsername Optional - proxy server user name.
* Default: ""
* @param proxyPassword Optional - proxy server password associated with the proxyUsername input value.
* Default: ""
* @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"
* Default: ""
* @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"
* Default: ""
* @param version Optional - Version of the web service to made the call against it.
* Example: "2016-11-15"
* Default: "2016-11-15"
* @param delimiter Optional - delimiter that will be used.
* Default: ","
* @param instanceIdsString String that contains one or more values that represents instance IDs.
* Example: "i-12345678,i-abcdef12,i-12ab34cd"
* @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 = "Terminate Instances", 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 = INSTANCE_IDS_STRING, required = true) String instanceIdsString) {
try {
version = getDefaultStringInput(version, INSTANCES_DEFAULT_API_VERSION);
final CommonInputs commonInputs = 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(TERMINATE_INSTANCES).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
final InstanceInputs instanceInputs = new InstanceInputs.Builder().withInstanceIdsString(instanceIdsString).build();
return new QueryApiExecutor().execute(commonInputs, instanceInputs);
} catch (Exception e) {
return ExceptionProcessor.getExceptionResult(e);
}
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class DescribeKeyPairsAction method execute.
/**
* Describes the specified key pairs or all of your key pairs.
*
* @param endpoint Endpoint to which request will be sent.
* Default: "https://ec2.amazonaws.com"
* @param identity ID of the secret access key associated with your Amazon AWS or IAM account.
* Example: "AKIAIOSFODNN7EXAMPLE"
* @param credential Secret access key associated with your Amazon AWS or IAM account.
* Example: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
* all the subnets are described.
* @param proxyHost Optional - proxy server used to connect to Amazon API. If empty no proxy
* will be used.
* Default: ""
* @param proxyPort Optional - proxy server port. You must either specify values for both
* proxyHost and proxyPort inputs or leave them both empty.
* Default: ""
* @param proxyUsername Optional - proxy server username.
* Default: ""
* @param proxyPassword Optional - proxy server password associated with the proxyUsername
* input value.
* Default: ""
* @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"
* Default: ""
* @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"
* Default: ""
* @param version Optional - Version of the web service to made the call against it.
* Example: "2016-11-15"
* Default: ""
* @param delimiter Optional - Delimiter that will be used.
* @param filterNamesString Optional - String that contains one or more values that represents filters for
* the search.
* Example: "key-pair-id,key-name,fingerprint ",
* Default: ""
* @param filterValuesString Optional - String that contains one or more values that represents filters values.
* Default: ""
* @param maxResults Optional - The maximum number of results to return in a single call. To retrieve the
* remaining results, make another call with the returned NextToken value. This value can
* be between 5 and 1000. You cannot specify this parameter and the instance IDs parameter
* or tag filters in the same call.
* Default: ""
* @param nextToken Optional - The token to use to retrieve the next page of results. This value is null when
* there are no more results to return.
* 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 = "Describe KeyPairs", outputs = { @Output(RETURN_CODE), @Output(RETURN_RESULT), @Output(EXCEPTION) }, responses = { @Response(text = SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, 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 = DESCRIBE_KEYPAIRS_FILTER_NAMES_STRING) String filterNamesString, @Param(value = DESCRIBE_KEYPAIRS_FILTER_VALUES_STRING) String filterValuesString, @Param(value = MAX_RESULTS) String maxResults, @Param(value = NEXT_TOKEN) String nextToken) {
try {
version = getDefaultStringInput(version, DESCRIBE_KEYPAIR_DEFAULT_API_VERSION);
final CommonInputs commonInputs = 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(DESCRIBE_KEYPAIRS).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
final CustomInputs customInputs = new CustomInputs.Builder().withKeyFiltersString(filterNamesString).withValueFiltersString(filterValuesString).build();
final FilterInputs filterInputs = new FilterInputs.Builder().withMaxResults(maxResults).withNextToken(nextToken).build();
return new QueryApiExecutor().execute(commonInputs, customInputs, filterInputs);
} catch (Exception e) {
return ExceptionProcessor.getExceptionResult(e);
}
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class InvokeLambdaAction method execute.
/**
* Invokes an AWS Lambda Function in sync mode using AWS Java SDK
*
* @param identity Access key associated with your Amazon AWS or IAM account.
* Example: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
* @param credential Secret access key ID associated with your Amazon AWS or IAM account.
* @param proxyHost Optional - proxy server used to connect to Amazon API. If empty no proxy will be used.
* Default: ""
* @param proxyPort Optional - proxy server port. You must either specify values for both proxyHost and
* proxyPort inputs or leave them both empty.
* Default: ""
* @param proxyUsername Optional - proxy server user name.
* Default: ""
* @param proxyPassword Optional - proxy server password associated with the proxyUsername input value.
* Default: ""
* @param function Lambda function name to call
* Example: "helloWord"
* @param qualifier Optional - Lambda function version or alias
* Example: ":1"
* Default: "$LATEST"
* @param payload Optional - Lambda function payload in JSON format
* Example: "{"key1":"value1", "key1":"value2"}"
* Default: null
* @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 = "Invoke AWS Lambda Function", 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 = IDENTITY, required = true) String identity, @Param(value = CREDENTIAL, required = true, encrypted = true) String credential, @Param(value = REGION, required = true) String region, @Param(value = PROXY_HOST) String proxyHost, @Param(value = PROXY_PORT) String proxyPort, @Param(value = PROXY_USERNAME) String proxyUsername, @Param(value = PROXY_PASSWORD) String proxyPassword, @Param(value = FUNCTION_NAME, required = true) String function, @Param(value = FUNCTION_QUALIFIER) String qualifier, @Param(value = FUNCTION_PAYLOAD) String payload, @Param(value = CONNECT_TIMEOUT) String connectTimeoutMs, @Param(value = EXECUTION_TIMEOUT) String execTimeoutMs) {
proxyPort = defaultIfEmpty(proxyPort, DefaultValues.PROXY_PORT);
connectTimeoutMs = defaultIfEmpty(connectTimeoutMs, DefaultValues.CONNECT_TIMEOUT);
execTimeoutMs = defaultIfBlank(execTimeoutMs, DefaultValues.EXEC_TIMEOUT);
qualifier = defaultIfBlank(qualifier, DefaultValues.DEFAULT_FUNCTION_QUALIFIER);
ClientConfiguration lambdaClientConf = AmazonWebServiceClientUtil.getClientConfiguration(proxyHost, proxyPort, proxyUsername, proxyPassword, connectTimeoutMs, execTimeoutMs);
AWSLambdaAsyncClient client = (AWSLambdaAsyncClient) AWSLambdaAsyncClientBuilder.standard().withClientConfiguration(lambdaClientConf).withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(identity, credential))).withRegion(region).build();
InvokeRequest invokeRequest = new InvokeRequest().withFunctionName(function).withQualifier(qualifier).withPayload(payload).withSdkClientExecutionTimeout(Integer.parseInt(execTimeoutMs));
try {
InvokeResult invokeResult = client.invoke(invokeRequest);
return OutputUtilities.getSuccessResultsMap(new String(invokeResult.getPayload().array()));
} catch (Exception e) {
return OutputUtilities.getFailureResultsMap(e);
}
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class DeleteLoadBalancer method execute.
/**
* Deletes the specified Application Load Balancer and its attached listeners.
* Note: You can't delete a load balancer if deletion protection is enabled. If the load balancer does not exist or
* has already been deleted, the call succeeds. Deleting a load balancer does not affect its registered targets.
* For example, your EC2 instances continue to run and are still registered to their target groups. If you no longer
* need these EC2 instances, you can stop or terminate them.
*
* @param endpoint Optional - Endpoint to which request will be sent.
* Default: "https://elasticloadbalancing.amazonaws.com"
* @param identity ID of the secret access key associated with your Amazon AWS or IAM account.
* Example: "AKIAIOSFODNN7EXAMPLE"
* @param credential Secret access key associated with your Amazon AWS or IAM account.
* Example: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
* @param proxyHost Optional - proxy server used to connect to Amazon API. If empty no proxy will be used.
* Default: ""
* @param proxyPort Optional - proxy server port. You must either specify values for both proxyHost and
* proxyPort inputs or leave them both empty.
* Default: ""
* @param proxyUsername Optional - proxy server user name.
* Default: ""
* @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"
* Default: ""
* @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"
* Default: ""
* @param version Optional - Version of the web service to made the call against it.
* Example: "2015-12-01"
* Default: "2015-12-01"
* @param loadBalancerArn Amazon Resource Name (ARN) of the load balancer.
* Example: "arn:aws:elasticloadbalancing:us-west-2:123456789012:loadbalancer/app/my-load-balancer/50dc6c495c0c9188"
* @return A map with strings as keys and strings as values that contains: outcome of the action (or failure message
* and the exception if there is one), returnCode of the operation and the ID of the request
*/
@Action(name = "Delete Load Balancer", outputs = { @Output(RETURN_CODE), @Output(RETURN_RESULT), @Output(EXCEPTION) }, responses = { @Response(text = SUCCESS, field = RETURN_CODE, value = ReturnCodes.SUCCESS, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED), @Response(text = FAILURE, field = RETURN_CODE, value = ReturnCodes.FAILURE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, isOnFail = true) })
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 = LOAD_BALANCER_ARN, required = true) String loadBalancerArn) {
try {
version = getDefaultStringInput(version, LOAD_BALANCER_DEFAULT_API_VERSION);
final CommonInputs commonInputs = new CommonInputs.Builder().withEndpoint(endpoint, LOAD_BALANCING_API, EMPTY).withIdentity(identity).withCredential(credential).withProxyHost(proxyHost).withProxyPort(proxyPort).withProxyUsername(proxyUsername).withProxyPassword(proxyPassword).withHeaders(headers).withQueryParams(queryParams).withVersion(version).withAction(DELETE_LOAD_BALANCER).withApiService(LOAD_BALANCING_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
final LoadBalancerInputs loadBalancerInputs = new LoadBalancerInputs.Builder().withLoadBalancerArn(loadBalancerArn).build();
return new QueryApiExecutor().execute(commonInputs, loadBalancerInputs);
} catch (Exception exception) {
return ExceptionProcessor.getExceptionResult(exception);
}
}
Aggregations