use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class DescribeNetworkInterfacesAction method execute.
/**
* Describes one or more of your network interfaces.
*
* @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¶meterName2=parameterValue2"
* Default: ""
* @param delimiter Optional - Delimiter that will be used.
* @param filterAddressesPrivateIpAddress Optional - The private IPv4 addresses associated with the network
* interface.
* @param filterAddressesPrimary Optional - Whether the private IPv4 address is the primary IP address
* associated with the network interface.
* @param filterAddressesAssociationPublicIp Optional - The association ID returned when the network interface was
* associated with the Elastic IP address (IPv4).
* @param filterAddressesAssociationOwnerId Optional - The owner ID of the addresses associated with the network
* interface.
* @param filterAssociationAssociationId Optional - The association ID returned when the network interface
* was associated with an IPv4 address.
* @param filterAssociationAllocationId Optional - The allocation ID returned when you allocated the Elastic
* IP address (IPv4) for your network interface.
* @param filterAssociationIpOwnerId Optional - The owner of the Elastic IP address (IPv4) associated
* with the network interface.
* @param filterAssociationPublicIp Optional - The address of the Elastic IP address (IPv4) bound to the
* network interface.
* @param filterAssociationPublicDnsName Optional - The public DNS name for the network interface (IPv4).
* @param filterAttachmentAttachmentId Optional - The ID of the interface attachment.
* @param filterAttachmentAttachTime Optional - The time that the network interface was attached to an
* instance.
* @param filterAttachmentDeleteOnTermination Optional - Indicates whether the attachment is deleted when an
* instance is terminated.
* @param filterAttachmentDeviceIndex Optional - The device index to which the network interface is attached.
* @param filterAttachmentInstanceId Optional - The ID of the instance to which the network interface is
* attached.
* @param filterAttachmentInstanceOwnerId Optional - The owner ID of the instance to which the network
* interface is attached.
* @param filterAttachmentNatGatewayId Optional - The ID of the NAT gateway to which the network interface
* is attached.
* @param filterAttachmentStatus Optional - The status of the attachment.
* Valid values: attaching, attached, detaching, detached.
* @param filterAvailabilityZone Optional - The Availability Zone of the network interface.
* @param filterDescription Optional - The description of the network interface.
* @param filterGroupId Optional - The ID of a security group associated with the network
* interface.
* @param filterGroupName Optional - The name of a security group associated with the network
* interface.
* @param filterIpv6AddressesIpv6Address Optional - An IPv6 address associated with the network interface.
* @param filterMacAddress Optional - The MAC address of the network interface.
* @param filterNetworkInterfaceId Optional - The ID of the network interface.
* @param filterOwnerId Optional - The AWS account ID of the network interface owner.
* @param filterPrivateIpAddress Optional - The private IPv4 address or addresses of the network
* interface.
* @param filterPrivateDnsName Optional - The private DNS name of the network interface (IPv4).
* @param filterRequesterId Optional - The ID of the entity that launched the instance on your
* behalf (for example, AWS Management Console, Auto Scaling, and so on).
* @param filterRequesterManaged Optional - Indicates whether the network interface is being managed
* by an AWS service (for example, AWS Management Console, Auto Scaling,
* and so on).
* @param filterSourceDestCheck Optional - Indicates whether the network interface performs
* source/destination checking. A value of true means checking is
* enabled, and false means checking is disabled. The value must be
* false for the network interface to perform network address
* translation (NAT) in your VPC.
* @param filterStatus Optional - The status of the network interface. If the network
* interface is not attached to an instance, the status is available;
* if a network interface is attached to an instance the status is in-use.
* Valid values: in-use, available.
* @param filterSubnetId Optional - The ID of the subnet for the network interface.
* @param filterTag Optional - The key/value combination of a tag assigned to the resource.
* Specify the key of the tag in the filter name and the value of the
* tag in the filter value.
* Example: Purpose1=X,Purpose2=B
* @param filterTagKey Optional - The key of a tag assigned to the resource. This filter is
* independent of the filterTagValue filter. For example, if you use both
* filterTagKey = "Purpose" and filterTagValue = "X", you get any
* resources assigned both the tag key Purpose (regardless of what
* the tag's value is), and the tag value X (regardless of what the
* tag's key is). If you want to list only resources where Purpose is X,
* see the filterTag.
* @param filterTagValue Optional - The value of a tag assigned to the resource. This filter
* is independent of the filterTagKey.
* @param filterVpcId Optional - The ID of the VPC for the network interface.
* @param networkInterfaceId Optional - String that contains one or more network interface IDs.
* Example: "eni-12345678,eni-87654321"
* 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 Network Interfaces", 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_ADDRESSES_PRIVATE_IP_ADDRESS) String filterAddressesPrivateIpAddress, @Param(value = FILTER_ADDRESSES_PRIMARY) String filterAddressesPrimary, @Param(value = FILTER_ADDRESSES_ASSOCIATION_PUBLIC_IP) String filterAddressesAssociationPublicIp, @Param(value = FILTER_ADDRESSES_ASSOCIATION_OWNER_ID) String filterAddressesAssociationOwnerId, @Param(value = FILTER_ASSOCIATION_ASSOCIATION_ID) String filterAssociationAssociationId, @Param(value = FILTER_ASSOCIATION_ALLOCATION_ID) String filterAssociationAllocationId, @Param(value = FILTER_ASSOCIATION_IP_OWNER_ID) String filterAssociationIpOwnerId, @Param(value = FILTER_ASSOCIATION_PUBLIC_IP) String filterAssociationPublicIp, @Param(value = FILTER_ASSOCIATION_PUBLIC_DNS_NAME) String filterAssociationPublicDnsName, @Param(value = FILTER_ATTACHMENT_ATTACHMENT_ID) String filterAttachmentAttachmentId, @Param(value = FILTER_ATTACHMENT_ATTACH_TIME) String filterAttachmentAttachTime, @Param(value = FILTER_ATTACHMENT_DELETE_ON_TERMINATION) String filterAttachmentDeleteOnTermination, @Param(value = FILTER_ATTACHMENT_DEVICE_INDEX) String filterAttachmentDeviceIndex, @Param(value = FILTER_ATTACHMENT_INSTANCE_ID) String filterAttachmentInstanceId, @Param(value = FILTER_ATTACHMENT_INSTANCE_OWNER_ID) String filterAttachmentInstanceOwnerId, @Param(value = FILTER_ATTACHMENT_NAT_GATEWAY_ID) String filterAttachmentNatGatewayId, @Param(value = FILTER_ATTACHMENT_STATUS) String filterAttachmentStatus, @Param(value = FILTER_AVAILABILITY_ZONE) String filterAvailabilityZone, @Param(value = FILTER_DESCRIPTION) String filterDescription, @Param(value = FILTER_GROUP_ID) String filterGroupId, @Param(value = FILTER_GROUP_NAME) String filterGroupName, @Param(value = FILTER_IPV6_ADDRESSES_IPV6_ADDRESS) String filterIpv6AddressesIpv6Address, @Param(value = FILTER_MAC_ADDRESS) String filterMacAddress, @Param(value = FILTER_NETWORK_INTERFACE_ID) String filterNetworkInterfaceId, @Param(value = FILTER_OWNER_ID) String filterOwnerId, @Param(value = FILTER_PRIVATE_IP_ADDRESS) String filterPrivateIpAddress, @Param(value = FILTER_PRIVATE_DNS_NAME) String filterPrivateDnsName, @Param(value = FILTER_REQUESTER_ID) String filterRequesterId, @Param(value = FILTER_REQUESTER_MANAGED) String filterRequesterManaged, @Param(value = FILTER_SOURCE_DEST_CHECK) String filterSourceDestCheck, @Param(value = FILTER_STATUS) String filterStatus, @Param(value = FILTER_SUBNET_ID) String filterSubnetId, @Param(value = FILTER_TAG) String filterTag, @Param(value = FILTER_TAG_KEY) String filterTagKey, @Param(value = FILTER_TAG_VALUE) String filterTagValue, @Param(value = FILTER_VPC_ID) String filterVpcId, @Param(value = NETWORK_INTERFACE_ID) 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).withDelimiter(delimiter).withAction(DESCRIBE_NETWORK_INTERFACES).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
final NetworkInputs networkInputs = new NetworkInputs.Builder().withNetworkInterfaceId(networkInterfaceId).build();
final List<ImmutablePair<String, String>> filterPairs = Arrays.asList(of(NetworkFilter.ADDRESSES_ASSOCIATION_OWNER_ID, filterAttachmentAttachTime), of(NetworkFilter.ADDRESSES_PRIVATE_IP_ADDRESS, filterAddressesPrivateIpAddress), of(NetworkFilter.ADDRESSES_PRIMARY, filterAddressesPrimary), of(NetworkFilter.ADDRESSES_ASSOCIATION_PUBLIC_IP, filterAddressesAssociationPublicIp), of(NetworkFilter.ADDRESSES_ASSOCIATION_OWNER_ID, filterAddressesAssociationOwnerId), of(NetworkFilter.ASSOCIATION_ASSOCIATION_ID, filterAssociationAssociationId), of(NetworkFilter.ASSOCIATION_ALLOCATION_ID, filterAssociationAllocationId), of(NetworkFilter.ASSOCIATION_IP_OWNER_ID, filterAssociationIpOwnerId), of(NetworkFilter.ASSOCIATION_PUBLIC_IP, filterAssociationPublicIp), of(NetworkFilter.ASSOCIATION_PUBLIC_DNS_NAME, filterAssociationPublicDnsName), of(NetworkFilter.ATTACHMENT_ATTACHMENT_ID, filterAttachmentAttachmentId), of(NetworkFilter.ATTACHMENT_ATTACH_TIME, filterAttachmentAttachTime), of(NetworkFilter.ATTACHMENT_DELETE_ON_TERMINATION, filterAttachmentDeleteOnTermination), of(NetworkFilter.ATTACHMENT_DEVICE_INDEX, filterAttachmentDeviceIndex), of(NetworkFilter.ATTACHMENT_INSTANCE_ID, filterAttachmentInstanceId), of(NetworkFilter.ATTACHMENT_INSTANCE_OWNER_ID, filterAttachmentInstanceOwnerId), of(NetworkFilter.ATTACHMENT_NAT_GATEWAY_ID, filterAttachmentNatGatewayId), of(NetworkFilter.ATTACHMENT_STATUS, filterAttachmentStatus), of(NetworkFilter.AVAILABILITY_ZONE, filterAvailabilityZone), of(NetworkFilter.DESCRIPTION, filterDescription), of(NetworkFilter.GROUP_ID, filterGroupId), of(NetworkFilter.GROUP_NAME, filterGroupName), of(NetworkFilter.IPV6_ADDRESSES_IPV6_ADDRESS, filterIpv6AddressesIpv6Address), of(NetworkFilter.MAC_ADDRESS, filterMacAddress), of(NetworkFilter.NETWORK_INTERFACE_ID, filterNetworkInterfaceId), of(NetworkFilter.OWNER_ID, filterOwnerId), of(NetworkFilter.PRIVATE_IP_ADDRESS, filterPrivateIpAddress), of(NetworkFilter.PRIVATE_DNS_NAME, filterPrivateDnsName), of(NetworkFilter.REQUESTER_ID, filterRequesterId), of(NetworkFilter.REQUESTER_MANAGED, filterRequesterManaged), of(NetworkFilter.SOURCE_DEST_CHECK, filterSourceDestCheck), of(NetworkFilter.STATUS, filterStatus), of(NetworkFilter.SUBNET_ID, filterSubnetId), of(NetworkFilter.TAG_KEY, filterTagKey), of(NetworkFilter.TAG_VALUE, filterTagValue), of(NetworkFilter.VPC_ID, filterVpcId));
final FilterInputs.Builder filterInputsBuilder = new FilterInputs.Builder().withDelimiter(commonInputs.getDelimiter());
for (ImmutablePair<String, String> filterPair : filterPairs) {
if (isNotEmpty(filterPair.getRight())) {
filterInputsBuilder.withNewFilter(filterPair.getLeft(), filterPair.getRight());
}
}
if (isNotEmpty(filterTag)) {
processTagFilter(filterTag, commonInputs.getDelimiter(), filterInputsBuilder);
}
final FilterInputs filterInputs = filterInputsBuilder.build();
return new QueryApiExecutor().execute(commonInputs, networkInputs, filterInputs);
} catch (Exception exception) {
return ExceptionProcessor.getExceptionResult(exception);
}
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class DisassociateAddressAction method execute.
/**
* Disassociates an Elastic IP address from the instance or network interface it's associated with.
* Note: An Elastic IP address is for use in either the EC2-Classic platform or in a VPC. For more information, see
* Elastic IP Addresses in the Amazon Elastic Compute Cloud User Guide.
*
* <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.
* 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"
* 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 associationId Optional - [EC2-VPC] Association ID. Required for EC2-VPC.
* Default: ""
* @param publicIp Optional - Elastic IP address. This is required for EC2-Classic.
* 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 = "Disassociate Address", 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 = QUERY_PARAMS) String queryParams, @Param(value = HEADERS) String headers, @Param(value = VERSION) String version, @Param(value = ASSOCIATION_ID) String associationId, @Param(value = PUBLIC_IP) String publicIp) {
try {
version = getDefaultStringInput(version, ELASTIC_IP_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(DISASSOCIATE_ADDRESS).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
final CustomInputs customInputs = new CustomInputs.Builder().withAssociationId(associationId).build();
final ElasticIpInputs elasticIpInputs = new ElasticIpInputs.Builder().withPublicIp(publicIp).build();
return new QueryApiExecutor().execute(commonInputs, customInputs, elasticIpInputs);
} catch (Exception exception) {
return ExceptionProcessor.getExceptionResult(exception);
}
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class ReleaseAddressAction method execute.
/**
* Releases the specified Elastic IP address.
* Note: After releasing an Elastic IP address, it is released to the IP address pool and might be unavailable to you.
* Be sure to update your DNS records and any servers or devices that communicate with the address. If you attempt
* to release an Elastic IP address that you already released, you'll get an AuthFailure error if the address
* is already allocated to another AWS account.
* [EC2-Classic, default VPC] Releasing an Elastic IP address automatically disassociates it from any instance
* that it's associated with. To disassociate an Elastic IP address without releasing it, use DisassociateAddress.
* [Non-default VPC] You must use DisassociateAddress to disassociate the Elastic IP address before you try to
* release it. Otherwise, Amazon EC2 returns an error (InvalidIPAddress.InUse).
*
* @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¶meterName2=parameterValue2"
* @param version Optional - Version of the web service to made the call against it.
* Example: "2016-11-15"
* Default: "2016-11-15"
* @param allocationId Optional - [EC2-VPC] Allocation ID. This is required for EC2-VPC.
* Example: "eipalloc-abcdef12"
* Default: ""
* @param publicIp Optional - Elastic IP address. This is required for EC2-Classic.
* 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 = "Release Address", 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 = ALLOCATION_ID) String allocationId, @Param(value = PUBLIC_IP) String publicIp) {
try {
version = getDefaultStringInput(version, ELASTIC_IP_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(RELEASE_ADDRESS).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
final CustomInputs customInputs = new CustomInputs.Builder().withAllocationId(allocationId).build();
final ElasticIpInputs elasticIpInputs = new ElasticIpInputs.Builder().withPublicIp(publicIp).build();
return new QueryApiExecutor().execute(commonInputs, customInputs, elasticIpInputs);
} catch (Exception exception) {
return ExceptionProcessor.getExceptionResult(exception);
}
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class CreateDBInstance method execute.
@Action(name = CREATE_DB_INSTANCE, description = CREATE_DB_INSTANCE_DESC, outputs = { @Output(value = Outputs.RETURN_CODE, description = RETURN_CODE_DESC), @Output(value = Outputs.RETURN_RESULT, description = RETURN_RESULT_DESC), @Output(value = Outputs.EXCEPTION, description = EXCEPTION_DESC) }, responses = { @Response(text = Outputs.SUCCESS, field = Outputs.RETURN_CODE, value = Outputs.SUCCESS_RETURN_CODE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.RESOLVED, description = SUCCESS_DESC), @Response(text = Outputs.FAILURE, field = Outputs.RETURN_CODE, value = Outputs.FAILURE_RETURN_CODE, matchType = MatchType.COMPARE_EQUAL, responseType = ResponseType.ERROR, description = FAILURE_DESC) })
public Map<String, String> execute(@Param(value = ACCESS_KEY_ID, required = true, description = ACCESS_KEY_ID_DESC) final String accessKeyID, @Param(value = ACCESS_KEY, required = true, encrypted = true, description = ACCESS_KEY_DESC) final String accessKey, @Param(value = REGION, required = true, description = REGION_DESC) String region, @Param(value = DB_INSTANCE_IDENTIFIER, required = true, description = DB_INSTANCE_IDENTIFIER_DESC) String dbInstanceIdentifier, @Param(value = DB_ENGINE_NAME, required = true, description = DB_ENGINE_NAME_DESC) final String dbEngineName, @Param(value = DB_ENGINE_VERSION, required = true, description = DB_ENGINE_VERSION_DESC) final String dbEngineVersion, @Param(value = DB_INSTANCE_SIZE, required = true, description = DB_INSTANCE_SIZE_DESC) String dbInstanceSize, @Param(value = DB_USERNAME, required = true, description = DB_USERNAME_DESC) String dbUsername, @Param(value = DB_PASSWORD, required = true, encrypted = true, description = DB_PASSWORD_DESC) final String dbPassword, @Param(value = DB_STORAGE_SIZE, required = true, encrypted = true, description = DB_STORAGE_SIZE_DESC) final String dbStorageSize, @Param(value = LICENSE_MODEL, description = LICENSE_MODEL_DESC) final String licenseModel, @Param(value = AVAILABILITY_ZONE, description = AVAILABILITY_ZONE_DESC) final String availabilityZone, @Param(value = PROXY_HOST, description = PROXY_HOST_DESC) final String proxyHost, @Param(value = PROXY_PORT, description = PROXY_PORT_DESC) final String proxyPort, @Param(value = PROXY_USERNAME, description = PROXY_USERNAME_DESC) final String proxyUsername, @Param(value = PROXY_PASSWORD, encrypted = true, description = PROXY_PASSWORD_DESC) final String proxyPassword, @Param(value = CONNECT_TIMEOUT, description = CONNECT_TIMEOUT_DESC) String connectTimeout, @Param(value = EXECUTION_TIMEOUT, description = EXECUTION_TIMEOUT_DESC) String execTimeout, @Param(value = ASYNC, description = ASYNC_DESC) String async) {
final String proxyPortVal = defaultIfEmpty(proxyPort, DefaultValues.PROXY_PORT);
final String connectTimeoutVal = defaultIfEmpty(connectTimeout, DefaultValues.CONNECT_TIMEOUT);
final String execTimeoutVal = defaultIfEmpty(execTimeout, DefaultValues.EXEC_TIMEOUT);
final String asyncVal = defaultIfEmpty(async, DefaultValues.ASYNC);
Validator validator = new Validator().validatePort(proxyPortVal, PROXY_PORT).validateInt(connectTimeoutVal, CONNECT_TIMEOUT).validateInt(execTimeoutVal, EXECUTION_TIMEOUT).validateInt(dbStorageSize, dbStorageSize).validateBoolean(asyncVal, ASYNC);
if (validator.hasErrors()) {
return getFailureResultsMap(validator.getErrors());
}
final Integer proxyPortImp = Integer.valueOf(proxyPortVal);
final Integer connectTimeoutImp = Integer.valueOf(connectTimeoutVal);
final Integer execTimeoutImp = Integer.valueOf(execTimeoutVal);
final boolean asyncImp = Boolean.parseBoolean(asyncVal);
final int dbStorageSizeImp = Integer.parseInt(dbStorageSize);
try {
final AmazonRDS amazonRDS = RDSClientBuilder.getRDSClientBuilder(accessKeyID, accessKey, proxyHost, proxyPortImp, proxyUsername, proxyPassword, connectTimeoutImp, execTimeoutImp, region, asyncImp);
final DBInstance result = AmazonRDSService.createRDSInstance(dbEngineName, dbEngineVersion, dbUsername, dbPassword, dbInstanceIdentifier, dbInstanceSize, dbStorageSizeImp, licenseModel, availabilityZone, amazonRDS);
return getSuccessResultMapDBInstance(result);
} catch (Exception e) {
return getFailureResultsMap(e);
}
}
use of com.hp.oo.sdk.content.annotations.Action in project cs-actions by CloudSlang.
the class DeleteSnapshotAction method execute.
/**
* Deletes the specified snapshot.
* Note: When you make periodic snapshots of a volume, the snapshots are incremental, and only the blocks on the device
* that have changed since your last snapshot are saved in the new snapshot. When you delete a snapshot, only the data
* not needed for any other snapshot is removed. So regardless of which prior snapshots have been deleted, all active
* snapshots will have access to all the information needed to restore the volume. You cannot delete a snapshot of the
* root device of an EBS volume used by a registered AMI. You must first de-register the AMI before you can delete the
* snapshot. For more information, see Deleting an Amazon EBS Snapshot 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 snapshotId ID of the EBS snapshot 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 Snapshot", 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 = SNAPSHOT_ID, required = true) String snapshotId) {
try {
version = getDefaultStringInput(version, SNAPSHOTS_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_SNAPSHOT).withApiService(EC2_API).withRequestUri(EMPTY).withRequestPayload(EMPTY).withHttpClientMethod(HTTP_CLIENT_METHOD_GET).build();
final VolumeInputs volumeInputs = new VolumeInputs.Builder().withSnapshotId(snapshotId).build();
return new QueryApiExecutor().execute(commonInputs, volumeInputs);
} catch (Exception e) {
return ExceptionProcessor.getExceptionResult(e);
}
}
Aggregations