Search in sources :

Example 26 with AmazonRDS

use of com.amazonaws.services.rds.AmazonRDS in project cs-actions by CloudSlang.

the class DescribeDBInstance method execute.

@Action(name = DESCRIBE_DB_INSTANCE, description = DESCRIBE_DB_INSTANCE_DESC, outputs = { @Output(value = Outputs.RETURN_CODE, description = RETURN_CODE_DESC), @Output(value = Outputs.RETURN_RESULT, description = RETURN_RESULT_DESC), @Output(value = DB_INSTANCE_STATUS, description = DB_INSTANCE_STATUS_DESC), @Output(value = ENDPOINT_ADDRESS, description = ENDPOINT_ADDRESS_DESC), @Output(value = DB_INSTANCE_ARN, description = DB_INSTANCE_ARN_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 = 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).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);
    try {
        final AmazonRDS amazonRDS = RDSClientBuilder.getRDSClientBuilder(accessKeyID, accessKey, proxyHost, proxyPortImp, proxyUsername, proxyPassword, connectTimeoutImp, execTimeoutImp, region, asyncImp);
        final DescribeDBInstancesResult result = AmazonRDSService.getDBDetails(dbInstanceIdentifier, amazonRDS);
        return getSuccessResultMapDescribedDBInstance(result);
    } catch (Exception e) {
        return getFailureResultsMap(e);
    }
}
Also used : AmazonRDS(com.amazonaws.services.rds.AmazonRDS) Validator(io.cloudslang.content.amazon.entities.validators.Validator) DescribeDBInstancesResult(com.amazonaws.services.rds.model.DescribeDBInstancesResult) Action(com.hp.oo.sdk.content.annotations.Action) ProvisionProductAction(io.cloudslang.content.amazon.entities.constants.Descriptions.ProvisionProductAction) DescribeDBInstanceAction(io.cloudslang.content.amazon.entities.constants.Descriptions.DescribeDBInstanceAction)

Example 27 with AmazonRDS

use of com.amazonaws.services.rds.AmazonRDS in project cs-actions by CloudSlang.

the class DeleteDBInstance method execute.

@Action(name = DELETE_DB_INSTANCE, description = DELETE_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 = SKIP_FINAL_SNAPSHOT, description = SKIP_FINAL_SNAPSHOT_DESC) String skipFinalSnapshot, @Param(value = FINAL_DB_SNAPSHOT_IDENTIFIER, description = FINAL_DB_SNAPSHOT_IDENTIFIER_DESC) String finalDBSnapshotIdentifier, @Param(value = DELETE_AUTOMATED_BACKUPS, description = DELETE_AUTOMATED_BACKUPS_DESC) String deleteAutomatedBackups, @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);
    final String skipFinalSnapshotVal = defaultIfEmpty(skipFinalSnapshot, SKIP_FINAL_SNAPSHOT_CONST);
    final String deleteAutomatedBackupsVal = defaultIfEmpty(deleteAutomatedBackups, DELETE_AUTOMATED_BACKUPS_CONST);
    Validator validator = new Validator().validatePort(proxyPortVal, PROXY_PORT).validateInt(connectTimeoutVal, CONNECT_TIMEOUT).validateInt(execTimeoutVal, EXECUTION_TIMEOUT).validateBoolean(asyncVal, ASYNC).validateBoolean(skipFinalSnapshotVal, SKIP_FINAL_SNAPSHOT).validateBoolean(deleteAutomatedBackupsVal, DELETE_AUTOMATED_BACKUPS);
    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 boolean skipFinalSnapshotImp = Boolean.parseBoolean(skipFinalSnapshotVal);
    final boolean deleteAutomatedBackupsImp = Boolean.parseBoolean(deleteAutomatedBackupsVal);
    try {
        final AmazonRDS amazonRDS = RDSClientBuilder.getRDSClientBuilder(accessKeyID, accessKey, proxyHost, proxyPortImp, proxyUsername, proxyPassword, connectTimeoutImp, execTimeoutImp, region, asyncImp);
        final DBInstance result = AmazonRDSService.deleteRDSInstance(dbInstanceIdentifier, skipFinalSnapshotImp, finalDBSnapshotIdentifier, deleteAutomatedBackupsImp, amazonRDS);
        return getSuccessResultMapDBInstance(result);
    } catch (Exception e) {
        return getFailureResultsMap(e);
    }
}
Also used : DBInstance(com.amazonaws.services.rds.model.DBInstance) OutputsUtil.getSuccessResultMapDBInstance(io.cloudslang.content.amazon.utils.OutputsUtil.getSuccessResultMapDBInstance) AmazonRDS(com.amazonaws.services.rds.AmazonRDS) Validator(io.cloudslang.content.amazon.entities.validators.Validator) DeleteDBInstanceAction(io.cloudslang.content.amazon.entities.constants.Descriptions.DeleteDBInstanceAction) Action(com.hp.oo.sdk.content.annotations.Action) ProvisionProductAction(io.cloudslang.content.amazon.entities.constants.Descriptions.ProvisionProductAction)

Aggregations

AmazonRDS (com.amazonaws.services.rds.AmazonRDS)27 Test (org.junit.jupiter.api.Test)24 DBInstance (com.amazonaws.services.rds.model.DBInstance)15 DescribeDBInstancesRequest (com.amazonaws.services.rds.model.DescribeDBInstancesRequest)15 DescribeDBInstancesResult (com.amazonaws.services.rds.model.DescribeDBInstancesResult)14 Endpoint (com.amazonaws.services.rds.model.Endpoint)10 DataSource (javax.sql.DataSource)9 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)7 XmlBeanDefinitionReader (org.springframework.beans.factory.xml.XmlBeanDefinitionReader)7 ClassPathResource (org.springframework.core.io.ClassPathResource)7 DataSourceFactory (io.awspring.cloud.jdbc.datasource.DataSourceFactory)6 DataSourceInformation (io.awspring.cloud.jdbc.datasource.DataSourceInformation)6 AmazonIdentityManagement (com.amazonaws.services.identitymanagement.AmazonIdentityManagement)5 GetUserResult (com.amazonaws.services.identitymanagement.model.GetUserResult)5 User (com.amazonaws.services.identitymanagement.model.User)5 ListTagsForResourceRequest (com.amazonaws.services.rds.model.ListTagsForResourceRequest)5 ListTagsForResourceResult (com.amazonaws.services.rds.model.ListTagsForResourceResult)5 Date (java.util.Date)5 RetryContext (org.springframework.retry.RetryContext)5 RetryContextSupport (org.springframework.retry.context.RetryContextSupport)5