Search in sources :

Example 51 with Action

use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.

the class GetBucket method execute.

/**
 * Returns some or all (up to 1,000) of the objects in a bucket. You can use the request parameters as selection criteria
 * to return a subset of the objects in a bucket. A 200 OK response can contain valid or invalid XML. Make sure to
 * design your application to parse the contents of the response and handle it appropriately. To use this implementation
 * of the operation, you must have READ access to the bucket.
 * Note: This section describe the latest revision of the API. We recommend that you use this revised API, GET Bucket
 * (List Objects) version 2, for application development. For backward compatibility, Amazon S3 continues to support
 * the prior version of this API, GET Bucket (List Objects) version 1. For more information about the previous version,
 * see GET Bucket (List Objects) Version 1: http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGET.html
 *
 * @param endpoint          Optional - Endpoint to which request will be sent.
 *                          Default: "https://s3.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&parameterName2=parameterValue2"
 *                          Default: ""
 * @param version           Optional - Version of the web service to made the call against it.
 *                          Example: "2006-03-01"
 *                          Default: "2006-03-01"
 * @param bucketName        Optional - HTTP Host Header Bucket Specification as it is described in Virtual Hosting of
 *                          Buckets API Guide: http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html
 *                          Default: ""
 * @param continuationToken Optional - When the Amazon S3 response to this API call is truncated (that is, IsTruncated
 *                          response element value is true), the response also includes the NextContinuationToken element,
 *                          the value of which you can use in the next request as the continuation-token to list the
 *                          next set of objects. The continuation token is an opaque value that Amazon S3 understands.
 *                          Amazon S3 lists objects in UTF-8 character encoding in lexicographical order.
 *                          Default: ""
 * @param delimiter         Optional - Character you use to group keys. If you specify a prefix, all keys that contain
 *                          the same string between the prefix and the first occurrence of the delimiter after the prefix
 *                          are grouped under a single result element called CommonPrefixes. If you don't specify the
 *                          prefix parameter, the substring starts at the beginning of the key. The keys that are grouped
 *                          under the CommonPrefixes result element are not returned elsewhere in the response.
 *                          Default: ""
 * @param encodingType      Optional - Requests Amazon S3 to encode the response and specifies the encoding method to use.
 *                          An object key can contain any Unicode character. However, XML 1.0 parsers cannot parse some
 *                          characters, such as characters with an ASCII value from 0 to 10. For characters that are not
 *                          supported in XML 1.0, you can add this parameter to request that Amazon S3 encode the keys in
 *                          the response.
 *                          Examples: "url"
 *                          Default: ""
 * @param fetchOwner        Optional - By default, the API does not return the Owner information in the response.
 *                          If you want the owner information in the response, you can specify this parameter with the
 *                          value set to true.
 *                          Valid values: "false", "true"
 *                          Default: "false"
 * @param maxKeys           Optional - Sets the maximum number of keys returned in the response body. If you want to
 *                          retrieve fewer than the default 1,000 keys, you can add this to your request. The response
 *                          might contain fewer keys, but it will never contain more. If there are additional keys
 *                          that satisfy the search criteria, but these keys were not returned because max-keys was
 *                          exceeded, the response contains <IsTruncated>true</IsTruncated>. To return the additional
 *                          keys, see NextContinuationToken.
 *                          Examples: "3"
 *                          Default: "1000"
 * @param prefix            Optional - Limits the response to keys that begin with the specified prefix. You can use
 *                          prefixes to separate a bucket into different groupings of keys. (You can think of using
 *                          prefix to make groups in the same way you'd use a folder in a file system.)
 *                          Examples: "E"
 *                          Default: ""
 * @param startAfter        Optional - If you want the API to return key names after a specific object key in your
 *                          key space, you can add this parameter. Amazon S3 lists objects in UTF-8 character encoding
 *                          in lexicographical order. This parameter is valid only in your first request. In case the
 *                          response is truncated, you can specify this parameter along with the continuation-token
 *                          parameter, and then Amazon S3 will ignore this parameter.
 *                          Examples: "ExampleGuide.pdf"
 *                          Default: ""
 * @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 = "Get Bucket", 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 = BUCKET_NAME) String bucketName, @Param(value = CONTINUATION_TOKEN) String continuationToken, @Param(value = DELIMITER) String delimiter, @Param(value = ENCODING_TYPE) String encodingType, @Param(value = FETCH_OWNER) String fetchOwner, @Param(value = MAX_KEYS) String maxKeys, @Param(value = PREFIX) String prefix, @Param(value = START_AFTER) String startAfter) {
    try {
        version = getDefaultStringInput(version, STORAGE_DEFAULT_API_VERSION);
        final CommonInputs commonInputs = new CommonInputs.Builder().withEndpoint(endpoint, S3_API, bucketName).withIdentity(identity).withCredential(credential).withProxyHost(proxyHost).withProxyPort(proxyPort).withProxyUsername(proxyUsername).withProxyPassword(proxyPassword).withHeaders(headers).withQueryParams(queryParams).withVersion(version).withDelimiter(delimiter).withAction(GET_BUCKET).withApiService(S3_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
        final StorageInputs storageInputs = new StorageInputs.Builder().withBucketName(bucketName).withContinuationToken(continuationToken).withEncodingType(encodingType).withFetchOwner(fetchOwner).withMaxKeys(maxKeys).withPrefix(prefix).withStartAfter(startAfter).build();
        return new QueryApiExecutor().execute(commonInputs, storageInputs);
    } catch (Exception exception) {
        return ExceptionProcessor.getExceptionResult(exception);
    }
}
Also used : CommonInputs(io.cloudslang.content.amazon.entities.inputs.CommonInputs) QueryApiExecutor(io.cloudslang.content.amazon.execute.QueryApiExecutor) StorageInputs(io.cloudslang.content.amazon.entities.inputs.StorageInputs) Action(com.hp.oo.sdk.content.annotations.Action)

Example 52 with Action

use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.

the class CreateTagsAction method execute.

/**
 * Adds or overwrites one or more tags for the specified Amazon EC2 resource/resources.
 * Note: Each resource can have a maximum of 50 tags. Each tag consists of a key and optional value. Tag keys must be
 * unique per resource. For more information about tags, see Tagging Your Resources:
 * http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html in the Amazon Elastic Compute Cloud User Guide.
 * For more information about creating IAM policies that control users' access to resources based on tags, see
 * Supported Resource-Level Permissions: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-supported-iam-actions-resources.html
 * for Amazon EC2 API Actions 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&parameterName2=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 resourceIdsString String that contains Id's of one or more resources to tag.
 *                          Example: "i-12345678"
 * @param keyTagsString     String that contains one or more key tags separated by delimiter.
 *                          Constraints: Tag keys are case-sensitive and accept a maximum of 127 Unicode characters.
 *                          May not begin with "aws:";  Each resource can have a maximum of 50 tags.
 *                          Note: if you want to overwrite the existing tag and replace it with empty value then
 *                          specify the parameter with "Not relevant" string
 *                          Example: "Name,webserver,stack,scope"
 *                          Default: ""
 * @param valueTagsString   String that contains one or more tag values separated by delimiter. The value parameter
 *                          is required, but if you don't want the tag to have a value, specify the parameter with
 *                          "Not relevant" string, and we set the value to an empty string.
 *                          Constraints: Tag values are case-sensitive and accept a maximum of 255 Unicode characters;
 *                          Each resource can have a maximum of 50 tags
 *                          Example of values string for tagging resourceswith values corresponding to the keys from
 *                          above example: "Tagged from API call,Not relevant,Testing,For testing purposes"
 *                          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 = "Create Tags", 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 = RESOURCE_IDS_STRING, required = true) String resourceIdsString, @Param(value = KEY_TAGS_STRING, required = true) String keyTagsString, @Param(value = VALUE_TAGS_STRING, required = true) String valueTagsString) {
    try {
        version = getDefaultStringInput(version, TAGS_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(CREATE_TAGS).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
        final CustomInputs customInputs = new CustomInputs.Builder().withKeyTagsString(keyTagsString).withValueTagsString(valueTagsString).withResourceIdsString(resourceIdsString).build();
        return new QueryApiExecutor().execute(commonInputs, customInputs);
    } catch (Exception e) {
        return ExceptionProcessor.getExceptionResult(e);
    }
}
Also used : CommonInputs(io.cloudslang.content.amazon.entities.inputs.CommonInputs) QueryApiExecutor(io.cloudslang.content.amazon.execute.QueryApiExecutor) CustomInputs(io.cloudslang.content.amazon.entities.inputs.CustomInputs) Action(com.hp.oo.sdk.content.annotations.Action)

Example 53 with Action

use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.

the class DescribeTagsAction method execute.

/**
 * Describes one or more of the tags for your EC2 resources.
 *
 * @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.
 * @param proxyPort                             Optional - proxy server port. You must either specify values for both
 *                                              proxyHost and proxyPort inputs or leave them both empty.
 * @param proxyUsername                         Optional - proxy server user name.
 *                                              Default: ""
 * @param proxyPassword                         Optional - proxy server password associated with the proxyUsername
 *                                              input value.
 * @param version                               Optional - Version of the web service to made the call against it.
 *                                              Example: "2016-11-15"
 *                                              Default: "2016-11-15"
 * @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&parameterName2=parameterValue2"
 *                                              Default: ""
 * @param delimiter                             Optional - Delimiter that will be used between filter values.
 *                                              Default: ","
 * @param filterKey                             Optional - The tag key.
 *                                              Default: ""
 * @param filterResourceId                      Optional - The resource ID.
 *                                              Default: ""
 * @param filterResourceType                    Optional - The resource type.
 *                                              Valid values: customer-gateway, dhcp-options, image, instance,
 *                                              internet-gateway, network-acl, network-interface, reserved-instances,
 *                                              route-table, security-group, snapshot, spot-instances-request,
 *                                              subnet, volume, vpc, vpn-connection, vpn-gateway.
 *                                              Default: ""
 * @param filterValue                           Optional - The tag value.
 *                                              Default: ""
 * @param maxResults                            Optional - The maximum number of results to return in a single call.
 *                                              This value can be between 5 and 1000. To retrieve the remaining
 *                                              results, make another call with the returned NextToken value.
 *                                              Default: ""
 * @param nextToken                             Optional - The token to retrieve the next page of results.
 *                                              Default: ""
 * @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 = "Describe Tags", 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 = DELIMITER) String delimiter, @Param(value = FILTER_KEY) String filterKey, @Param(value = FILTER_RESOURCE_ID) String filterResourceId, @Param(value = FILTER_RESOURCE_TYPE) String filterResourceType, @Param(value = FILTER_VALUE) String filterValue, @Param(value = MAX_RESULTS) String maxResults, @Param(value = NEXT_TOKEN) String nextToken) {
    try {
        version = getDefaultStringInput(version, TAGS_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_TAGS).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
        final List<ImmutablePair<String, String>> filterPairs = Arrays.asList(of(KEY, filterKey), of(RESOURCE_ID, filterResourceId), of(RESOURCE_TYPE, filterResourceType), of(VALUE, filterValue));
        final FilterInputs.Builder filterInputsBuilder = new FilterInputs.Builder().withDelimiter(commonInputs.getDelimiter()).withMaxResults(maxResults).withNextToken(nextToken);
        for (ImmutablePair<String, String> filterPair : filterPairs) {
            if (isNotEmpty(filterPair.getRight())) {
                filterInputsBuilder.withNewFilter(filterPair.getLeft(), filterPair.getRight());
            }
        }
        final FilterInputs filterInputs = filterInputsBuilder.build();
        return new QueryApiExecutor().execute(commonInputs, filterInputs);
    } catch (Exception exception) {
        return ExceptionProcessor.getExceptionResult(exception);
    }
}
Also used : CommonInputs(io.cloudslang.content.amazon.entities.inputs.CommonInputs) FilterInputs(io.cloudslang.content.amazon.entities.inputs.FilterInputs) QueryApiExecutor(io.cloudslang.content.amazon.execute.QueryApiExecutor) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Action(com.hp.oo.sdk.content.annotations.Action)

Example 54 with Action

use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.

the class AttachVolumeAction method execute.

/**
 * Attaches an EBS volume to a running or stopped instance and exposes it to the instance with the specified device
 * name.
 * Note: Encrypted EBS volumes may only be attached to instances that support Amazon EBS encryption. For more information,
 * see Amazon EBS Encryption in the Amazon Elastic Compute Cloud User Guide. For a list of supported device names, see
 * Attaching an EBS Volume to an Instance. Any device names that aren't reserved for instance store volumes can be used
 * for EBS volumes. For more information, see Amazon EC2 Instance Store in the Amazon Elastic Compute Cloud User Guide.
 * If a volume has an AWS Marketplace product code:
 * - The volume can be attached only to a stopped instance.
 * - AWS Marketplace product codes are copied from the volume to the instance.
 * - You must be subscribed to the product.
 * - The instance type and operating system of the instance must support the product. For example, you can't detach
 * a volume from a Windows instance and attach it to a Linux instance.
 * For more information about EBS volumes, see Attaching Amazon EBS Volumes 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&parameterName2=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"
 * @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 = "Attach 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, required = true) String instanceId, @Param(value = VOLUME_ID, required = true) String volumeId, @Param(value = DEVICE_NAME, required = true) String deviceName) {
    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(ATTACH_VOLUME).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
        final CustomInputs customInputs = new CustomInputs.Builder().withInstanceId(instanceId).withVolumeId(volumeId).build();
        final VolumeInputs volumeInputs = new VolumeInputs.Builder().withDeviceName(deviceName).build();
        return new QueryApiExecutor().execute(commonInputs, customInputs, volumeInputs);
    } catch (Exception e) {
        return ExceptionProcessor.getExceptionResult(e);
    }
}
Also used : CommonInputs(io.cloudslang.content.amazon.entities.inputs.CommonInputs) VolumeInputs(io.cloudslang.content.amazon.entities.inputs.VolumeInputs) QueryApiExecutor(io.cloudslang.content.amazon.execute.QueryApiExecutor) CustomInputs(io.cloudslang.content.amazon.entities.inputs.CustomInputs) Action(com.hp.oo.sdk.content.annotations.Action)

Example 55 with Action

use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.

the class DeleteVolume method execute.

/**
 * Deletes the specified EBS volume. The volume must be in the "available" state (not attached to an instance).
 * Note: The volume may remain in the deleting state for several minutes. For more information, see Deleting an Amazon
 * EBS Volume in the Amazon Elastic Compute Cloud User Guide: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-deleting-volume.html
 *
 * @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&parameterName2=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 volumeId      ID of the EBS volume to be deleted.
 * @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 = "Delete 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 = VOLUME_ID, required = true) String volumeId) {
    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(DELETE_VOLUME).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
        final CustomInputs customInputs = new CustomInputs.Builder().withVolumeId(volumeId).build();
        return new QueryApiExecutor().execute(commonInputs, customInputs);
    } catch (Exception e) {
        return ExceptionProcessor.getExceptionResult(e);
    }
}
Also used : CommonInputs(io.cloudslang.content.amazon.entities.inputs.CommonInputs) QueryApiExecutor(io.cloudslang.content.amazon.execute.QueryApiExecutor) CustomInputs(io.cloudslang.content.amazon.entities.inputs.CustomInputs) Action(com.hp.oo.sdk.content.annotations.Action)

Aggregations

Action (com.hp.oo.sdk.content.annotations.Action)230 CommonInputs (io.cloudslang.content.amazon.entities.inputs.CommonInputs)48 QueryApiExecutor (io.cloudslang.content.amazon.execute.QueryApiExecutor)47 CustomInputs (io.cloudslang.content.amazon.entities.inputs.CustomInputs)32 HttpClientInputs (io.cloudslang.content.httpclient.entities.HttpClientInputs)29 HashMap (java.util.HashMap)22 VmInputs (io.cloudslang.content.vmware.entities.VmInputs)21 HttpInputs (io.cloudslang.content.vmware.entities.http.HttpInputs)21 CommonInputs (io.cloudslang.content.couchbase.entities.inputs.CommonInputs)15 CouchbaseService (io.cloudslang.content.couchbase.execute.CouchbaseService)15 InputsUtil.getHttpClientInputs (io.cloudslang.content.couchbase.utils.InputsUtil.getHttpClientInputs)15 NetworkInputs (io.cloudslang.content.amazon.entities.inputs.NetworkInputs)11 Map (java.util.Map)11 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)10 CommonInputs (io.cloudslang.content.amazon.entities.constants.Inputs.CommonInputs)9 InstanceInputs (io.cloudslang.content.amazon.entities.inputs.InstanceInputs)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 JsonParser (com.google.gson.JsonParser)8 SFTPService (io.cloudslang.content.rft.services.SFTPService)8 ClusterComputeResourceService (io.cloudslang.content.vmware.services.ClusterComputeResourceService)8