Search in sources :

Example 41 with Action

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

the class ComputeSignatureV4 method execute.

/**
 * Computes the AWS Signature Version 4 used to authenticate requests by using the authorization header.
 * For this signature type the checksum of the entire payload is computed.
 * Note: The "authorizationHeader" output's value should be added in the "Authorization" header.
 *
 * @param endpoint      Service endpoint used to compute the signature. Ex.: "ec2.amazonaws.com", "s3.amazonaws.com"
 *                      Default: "ec2.amazonaws.com"
 * @param identity      ID of the secret access key associated with your Amazon AWS or IAM account.
 * @param credential    Secret access key associated with your Amazon AWS or IAM account.
 * @param amazonApi     Amazon API corresponding to where the request is send.
 *                      Examples: "ec2", "s3"
 * @param uri           request's relative URI. The URI should be from the service endpoint to the query params.
 *                      Default: "/"
 * @param httpVerb      Method used for the request. You need to specify this with upper case.
 *                      Valid values: GET, DELETE, HEAD, POST, PUT
 *                      Default: GET
 * @param payloadHash   Payload's hash that will be included in the signature. The hashing should be computed using
 *                      the "SHA-256" hashing algorithm and then hex encoded.
 * @param securityToken URI-encoded session token. The string you received from AWS STS when you obtained temporary
 *                      security credentials.
 * @param date          Date of the request. The date should be also included in the "x-amz-date" header and should
 *                      be in the in the YYYYMMDD'T'HHMMSS'Z' format form UTC time zone.
 *                      Example: 20150416T112043Z for April 16, 2015 11:20:43 AM UTC
 *                      Default: The current date and time in UTC time zone
 * @param headers       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   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;
 * @param prefix        Optional - used to sign request for Simple Storage Service (S3). This prefix will precede the
 *                      endpoint when made calls for specific bucket (for e.g. if prefix is "mybucket" then the endpoint
 *                      where the request are made will be "mybucket.s3.amazonaws.com")
 *                      Default: ""
 * @return A map, with strings as keys and values, that contains: outcome of the action, returnCode of the operation
 *         or failure message, the exception if there is one, signature value and authorization header value
 */
@Action(name = "Compute Signature V4", outputs = { @Output(Outputs.RETURN_CODE), @Output(Outputs.RETURN_RESULT), @Output(Outputs.EXCEPTION), @Output(SIGNATURE_RESULT), @Output(AUTHORIZATION_HEADER_RESULT) }, 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, 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 = HEADERS) String headers, @Param(value = QUERY_PARAMS) String queryParams, @Param(value = AMAZON_API) String amazonApi, @Param(value = URI) String uri, @Param(value = HTTP_VERB) String httpVerb, @Param(value = PAYLOAD_HASH) String payloadHash, @Param(value = DATE) String date, @Param(value = SECURITY_TOKEN) String securityToken, @Param(value = PREFIX) String prefix) {
    try {
        Map<String, String> headersMap = getHeadersOrQueryParamsMap(new HashMap<String, String>(), headers, HEADER_DELIMITER, COLON, true);
        Map<String, String> queryParamsMap = getHeadersOrQueryParamsMap(new HashMap<String, String>(), queryParams, AMPERSAND, EQUAL, false);
        CommonInputs commonInputs = new CommonInputs.Builder().withEndpoint(endpoint, amazonApi, prefix).withIdentity(identity).withCredential(credential).build();
        InputsWrapper wrapper = new InputsWrapper.Builder().withCommonInputs(commonInputs).withApiService(amazonApi).withRequestUri(uri).withHttpVerb(httpVerb).withRequestPayload(payloadHash).withDate(date).withHeaders(headers).withQueryParams(queryParams).withSecurityToken(securityToken).build();
        AuthorizationHeader authorizationHeader = new AmazonSignatureService().signRequestHeaders(wrapper, headersMap, queryParamsMap);
        return OutputsUtil.populateSignatureResultsMap(authorizationHeader);
    } catch (Exception exception) {
        return ExceptionProcessor.getExceptionResult(exception);
    }
}
Also used : CommonInputs(io.cloudslang.content.amazon.entities.inputs.CommonInputs) InputsWrapper(io.cloudslang.content.amazon.entities.inputs.InputsWrapper) AuthorizationHeader(io.cloudslang.content.amazon.entities.aws.AuthorizationHeader) AmazonSignatureService(io.cloudslang.content.amazon.services.AmazonSignatureService) Action(com.hp.oo.sdk.content.annotations.Action)

Example 42 with Action

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

the class CreateSubnetAction method execute.

/**
 * Creates a subnet in an existing VPC.
 * Note: When you create each subnet, you provide the VPC ID and the CIDR block you want for the subnet. After you
 * create a subnet, you can't change its CIDR block. The subnet's CIDR block can be the same as the VPC's CIDR block
 * (assuming you want only a single subnet in the VPC), or a subset of the VPC's CIDR block. If you create more than
 * one subnet in a VPC, the subnets' CIDR blocks must not overlap. The smallest subnet (and VPC) you can create uses
 * a /28 netmask (16 IP addresses), and the largest uses a /16 netmask (65,536 IP addresses).
 * Important: AWS reserves both the first four and the last IP address in each subnet's CIDR block. They're not available
 * for use. If you add more than one subnet to a VPC, they're set up in a star topology with a logical router in the
 * middle. If you launch an instance in a VPC using an Amazon EBS-backed AMI, the IP address doesn't change if you
 * stop and restart the instance (unlike a similar instance launched outside a VPC, which gets a new IP address when
 * restarted). It's therefore possible to have a subnet with no running instances (they're all stopped), but no remaining
 * IP addresses available.
 * For more information about subnets, see Your VPC and Subnets: http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html
 * in the Amazon Virtual Private 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.
 * @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 availabilityZone Optional - Availability Zone for the subnet.
 *                         Default: AWS selects one for you. If you create more than one subnet in your VPC, we may
 *                         not necessarily select a different zone for each subnet.
 * @param vpcId            ID of the VPC
 * @param cidrBlock        Network range for the subnet, in CIDR notation.
 *                         Example: "10.0.0.0/24"
 * @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 = "Create Subnet", 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 = AVAILABILITY_ZONE) String availabilityZone, @Param(value = VPC_ID, required = true) String vpcId, @Param(value = CIDR_BLOCK, required = true) String cidrBlock) {
    try {
        version = getDefaultStringInput(version, NETWORK_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(CREATE_SUBNET).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
        final CustomInputs customInputs = new CustomInputs.Builder().withAvailabilityZone(availabilityZone).withVpcId(vpcId).build();
        final NetworkInputs networkInputs = new NetworkInputs.Builder().withCidrBlock(cidrBlock).build();
        return new QueryApiExecutor().execute(commonInputs, customInputs, networkInputs);
    } catch (Exception exception) {
        return ExceptionProcessor.getExceptionResult(exception);
    }
}
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) NetworkInputs(io.cloudslang.content.amazon.entities.inputs.NetworkInputs) Action(com.hp.oo.sdk.content.annotations.Action)

Example 43 with Action

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

the class CreateVpc method execute.

/**
 * Creates a VPC with the specified IPv4 CIDR block.
 * Note: The smallest VPC you can create uses a /28 netmask (16 IPv4 addresses), and the largest uses a /16 netmask
 * (65,536 IPv4 addresses). To help you decide how big to make your VPC, see Your VPC and Subnets in the Amazon Virtual
 * Private Cloud User Guide: http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html
 * You can optionally request an Amazon-provided IPv6 CIDR block for the VPC. The IPv6 CIDR block uses a /56 prefix
 * length, and is allocated from Amazon's pool of IPv6 addresses. You cannot choose the IPv6 range for your VPC.
 * By default, each instance you launch in the VPC has the default DHCP options, which includes only a default DNS
 * server that we provide (AmazonProvidedDNS). For more information about DHCP options, see DHCP Options Sets:
 * http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_DHCP_Options.html
 * You can specify the instance tenancy value for the VPC when you create it. You can't change this value for the VPC
 * after you create it. For more information, see Dedicated Instances: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/dedicated-instance.html
 * <p>
 * Important: This is an idempotent operation. If you perform the operation more than once, Amazon EC2 doesn't return
 * an error.
 *
 * @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.
 * @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&parameterName2=parameterValue2"
 * @param version                     Optional - Version of the web service to made the call against it.
 *                                    Example: "2016-11-15"
 *                                    Default: "2016-11-15"
 * @param amazonProvidedIpv6CidrBlock Optional - Requests an Amazon-provided IPv6 CIDR block with a /56 prefix length
 *                                    for the VPC. You cannot specify the range of IP addresses, or the size of the
 *                                    CIDR block.
 *                                    Valid values: "true", "false"
 *                                    Default: "false"
 * @param cidrBlock                   IPv4 network range for the VPC, in CIDR notation.
 *                                    Example: "10.0.0.0/16"
 *                                    Default: "10.0.0.0/28"
 * @param tenancy                     Optional - tenancy options for instances launched into the VPC. For default,
 *                                    instances are launched with shared tenancy by default. You can launch instances
 *                                    with any tenancy into a shared tenancy VPC. For dedicated, instances are launched
 *                                    as dedicated tenancy instances by default. You can only launch instances with
 *                                    a tenancy of dedicated or host into a dedicated tenancy VPC.
 *                                    Important: The "host" value cannot be used with this parameter. Use the "default"
 *                                    or "dedicated" values only.
 *                                    Valid values: "default", "dedicated"
 *                                    Default: "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 = "Create Vpc", outputs = { @Output(OutputNames.RETURN_CODE), @Output(OutputNames.RETURN_RESULT), @Output(OutputNames.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, 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 = QUERY_PARAMS) String queryParams, @Param(value = HEADERS) String headers, @Param(value = VERSION) String version, @Param(value = AMAZON_PROVIDED_IPV6_CIDR_BLOCK) String amazonProvidedIpv6CidrBlock, @Param(value = CIDR_BLOCK) String cidrBlock, @Param(value = TENANCY) String tenancy) {
    try {
        version = getDefaultStringInput(version, NETWORK_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(CREATE_VPC).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
        final InstanceInputs instanceInputs = new InstanceInputs.Builder().withTenancy(tenancy).build();
        final NetworkInputs networkInputs = new NetworkInputs.Builder().withAmazonProvidedIpv6CidrBlock(amazonProvidedIpv6CidrBlock).withCidrBlock(cidrBlock).build();
        return new QueryApiExecutor().execute(commonInputs, instanceInputs, networkInputs);
    } catch (Exception exception) {
        return ExceptionProcessor.getExceptionResult(exception);
    }
}
Also used : CommonInputs(io.cloudslang.content.amazon.entities.constants.Inputs.CommonInputs) CommonInputs(io.cloudslang.content.amazon.entities.inputs.CommonInputs) QueryApiExecutor(io.cloudslang.content.amazon.execute.QueryApiExecutor) InstanceInputs(io.cloudslang.content.amazon.entities.inputs.InstanceInputs) NetworkInputs(io.cloudslang.content.amazon.entities.inputs.NetworkInputs) Action(com.hp.oo.sdk.content.annotations.Action)

Example 44 with Action

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

the class DeleteNetworkInterfaceAction method execute.

/**
 * Deletes the specified network interface.
 * Note: You must detach the network interface before you can delete it.
 *
 * @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 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"
 * @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 networkInterfaceId ID of the network interface to delete.
 *                           Example: "eni-12345678"
 * @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 Network Interface", 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, 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 = NETWORK_INTERFACE_ID, required = true) String networkInterfaceId) {
    try {
        version = getDefaultStringInput(version, NETWORK_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_NETWORK_INTERFACE).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
        final NetworkInputs networkInputs = new NetworkInputs.Builder().withNetworkInterfaceId(networkInterfaceId).build();
        return new QueryApiExecutor().execute(commonInputs, networkInputs);
    } catch (Exception exception) {
        return ExceptionProcessor.getExceptionResult(exception);
    }
}
Also used : CommonInputs(io.cloudslang.content.amazon.entities.inputs.CommonInputs) QueryApiExecutor(io.cloudslang.content.amazon.execute.QueryApiExecutor) NetworkInputs(io.cloudslang.content.amazon.entities.inputs.NetworkInputs) Action(com.hp.oo.sdk.content.annotations.Action)

Example 45 with Action

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

the class DeleteVpc method execute.

/**
 * Deletes the specified VPC.
 * Note: You must detach or delete all gateways and resources that are associated with the VPC before you can delete
 * it. For example, you must terminate all instances running in the VPC, delete all security groups associated with
 * the VPC (except the default one), delete all route tables associated with the VPC (except the default one), and
 * so on.
 *
 * @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.
 * @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&parameterName2=parameterValue2"
 * @param version       Optional - Version of the web service to made the call against it.
 *                      Example: "2016-11-15"
 *                      Default: "2016-11-15"
 * @param vpcId         ID of the VPC to be deleted.
 * @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 Vpc", outputs = { @Output(OutputNames.RETURN_CODE), @Output(OutputNames.RETURN_RESULT), @Output(OutputNames.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, 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 = QUERY_PARAMS) String queryParams, @Param(value = HEADERS) String headers, @Param(value = VERSION) String version, @Param(value = VPC_ID) String vpcId) {
    try {
        version = getDefaultStringInput(version, NETWORK_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_VPC).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
        final CustomInputs customInputs = new CustomInputs.Builder().withVpcId(vpcId).build();
        return new QueryApiExecutor().execute(commonInputs, customInputs);
    } catch (Exception exception) {
        return ExceptionProcessor.getExceptionResult(exception);
    }
}
Also used : CommonInputs(io.cloudslang.content.amazon.entities.constants.Inputs.CommonInputs) 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