mirror of https://github.com/apache/jclouds.git
Issue 309: initial support for amazon rds
This commit is contained in:
parent
3d221d48eb
commit
c9f49bd512
|
@ -0,0 +1,114 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.jclouds</groupId>
|
||||
<artifactId>jclouds-project</artifactId>
|
||||
<version>1.5.0-SNAPSHOT</version>
|
||||
<relativePath>../../project/pom.xml</relativePath>
|
||||
</parent>
|
||||
<groupId>org.jclouds.labs</groupId>
|
||||
<artifactId>aws-rds</artifactId>
|
||||
<name>jclouds Amazon Relational Database Service provider</name>
|
||||
<description>Relational Database Service implementation targeted to Amazon Web Services</description>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<properties>
|
||||
<test.aws-rds.endpoint>https://rds.us-east-1.amazonaws.com</test.aws-rds.endpoint>
|
||||
<test.aws-rds.api-version>2012-04-23</test.aws-rds.api-version>
|
||||
<test.aws-rds.build-version></test.aws-rds.build-version>
|
||||
<test.aws-rds.identity>${test.aws.identity}</test.aws-rds.identity>
|
||||
<test.aws-rds.credential>${test.aws.credential}</test.aws-rds.credential>
|
||||
|
||||
<jclouds.osgi.export>org.jclouds.aws.rds*;version="${project.version}"</jclouds.osgi.export>
|
||||
<jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jclouds.labs</groupId>
|
||||
<artifactId>rds</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds.labs</groupId>
|
||||
<artifactId>rds</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds</groupId>
|
||||
<artifactId>jclouds-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds.driver</groupId>
|
||||
<artifactId>jclouds-slf4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>live</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<test.aws-rds.endpoint>${test.aws-rds.endpoint}</test.aws-rds.endpoint>
|
||||
<test.aws-rds.api-version>${test.aws-rds.api-version}</test.aws-rds.api-version>
|
||||
<test.aws-rds.build-version>${test.aws-rds.build-version}</test.aws-rds.build-version>
|
||||
<test.aws-rds.identity>${test.aws-rds.identity}</test.aws-rds.identity>
|
||||
<test.aws-rds.credential>${test.aws-rds.credential}</test.aws-rds.credential>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,109 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.aws.rds;
|
||||
|
||||
import static org.jclouds.aws.domain.Region.AP_NORTHEAST_1;
|
||||
import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1;
|
||||
import static org.jclouds.aws.domain.Region.EU_WEST_1;
|
||||
import static org.jclouds.aws.domain.Region.SA_EAST_1;
|
||||
import static org.jclouds.aws.domain.Region.US_EAST_1;
|
||||
import static org.jclouds.aws.domain.Region.US_WEST_1;
|
||||
import static org.jclouds.aws.domain.Region.US_WEST_2;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_ZONECLIENT_ENDPOINT;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.rds.RDSApiMetadata;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
import org.jclouds.providers.internal.BaseProviderMetadata;
|
||||
|
||||
/**
|
||||
* Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's Elastic Load Balancing
|
||||
* provider.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class AWSRDSProviderMetadata extends BaseProviderMetadata {
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = 7750012233546655021L;
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return Builder.class.cast(builder().fromProviderMetadata(this));
|
||||
}
|
||||
|
||||
public AWSRDSProviderMetadata() {
|
||||
super(builder());
|
||||
}
|
||||
|
||||
public AWSRDSProviderMetadata(Builder builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
public static Properties defaultProperties() {
|
||||
Properties properties = new Properties();
|
||||
properties.putAll(Region.regionProperties());
|
||||
properties.setProperty(PROPERTY_REGION + "." + US_EAST_1 + ".endpoint",
|
||||
"https://rds.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + US_WEST_1 + ".endpoint",
|
||||
"https://rds.us-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + US_WEST_2 + ".endpoint",
|
||||
"https://rds.us-west-2.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + SA_EAST_1 + ".endpoint",
|
||||
"https://rds.sa-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + EU_WEST_1 + ".endpoint",
|
||||
"https://rds.eu-west-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + AP_SOUTHEAST_1 + ".endpoint",
|
||||
"https://rds.ap-southeast-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGION + "." + AP_NORTHEAST_1 + ".endpoint",
|
||||
"https://rds.ap-northeast-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_ZONECLIENT_ENDPOINT, "https://ec2.us-east-1.amazonaws.com");
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static class Builder extends BaseProviderMetadata.Builder {
|
||||
|
||||
protected Builder(){
|
||||
id("aws-rds")
|
||||
.name("Amazon Relational Database Service")
|
||||
.endpoint("https://rds.us-east-1.amazonaws.com")
|
||||
.homepage(URI.create("http://aws.amazon.com/rds"))
|
||||
.console(URI.create("https://console.aws.amazon.com/ec2/home"))
|
||||
.linkedServices("aws-ec2", "aws-rds", "aws-elb", "aws-iam","aws-cloudwatch", "aws-s3", "aws-simpledb")
|
||||
.iso3166Codes("US-VA", "US-CA", "BR-SP", "US-OR", "IE", "SG", "JP-13")
|
||||
.apiMetadata(new RDSApiMetadata())
|
||||
.defaultProperties(AWSRDSProviderMetadata.defaultProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder fromProviderMetadata(
|
||||
ProviderMetadata in) {
|
||||
super.fromProviderMetadata(in);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
org.jclouds.aws.rds.AWSRDSProviderMetadata
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.aws.rds;
|
||||
|
||||
import org.jclouds.rds.RDSApiMetadata;
|
||||
import org.jclouds.providers.internal.BaseProviderMetadataTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* The AWSRDSProviderTest tests the org.jclouds.providers.AWSRDSProvider class.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "AWSRDSProviderTest")
|
||||
public class AWSRDSProviderTest extends BaseProviderMetadataTest {
|
||||
|
||||
public AWSRDSProviderTest() {
|
||||
super(new AWSRDSProviderMetadata(), new RDSApiMetadata());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.aws.rds.features;
|
||||
|
||||
import org.jclouds.rds.features.InstanceClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", testName = "AWSInstanceClientLiveTest")
|
||||
public class AWSInstanceClientLiveTest extends InstanceClientLiveTest {
|
||||
|
||||
public AWSInstanceClientLiveTest() {
|
||||
provider = "aws-rds";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.aws.rds.features;
|
||||
|
||||
import org.jclouds.rds.features.SecurityGroupClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", testName = "AWSSecurityGroupClientLiveTest")
|
||||
public class AWSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest {
|
||||
|
||||
public AWSSecurityGroupClientLiveTest() {
|
||||
provider = "aws-rds";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.aws.rds.features;
|
||||
|
||||
import org.jclouds.rds.features.SubnetGroupClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", testName = "AWSSubnetGroupClientLiveTest")
|
||||
public class AWSSubnetGroupClientLiveTest extends SubnetGroupClientLiveTest {
|
||||
|
||||
public AWSSubnetGroupClientLiveTest() {
|
||||
provider = "aws-rds";
|
||||
}
|
||||
|
||||
}
|
|
@ -53,5 +53,7 @@
|
|||
<module>iam</module>
|
||||
<module>aws-iam</module>
|
||||
<module>nodepool</module>
|
||||
<module>rds</module>
|
||||
<module>aws-rds</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. jclouds licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.jclouds</groupId>
|
||||
<artifactId>jclouds-project</artifactId>
|
||||
<version>1.5.0-SNAPSHOT</version>
|
||||
<relativePath>../../project/pom.xml</relativePath>
|
||||
</parent>
|
||||
<groupId>org.jclouds.labs</groupId>
|
||||
<artifactId>rds</artifactId>
|
||||
<name>jcloud rds api</name>
|
||||
<description>jclouds components to access an implementation of Relational Database Service</description>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<properties>
|
||||
<test.rds.endpoint>https://rds.us-east-1.amazonaws.com</test.rds.endpoint>
|
||||
<test.rds.api-version>2012-04-23</test.rds.api-version>
|
||||
<test.rds.build-version></test.rds.build-version>
|
||||
<test.rds.identity>${test.aws.identity}</test.rds.identity>
|
||||
<test.rds.credential>${test.aws.credential}</test.rds.credential>
|
||||
|
||||
<jclouds.osgi.export>org.jclouds.rds*;version="${project.version}"</jclouds.osgi.export>
|
||||
<jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jclouds.common</groupId>
|
||||
<artifactId>aws-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds</groupId>
|
||||
<artifactId>jclouds-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jclouds.driver</groupId>
|
||||
<artifactId>jclouds-slf4j</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>live</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>integration</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<test.rds.endpoint>${test.rds.endpoint}</test.rds.endpoint>
|
||||
<test.rds.api-version>${test.rds.api-version}</test.rds.api-version>
|
||||
<test.rds.build-version>${test.rds.build-version}</test.rds.build-version>
|
||||
<test.rds.identity>${test.rds.identity}</test.rds.identity>
|
||||
<test.rds.credential>${test.rds.credential}</test.rds.credential>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
package org.jclouds.rds;
|
||||
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.collect.PaginatedIterables;
|
||||
import org.jclouds.rds.domain.Instance;
|
||||
import org.jclouds.rds.domain.SecurityGroup;
|
||||
import org.jclouds.rds.domain.SubnetGroup;
|
||||
import org.jclouds.rds.features.InstanceClient;
|
||||
import org.jclouds.rds.features.SecurityGroupClient;
|
||||
import org.jclouds.rds.features.SubnetGroupClient;
|
||||
import org.jclouds.rds.options.ListInstancesOptions;
|
||||
import org.jclouds.rds.options.ListSecurityGroupsOptions;
|
||||
import org.jclouds.rds.options.ListSubnetGroupsOptions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
/**
|
||||
* Utilities for using RDS.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class RDS {
|
||||
|
||||
/**
|
||||
* List instances based on the criteria in the {@link ListInstancesOptions} passed in.
|
||||
*
|
||||
* @param instanceClient
|
||||
* the {@link InstanceClient} to use for the request
|
||||
* @param options
|
||||
* the {@link ListInstancesOptions} describing the ListInstances request
|
||||
*
|
||||
* @return iterable of instances fitting the criteria
|
||||
*/
|
||||
public static Iterable<Instance> listInstances(final InstanceClient instanceClient,
|
||||
final ListInstancesOptions options) {
|
||||
return PaginatedIterables.lazyContinue(instanceClient.list(options),
|
||||
new Function<Object, PaginatedIterable<Instance>>() {
|
||||
|
||||
@Override
|
||||
public PaginatedIterable<Instance> apply(Object input) {
|
||||
return instanceClient.list(options.clone().afterMarker(input));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "listInstances(" + options + ")";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Iterable<Instance> listInstances(InstanceClient instanceClient) {
|
||||
return listInstances(instanceClient, new ListInstancesOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* List securityGroups based on the criteria in the {@link ListSecurityGroupsOptions} passed in.
|
||||
*
|
||||
* @param securityGroupClient
|
||||
* the {@link SecurityGroupClient} to use for the request
|
||||
* @param options
|
||||
* the {@link ListSecurityGroupsOptions} describing the ListSecurityGroups request
|
||||
*
|
||||
* @return iterable of securityGroups fitting the criteria
|
||||
*/
|
||||
public static Iterable<SecurityGroup> listSecurityGroups(final SecurityGroupClient securityGroupClient,
|
||||
final ListSecurityGroupsOptions options) {
|
||||
return PaginatedIterables.lazyContinue(securityGroupClient.list(options),
|
||||
new Function<Object, PaginatedIterable<SecurityGroup>>() {
|
||||
|
||||
@Override
|
||||
public PaginatedIterable<SecurityGroup> apply(Object input) {
|
||||
return securityGroupClient.list(options.clone().afterMarker(input));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "listSecurityGroups(" + options + ")";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Iterable<SecurityGroup> listSecurityGroups(SecurityGroupClient securityGroupClient) {
|
||||
return listSecurityGroups(securityGroupClient, new ListSecurityGroupsOptions());
|
||||
}
|
||||
|
||||
/**
|
||||
* List subnetGroups based on the criteria in the {@link ListSubnetGroupsOptions} passed in.
|
||||
*
|
||||
* @param subnetGroupClient
|
||||
* the {@link SubnetGroupClient} to use for the request
|
||||
* @param options
|
||||
* the {@link ListSubnetGroupsOptions} describing the ListSubnetGroups request
|
||||
*
|
||||
* @return iterable of subnetGroups fitting the criteria
|
||||
*/
|
||||
public static Iterable<SubnetGroup> listSubnetGroups(final SubnetGroupClient subnetGroupClient,
|
||||
final ListSubnetGroupsOptions options) {
|
||||
return PaginatedIterables.lazyContinue(subnetGroupClient.list(options),
|
||||
new Function<Object, PaginatedIterable<SubnetGroup>>() {
|
||||
|
||||
@Override
|
||||
public PaginatedIterable<SubnetGroup> apply(Object input) {
|
||||
return subnetGroupClient.list(options.clone().afterMarker(input));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "listSubnetGroups(" + options + ")";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Iterable<SubnetGroup> listSubnetGroups(SubnetGroupClient subnetGroupClient) {
|
||||
return listSubnetGroups(subnetGroupClient, new ListSubnetGroupsOptions());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds;
|
||||
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.rds.config.RDSRestClientModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadata;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ApiMetadata} for Amazon's Relational Database Service api.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class RDSApiMetadata extends BaseRestApiMetadata {
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = -7077953935392202824L;
|
||||
|
||||
public static final TypeToken<RestContext<RDSClient, RDSAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<RDSClient, RDSAsyncClient>>() {
|
||||
private static final long serialVersionUID = -5070937833892503232L;
|
||||
};
|
||||
|
||||
@Override
|
||||
public Builder toBuilder() {
|
||||
return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this);
|
||||
}
|
||||
|
||||
public RDSApiMetadata() {
|
||||
this(new Builder(RDSClient.class, RDSAsyncClient.class));
|
||||
}
|
||||
|
||||
protected RDSApiMetadata(Builder builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
public static Properties defaultProperties() {
|
||||
Properties properties = BaseRestApiMetadata.defaultProperties();
|
||||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
||||
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static class Builder extends BaseRestApiMetadata.Builder {
|
||||
|
||||
protected Builder(Class<?> client, Class<?> asyncClient) {
|
||||
super(client, asyncClient);
|
||||
id("rds")
|
||||
.name("Amazon Relational Database Service Api")
|
||||
.identityName("Access Key ID")
|
||||
.credentialName("Secret Access Key")
|
||||
.version("2012-04-23")
|
||||
.defaultProperties(RDSApiMetadata.defaultProperties())
|
||||
.defaultEndpoint("https://rds.us-east-1.amazonaws.com")
|
||||
.documentation(URI.create("http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference"))
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(RDSRestClientModule.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RDSApiMetadata build() {
|
||||
return new RDSApiMetadata(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder fromApiMetadata(ApiMetadata in) {
|
||||
super.fromApiMetadata(in);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.location.Region;
|
||||
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
||||
import org.jclouds.rds.features.InstanceAsyncClient;
|
||||
import org.jclouds.rds.features.SecurityGroupAsyncClient;
|
||||
import org.jclouds.rds.features.SubnetGroupAsyncClient;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.VirtualHost;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
* Provides access to EC2 Elastic Load Balancer via REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/">RDS
|
||||
* documentation</a>
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Beta
|
||||
@RequestFilters(FormSigner.class)
|
||||
@VirtualHost
|
||||
public interface RDSAsyncClient {
|
||||
/**
|
||||
*
|
||||
* @return the Region codes configured
|
||||
*/
|
||||
@Provides
|
||||
@Region
|
||||
Set<String> getConfiguredRegions();
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Instance features.
|
||||
*/
|
||||
@Delegate
|
||||
InstanceAsyncClient getInstanceClient();
|
||||
|
||||
@Delegate
|
||||
InstanceAsyncClient getInstanceClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to SecurityGroup features.
|
||||
*/
|
||||
@Delegate
|
||||
SecurityGroupAsyncClient getSecurityGroupClient();
|
||||
|
||||
@Delegate
|
||||
SecurityGroupAsyncClient getSecurityGroupClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to SubnetGroup features.
|
||||
*/
|
||||
@Delegate
|
||||
SubnetGroupAsyncClient getSubnetGroupClient();
|
||||
|
||||
@Delegate
|
||||
SubnetGroupAsyncClient getSubnetGroupClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.location.Region;
|
||||
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
||||
import org.jclouds.rds.features.InstanceClient;
|
||||
import org.jclouds.rds.features.SecurityGroupClient;
|
||||
import org.jclouds.rds.features.SubnetGroupClient;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
* Provides access to EC2 Elastic Load Balancer via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see RDSAsyncClient
|
||||
*/
|
||||
@Beta
|
||||
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
||||
public interface RDSClient {
|
||||
/**
|
||||
*
|
||||
* @return the Region codes configured
|
||||
*/
|
||||
@Provides
|
||||
@Region
|
||||
Set<String> getConfiguredRegions();
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Instance features.
|
||||
*/
|
||||
@Delegate
|
||||
InstanceClient getInstanceClient();
|
||||
|
||||
@Delegate
|
||||
InstanceClient getInstanceClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides synchronous access to SecurityGroup features.
|
||||
*/
|
||||
@Delegate
|
||||
SecurityGroupClient getSecurityGroupClient();
|
||||
|
||||
@Delegate
|
||||
SecurityGroupClient getSecurityGroupClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides synchronous access to SubnetGroup features.
|
||||
*/
|
||||
@Delegate
|
||||
SubnetGroupClient getSubnetGroupClient();
|
||||
|
||||
@Delegate
|
||||
SubnetGroupClient getSubnetGroupClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.aws.config.FormSigningRestClientModule;
|
||||
import org.jclouds.rds.RDSAsyncClient;
|
||||
import org.jclouds.rds.RDSClient;
|
||||
import org.jclouds.rds.features.InstanceAsyncClient;
|
||||
import org.jclouds.rds.features.InstanceClient;
|
||||
import org.jclouds.rds.features.SecurityGroupAsyncClient;
|
||||
import org.jclouds.rds.features.SecurityGroupClient;
|
||||
import org.jclouds.rds.features.SubnetGroupAsyncClient;
|
||||
import org.jclouds.rds.features.SubnetGroupClient;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* Configures the RDS connection.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@ConfiguresRestClient
|
||||
public class RDSRestClientModule extends FormSigningRestClientModule<RDSClient, RDSAsyncClient> {
|
||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
||||
.put(InstanceClient.class, InstanceAsyncClient.class)
|
||||
.put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)
|
||||
.put(SubnetGroupClient.class, SubnetGroupAsyncClient.class)
|
||||
.build();
|
||||
|
||||
public RDSRestClientModule() {
|
||||
super(TypeToken.of(RDSClient.class), TypeToken.of(RDSAsyncClient.class), DELEGATE_MAP);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_EC2SecurityGroup.html"
|
||||
* >doc</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class EC2SecurityGroup {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromEC2SecurityGroup(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
protected Optional<String> id = Optional.absent();
|
||||
protected String name;
|
||||
protected String ownerId;
|
||||
protected String status;
|
||||
|
||||
/**
|
||||
* @see EC2SecurityGroup#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = Optional.fromNullable(id);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EC2SecurityGroup#getName()
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EC2SecurityGroup#getOwnerId()
|
||||
*/
|
||||
public Builder ownerId(String ownerId) {
|
||||
this.ownerId = ownerId;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EC2SecurityGroup#getStatus()
|
||||
*/
|
||||
public Builder status(String status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public EC2SecurityGroup build() {
|
||||
return new EC2SecurityGroup(id, name, ownerId, status);
|
||||
}
|
||||
|
||||
public Builder fromEC2SecurityGroup(EC2SecurityGroup in) {
|
||||
return this.id(in.getId().orNull()).name(in.getName()).ownerId(in.getOwnerId()).status(in.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
protected final Optional<String> id;
|
||||
protected final String name;
|
||||
protected final String ownerId;
|
||||
protected final String status;
|
||||
|
||||
protected EC2SecurityGroup(Optional<String> id, String name, String ownerId, String status) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.ownerId = checkNotNull(ownerId, "ownerId");
|
||||
this.status = checkNotNull(status, "status");
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the id of the EC2 Security Group.
|
||||
*/
|
||||
public Optional<String> getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the name of the EC2 Security Group.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the AWS ID of the owner of the EC2 security group specified as {@link #getName()}
|
||||
*/
|
||||
public String getOwnerId() {
|
||||
return ownerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the status of the EC2 security group.
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, name, ownerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
EC2SecurityGroup other = EC2SecurityGroup.class.cast(obj);
|
||||
return Objects.equal(this.id, other.id) && Objects.equal(this.name, other.name)
|
||||
&& Objects.equal(this.ownerId, other.ownerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("id", id.orNull()).add("name", name)
|
||||
.add("ownerId", ownerId).add("status", status).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_IPRange.html"
|
||||
* >doc</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class IPRange {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromIPRange(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
protected String cidrIp;
|
||||
protected String status;
|
||||
|
||||
/**
|
||||
* @see IPRange#getAvailabilityZone()
|
||||
*/
|
||||
public Builder cidrIp(String cidrIp) {
|
||||
this.cidrIp = cidrIp;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IPRange#getStatus()
|
||||
*/
|
||||
public Builder status(String status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IPRange build() {
|
||||
return new IPRange(cidrIp, status);
|
||||
}
|
||||
|
||||
public Builder fromIPRange(IPRange in) {
|
||||
return this.cidrIp(in.getCIDRIP()).status(in.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
protected final String cidrIp;
|
||||
protected final String status;
|
||||
|
||||
protected IPRange(String cidrIp, String status) {
|
||||
this.cidrIp = checkNotNull(cidrIp, "cidrIp");
|
||||
this.status = checkNotNull(status, "status");
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the IP range.
|
||||
*/
|
||||
public String getCIDRIP() {
|
||||
return cidrIp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the status of the IP range.
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(cidrIp, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
IPRange other = IPRange.class.cast(obj);
|
||||
return Objects.equal(this.cidrIp, other.cidrIp) && Objects.equal(this.status, other.status);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("cidrIp", cidrIp)
|
||||
.add("status", status).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,434 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.net.HostAndPort;
|
||||
|
||||
/**
|
||||
* A DB Instance is an isolated database environment running in the cloud. A DB Instance can contain
|
||||
* multiple user-created databases, and can be accessed using the same tools and applications as a
|
||||
* stand-alone database instance.
|
||||
*
|
||||
*
|
||||
* <h4>Note</h4>
|
||||
*
|
||||
* Amazon RDS supports access from any standard SQL client application. Amazon RDS does not allow
|
||||
* direct host access via Telnet, Secure Shell (SSH), or Windows Remote Desktop Connection.
|
||||
*
|
||||
*
|
||||
* DB Instances are simple to create and modify with the Amazon RDS command line tools, APIs, or the
|
||||
* AWS Management Console.
|
||||
*
|
||||
*
|
||||
* Amazon RDS creates a master user account for your DB Instance as part of the creation process.
|
||||
* This master user has permissions to create databases and to perform create, delete, select,
|
||||
* update and insert operations on tables the master user creates. You must set the master user
|
||||
* password when you create a DB Instance, but you can change it at any time using the Amazon RDS
|
||||
* command line tools, APIs, or the AWS Management Console. You can also change the master user
|
||||
* password and manage users using standard SQL commands.
|
||||
*
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/UserGuide/Concepts.DBInstance.html"
|
||||
* >doc</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class Instance {
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromInstance(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected Optional<String> name = Optional.absent();
|
||||
protected String instanceClass;
|
||||
protected HostAndPort endpoint;
|
||||
protected String status;
|
||||
protected String availabilityZone;
|
||||
protected boolean multiAZ;
|
||||
protected String engine;
|
||||
protected String engineVersion;
|
||||
protected String licenseModel;
|
||||
protected String masterUsername;
|
||||
protected int allocatedStorageGB;
|
||||
protected Date createdTime;
|
||||
protected Optional<SubnetGroup> subnetGroup = Optional.absent();
|
||||
protected ImmutableMap.Builder<String, String> securityGroupNameToStatus = ImmutableMap
|
||||
.<String, String> builder();
|
||||
|
||||
/**
|
||||
* @see Instance#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = id;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = Optional.fromNullable(name);
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getInstanceClass()
|
||||
*/
|
||||
public T instanceClass(String instanceClass) {
|
||||
this.instanceClass = instanceClass;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getEndpoint()
|
||||
*/
|
||||
public T endpoint(HostAndPort endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getStatus()
|
||||
*/
|
||||
public T status(String status) {
|
||||
this.status = status;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getAvailabilityZone()
|
||||
*/
|
||||
public T availabilityZone(String availabilityZone) {
|
||||
this.availabilityZone = availabilityZone;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#isMultiAZ()
|
||||
*/
|
||||
public T multiAZ(boolean multiAZ) {
|
||||
this.multiAZ = multiAZ;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getEngine()
|
||||
*/
|
||||
public T engine(String engine) {
|
||||
this.engine = engine;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getEngineVersion()
|
||||
*/
|
||||
public T engineVersion(String engineVersion) {
|
||||
this.engineVersion = engineVersion;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getLicenseModel()
|
||||
*/
|
||||
public T licenseModel(String licenseModel) {
|
||||
this.licenseModel = licenseModel;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getMasterUsername()
|
||||
*/
|
||||
public T masterUsername(String masterUsername) {
|
||||
this.masterUsername = masterUsername;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getAllocatedStorageGB()
|
||||
*/
|
||||
public T allocatedStorageGB(int allocatedStorageGB) {
|
||||
this.allocatedStorageGB = allocatedStorageGB;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getCreatedTime()
|
||||
*/
|
||||
public T createdTime(Date createdTime) {
|
||||
this.createdTime = createdTime;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getSubnetGroup()
|
||||
*/
|
||||
public T subnetGroup(SubnetGroup subnetGroup) {
|
||||
this.subnetGroup = Optional.fromNullable(subnetGroup);
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getSecurityGroupNameToStatus()
|
||||
*/
|
||||
public T securityGroupNameToStatus(Map<String, String> securityGroupNameToStatus) {
|
||||
this.securityGroupNameToStatus.putAll(checkNotNull(securityGroupNameToStatus, "securityGroupNameToStatus"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getSecurityGroupNameToStatus()
|
||||
*/
|
||||
public T securityGroupNameToStatus(String securityGroupName, String status) {
|
||||
this.securityGroupNameToStatus.put(checkNotNull(securityGroupName, "securityGroupName"),
|
||||
checkNotNull(status, "status"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Instance build() {
|
||||
return new Instance(id, name, instanceClass, endpoint, status, availabilityZone, multiAZ, engine,
|
||||
engineVersion, licenseModel, masterUsername, allocatedStorageGB, createdTime, subnetGroup,
|
||||
securityGroupNameToStatus.build());
|
||||
}
|
||||
|
||||
public T fromInstance(Instance in) {
|
||||
return this.id(in.getId()).name(in.getName().orNull()).instanceClass(in.getInstanceClass())
|
||||
.endpoint(in.getEndpoint()).status(in.getStatus()).availabilityZone(in.getAvailabilityZone())
|
||||
.multiAZ(in.isMultiAZ()).engine(in.getEngine()).engineVersion(in.getEngineVersion())
|
||||
.licenseModel(in.getLicenseModel()).masterUsername(in.getMasterUsername())
|
||||
.allocatedStorageGB(in.getAllocatedStorageGB()).createdTime(in.getCreatedTime())
|
||||
.subnetGroup(in.getSubnetGroup().orNull())
|
||||
.securityGroupNameToStatus(in.getSecurityGroupNameToStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected final String id;
|
||||
protected final Optional<String> name;
|
||||
protected final String instanceClass;
|
||||
protected final HostAndPort endpoint;
|
||||
protected final String status;
|
||||
protected final String availabilityZone;
|
||||
protected final boolean multiAZ;
|
||||
protected final String engine;
|
||||
protected final String engineVersion;
|
||||
protected final String licenseModel;
|
||||
protected final String masterUsername;
|
||||
protected int allocatedStorageGB;
|
||||
protected final Date createdTime;
|
||||
protected final Optional<SubnetGroup> subnetGroup;
|
||||
protected final Map<String, String> securityGroupNameToStatus;
|
||||
|
||||
protected Instance(String id, Optional<String> name, String instanceClass, HostAndPort endpoint, String status,
|
||||
String availabilityZone, boolean multiAZ, String engine, String engineVersion, String licenseModel,
|
||||
String masterUsername, int allocatedStorageGB, Date createdTime, Optional<SubnetGroup> subnetGroup,
|
||||
Map<String, String> securityGroupNameToStatus) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.name = checkNotNull(name, "name of %s", id);
|
||||
this.endpoint = checkNotNull(endpoint, "endpoint of %s", id);
|
||||
this.status = checkNotNull(status, "status of %s", id);
|
||||
this.instanceClass = checkNotNull(instanceClass, "instanceClass of %s", id);
|
||||
this.availabilityZone = checkNotNull(availabilityZone, "availabilityZone of %s", id);
|
||||
this.multiAZ = multiAZ;
|
||||
this.engine = checkNotNull(engine, "engine of %s", id);
|
||||
this.engineVersion = checkNotNull(engineVersion, "engineVersion of %s", id);
|
||||
this.licenseModel = checkNotNull(licenseModel, "licenseModel of %s", id);
|
||||
this.masterUsername = checkNotNull(masterUsername, "masterUsername of %s", id);
|
||||
this.allocatedStorageGB = allocatedStorageGB;
|
||||
this.createdTime = checkNotNull(createdTime, "createdTime of %s", id);
|
||||
this.subnetGroup = checkNotNull(subnetGroup, "subnetGroup of %s", id);
|
||||
this.securityGroupNameToStatus = ImmutableMap.copyOf(checkNotNull(securityGroupNameToStatus,
|
||||
"securityGroupNameToStatus of %s", id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains a user-supplied database identifier. This is the unique key that identifies a DB
|
||||
* Instance.
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The meaning of this parameter differs according to the database engine you use.
|
||||
*
|
||||
* <h4>MySQL</h4>
|
||||
*
|
||||
* Contains the name of the initial database of this instance that was provided at create time,
|
||||
* if one was specified when the DB Instance was created. This same name is returned for the life
|
||||
* of the DB Instance.
|
||||
*
|
||||
* <h4>Oracle</h4>
|
||||
*
|
||||
* Contains the Oracle System ID (SID) of the created DB Instance.
|
||||
*/
|
||||
public Optional<String> getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the current state of this database.
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the name of the compute and memory capacity class of the DB Instance.
|
||||
*/
|
||||
public String getInstanceClass() {
|
||||
return instanceClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the connection endpoint.
|
||||
*/
|
||||
public HostAndPort getEndpoint() {
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the name of the Availability Zone the DB Instance is located in.
|
||||
*/
|
||||
public String getAvailabilityZone() {
|
||||
return availabilityZone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the name of the Availability Zone the DB Instance is located in.
|
||||
*/
|
||||
public boolean isMultiAZ() {
|
||||
return multiAZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the name of the database engine to be used for this DB Instance.
|
||||
*/
|
||||
public String getEngine() {
|
||||
return engine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the database engine version.
|
||||
*/
|
||||
public String getEngineVersion() {
|
||||
return engineVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* License model information for this DB Instance.
|
||||
*/
|
||||
public String getLicenseModel() {
|
||||
return licenseModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the master username for the DB Instance.
|
||||
*/
|
||||
public String getMasterUsername() {
|
||||
return masterUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the allocated storage size specified in gigabytes.
|
||||
*/
|
||||
public int getAllocatedStorageGB() {
|
||||
return allocatedStorageGB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the date and time the DB Instance was created.
|
||||
*/
|
||||
public Date getCreatedTime() {
|
||||
return createdTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the information of the subnet group associated with the DB instance, including the
|
||||
* name, description and subnets in the subnet group.
|
||||
*/
|
||||
public Optional<SubnetGroup> getSubnetGroup() {
|
||||
return subnetGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* SecurityGroupName -> Status
|
||||
*/
|
||||
public Map<String, String> getSecurityGroupNameToStatus() {
|
||||
return securityGroupNameToStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, createdTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Instance other = (Instance) obj;
|
||||
return Objects.equal(this.id, other.id) && Objects.equal(this.createdTime, other.createdTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("id", id).add("name", name.orNull())
|
||||
.add("instanceClass", instanceClass).add("endpoint", endpoint).add("status", status)
|
||||
.add("availabilityZone", availabilityZone).add("multiAZ", multiAZ).add("engine", engine)
|
||||
.add("engineVersion", engineVersion).add("licenseModel", licenseModel)
|
||||
.add("masterUsername", masterUsername).add("allocatedStorageGB", allocatedStorageGB)
|
||||
.add("createdTime", createdTime).add("subnetGroup", subnetGroup.orNull())
|
||||
.add("securityGroupNameToStatus", securityGroupNameToStatus).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,251 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Amazon RDS allows you to control access to your DB Instances using DB Security Groups. A DB
|
||||
* Security Group acts like a firewall controlling network access to your DB Instance. By default,
|
||||
* network access is turned off to your DB Instances. If you want your applications to access your
|
||||
* DB Instance you can allow access from specific EC2 security groups or IP ranges. Once ingress is
|
||||
* configured, the same rules apply to all DB Instances associated with that DBSecurityGroup.
|
||||
*
|
||||
* <h4>Important<h4/>
|
||||
*
|
||||
* Please ensure you authorize only specific IP ranges or EC2 security groups. We highly discourage
|
||||
* authorizing broad IP ranges (for example, 0.0.0.0/0).
|
||||
*
|
||||
* Note that you cannot use Amazon RDS DB Security Groups to restrict access to your Amazon EC2
|
||||
* instances. Similarly, you cannot apply an Amazon EC2 security group to your Amazon RDS DB
|
||||
* Instance.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/UserGuide/Overview.RDSSecurityGroups.html"
|
||||
* >doc</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SecurityGroup {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromSecurityGroup(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected ImmutableSet.Builder<EC2SecurityGroup> ec2SecurityGroups = ImmutableSet.<EC2SecurityGroup> builder();
|
||||
protected ImmutableSet.Builder<IPRange> ipRanges = ImmutableSet.<IPRange> builder();
|
||||
protected String ownerId;
|
||||
protected Optional<String> vpcId = Optional.absent();
|
||||
|
||||
/**
|
||||
* @see SecurityGroup#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SecurityGroup#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SecurityGroup#getEC2SecurityGroups()
|
||||
*/
|
||||
public T ec2SecurityGroups(Iterable<EC2SecurityGroup> ec2SecurityGroups) {
|
||||
this.ec2SecurityGroups.addAll(checkNotNull(ec2SecurityGroups, "ec2SecurityGroups"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SecurityGroup#getEC2SecurityGroups()
|
||||
*/
|
||||
public T ec2SecurityGroup(EC2SecurityGroup ec2SecurityGroup) {
|
||||
this.ec2SecurityGroups.add(checkNotNull(ec2SecurityGroup, "ec2SecurityGroup"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SecurityGroup#getEC2SecurityGroups()
|
||||
*/
|
||||
public T ipRanges(Iterable<IPRange> ipRanges) {
|
||||
this.ipRanges.addAll(checkNotNull(ipRanges, "ipRanges"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SecurityGroup#getEC2SecurityGroups()
|
||||
*/
|
||||
public T ipRange(IPRange ipRange) {
|
||||
this.ipRanges.add(checkNotNull(ipRange, "ipRange"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SecurityGroup#getOwnerId()
|
||||
*/
|
||||
public T ownerId(String ownerId) {
|
||||
this.ownerId = ownerId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SecurityGroupGroup#getVpcId()
|
||||
*/
|
||||
public T vpcId(String vpcId) {
|
||||
this.vpcId = Optional.fromNullable(vpcId);
|
||||
return self();
|
||||
}
|
||||
|
||||
public SecurityGroup build() {
|
||||
return new SecurityGroup(name, description, ec2SecurityGroups.build(), ipRanges.build(), ownerId, vpcId);
|
||||
}
|
||||
|
||||
public T fromSecurityGroup(SecurityGroup in) {
|
||||
return this.name(in.getName()).description(in.getDescription()).ec2SecurityGroups(in.getEC2SecurityGroups())
|
||||
.ipRanges(in.getIPRanges()).ownerId(in.getOwnerId()).vpcId(in.getVpcId().orNull());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected final String name;
|
||||
protected final String description;
|
||||
protected final Set<EC2SecurityGroup> ec2SecurityGroups;
|
||||
protected final Set<IPRange> ipRanges;
|
||||
protected final String ownerId;
|
||||
protected final Optional<String> vpcId;
|
||||
|
||||
protected SecurityGroup(String name, String description, Iterable<EC2SecurityGroup> ec2SecurityGroups,
|
||||
Iterable<IPRange> ipRanges, String ownerId, Optional<String> vpcId) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.description = checkNotNull(description, "description");
|
||||
this.ownerId = checkNotNull(ownerId, "ownerId");
|
||||
this.ec2SecurityGroups = ImmutableSet.copyOf(checkNotNull(ec2SecurityGroups, "ec2SecurityGroups"));
|
||||
this.ipRanges = ImmutableSet.copyOf(checkNotNull(ipRanges, "ipRanges"));
|
||||
this.vpcId = checkNotNull(vpcId, "vpcId");
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the name of the DB Security Group.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the description of the DB Security Group.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains a list of EC2SecurityGroup elements.
|
||||
*/
|
||||
public Set<EC2SecurityGroup> getEC2SecurityGroups() {
|
||||
return ec2SecurityGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains a list of IPRange elements.
|
||||
*/
|
||||
public Set<IPRange> getIPRanges() {
|
||||
return ipRanges;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the AWS ID of the owner of a specific DB Security Group..
|
||||
*/
|
||||
public String getOwnerId() {
|
||||
return ownerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the VpcId of the DB Security Group.
|
||||
*/
|
||||
public Optional<String> getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
SecurityGroup other = (SecurityGroup) obj;
|
||||
return Objects.equal(this.name, other.name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("name", name).add("description", description)
|
||||
.add("ec2SecurityGroups", ec2SecurityGroups).add("ipRanges", ipRanges).add("ownerId", ownerId)
|
||||
.add("vpcId", vpcId.orNull());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_Subnet.html"
|
||||
* >doc</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class Subnet {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromSubnet(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
protected String id;
|
||||
protected String availabilityZone;
|
||||
protected String status;
|
||||
|
||||
/**
|
||||
* @see Subnet#getId()
|
||||
*/
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Subnet#getAvailabilityZone()
|
||||
*/
|
||||
public Builder availabilityZone(String availabilityZone) {
|
||||
this.availabilityZone = availabilityZone;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Subnet#getStatus()
|
||||
*/
|
||||
public Builder status(String status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Subnet build() {
|
||||
return new Subnet(id, availabilityZone, status);
|
||||
}
|
||||
|
||||
public Builder fromSubnet(Subnet in) {
|
||||
return this.id(in.getId()).availabilityZone(in.getAvailabilityZone()).status(in.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
protected final String id;
|
||||
protected final String availabilityZone;
|
||||
protected final String status;
|
||||
|
||||
protected Subnet(String id, String availabilityZone, String status) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.availabilityZone = checkNotNull(availabilityZone, "availabilityZone");
|
||||
this.status = checkNotNull(status, "status");
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the identifier of the subnet.
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the availability zone.
|
||||
*/
|
||||
public String getAvailabilityZone() {
|
||||
return availabilityZone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the current status of the securityGroup.
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Subnet other = Subnet.class.cast(obj);
|
||||
return Objects.equal(this.id, other.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("id", id).add("availabilityZone", availabilityZone)
|
||||
.add("status", status).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,212 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Relational Database Service routinely checks the health of each load-balanced Amazon EC2
|
||||
* securityGroup based on the configurations that you specify. If Relational Database Service finds
|
||||
* an unhealthy securityGroup, it stops sending traffic to the securityGroup and reroutes traffic to
|
||||
* healthy securityGroups.
|
||||
*
|
||||
*
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/DeveloperGuide/ConfigureSubnetGroup.html"
|
||||
* >doc</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SubnetGroup {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromSubnetGroup(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected String status;
|
||||
protected ImmutableSet.Builder<Subnet> subnets = ImmutableSet.<Subnet> builder();
|
||||
protected Optional<String> vpcId = Optional.absent();
|
||||
|
||||
/**
|
||||
* @see SubnetGroup#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = name;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SubnetGroup#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = description;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SubnetGroup#getStatus()
|
||||
*/
|
||||
public T status(String status) {
|
||||
this.status = status;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getSubnets()
|
||||
*/
|
||||
public T subnets(Iterable<Subnet> subnets) {
|
||||
this.subnets.addAll(checkNotNull(subnets, "subnets"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getSubnets()
|
||||
*/
|
||||
public T subnet(Subnet subnet) {
|
||||
this.subnets.add(checkNotNull(subnet, "subnet"));
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SubnetGroup#getVpcId()
|
||||
*/
|
||||
public T vpcId(String vpcId) {
|
||||
this.vpcId = Optional.fromNullable(vpcId);
|
||||
return self();
|
||||
}
|
||||
|
||||
public SubnetGroup build() {
|
||||
return new SubnetGroup(name, description, status, subnets.build(), vpcId);
|
||||
}
|
||||
|
||||
public T fromSubnetGroup(SubnetGroup in) {
|
||||
return this.name(in.getName()).description(in.getDescription()).status(in.getStatus())
|
||||
.subnets(in.getSubnets()).vpcId(in.getVpcId().orNull());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected final String name;
|
||||
protected final String description;
|
||||
protected final String status;
|
||||
protected final Set<Subnet> subnets;
|
||||
protected final Optional<String> vpcId;
|
||||
|
||||
protected SubnetGroup(String name, String description, String status, Iterable<Subnet> subnets, Optional<String> vpcId) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.description = checkNotNull(description, "description");
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.subnets = ImmutableSet.copyOf(checkNotNull(subnets, "subnets"));
|
||||
this.vpcId = checkNotNull(vpcId, "vpcId");
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the name of the DB Subnet Group.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the description of the DB Subnet Group.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the status of the DB Subnet Group.
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the Subnets of the DB Subnet Group.
|
||||
*/
|
||||
public Set<Subnet> getSubnets() {
|
||||
return subnets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the VpcId of the DB Subnet Group.
|
||||
*/
|
||||
public Optional<String> getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(name, vpcId);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
SubnetGroup other = (SubnetGroup) obj;
|
||||
return Objects.equal(this.name, other.name) && Objects.equal(this.vpcId, other.vpcId);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("name", name).add("description", description)
|
||||
.add("status", status).add("subnets", subnets).add("vpcId", vpcId.orNull());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.features;
|
||||
|
||||
import static org.jclouds.aws.reference.FormParameters.ACTION;
|
||||
|
||||
import javax.ws.rs.FormParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.rds.domain.Instance;
|
||||
import org.jclouds.rds.options.ListInstancesOptions;
|
||||
import org.jclouds.rds.xml.DescribeDBInstancesResultHandler;
|
||||
import org.jclouds.rds.xml.InstanceHandler;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.FormParams;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.VirtualHost;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* Provides access to Amazon RDS via the Query API
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference"
|
||||
* >doc</a>
|
||||
* @see InstanceClient
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(FormSigner.class)
|
||||
@VirtualHost
|
||||
public interface InstanceAsyncClient {
|
||||
|
||||
/**
|
||||
* @see InstanceClient#get()
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(InstanceHandler.class)
|
||||
@FormParams(keys = "Action", values = "DescribeDBInstances")
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<Instance> get(@FormParam("DBInstanceIdentifier") String id);
|
||||
|
||||
/**
|
||||
* @see InstanceClient#list()
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(DescribeDBInstancesResultHandler.class)
|
||||
@FormParams(keys = "Action", values = "DescribeDBInstances")
|
||||
ListenableFuture<PaginatedIterable<Instance>> list();
|
||||
|
||||
/**
|
||||
* @see InstanceClient#list(ListInstancesOptions)
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(DescribeDBInstancesResultHandler.class)
|
||||
@FormParams(keys = "Action", values = "DescribeDBInstances")
|
||||
ListenableFuture<PaginatedIterable<Instance>> list(ListInstancesOptions options);
|
||||
|
||||
/**
|
||||
* @see InstanceClient#delete()
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||
@FormParams(keys = ACTION, values = "DeleteDBInstance")
|
||||
ListenableFuture<Void> delete(@FormParam("DBInstanceIdentifier") String id);
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.features;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.rds.domain.Instance;
|
||||
import org.jclouds.rds.options.ListInstancesOptions;
|
||||
|
||||
/**
|
||||
* Provides access to Amazon RDS via the Query API
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference" >doc</a>
|
||||
* @see InstanceAsyncClient
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
||||
public interface InstanceClient {
|
||||
|
||||
/**
|
||||
* Retrieves information about the specified instance.
|
||||
*
|
||||
* @param id
|
||||
* The user-supplied instance identifier. If this parameter is specified, information
|
||||
* from only the specific DB Instance is returned. This parameter isn't case sensitive.
|
||||
*
|
||||
* @return null if not found
|
||||
*/
|
||||
@Nullable
|
||||
Instance get(String id);
|
||||
|
||||
/**
|
||||
* Returns information about provisioned RDS instances. If there are none, the action returns an
|
||||
* empty list.
|
||||
*
|
||||
* <br/>
|
||||
* You can paginate the results using the {@link ListInstancesOptions parameter}
|
||||
*
|
||||
* @param options
|
||||
* the options describing the instances query
|
||||
*
|
||||
* @return the response object
|
||||
*/
|
||||
PaginatedIterable<Instance> list(ListInstancesOptions options);
|
||||
|
||||
/**
|
||||
* Returns information about provisioned RDS instances.
|
||||
*
|
||||
* @return the response object
|
||||
*/
|
||||
PaginatedIterable<Instance> list();
|
||||
|
||||
/**
|
||||
* Deletes the specified Instance.
|
||||
*
|
||||
* <p/>
|
||||
* The DeleteDBInstance API deletes a previously provisioned RDS instance. A successful response
|
||||
* from the web service indicates the request was received correctly. If a final DBSnapshot is
|
||||
* requested the status of the RDS instance will be "deleting" until the DBSnapshot is created.
|
||||
* DescribeDBInstance is used to monitor the status of this operation. This cannot be canceled or
|
||||
* reverted once submitted.
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
* The DB Instance identifier for the DB Instance to be deleted. This parameter isn't
|
||||
* case sensitive.
|
||||
*/
|
||||
void delete(String id);
|
||||
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.features;
|
||||
|
||||
import static org.jclouds.aws.reference.FormParameters.ACTION;
|
||||
|
||||
import javax.ws.rs.FormParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.rds.domain.SecurityGroup;
|
||||
import org.jclouds.rds.options.ListSecurityGroupsOptions;
|
||||
import org.jclouds.rds.xml.DescribeDBSecurityGroupsResultHandler;
|
||||
import org.jclouds.rds.xml.SecurityGroupHandler;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.FormParams;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.VirtualHost;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* Provides access to Amazon RDS via the Query API
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference"
|
||||
* >doc</a>
|
||||
* @see SecurityGroupClient
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(FormSigner.class)
|
||||
@VirtualHost
|
||||
public interface SecurityGroupAsyncClient {
|
||||
|
||||
/**
|
||||
* @see SecurityGroupClient#get()
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(SecurityGroupHandler.class)
|
||||
@FormParams(keys = "Action", values = "DescribeDBSecurityGroups")
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<SecurityGroup> get(@FormParam("DBSecurityGroupName") String name);
|
||||
|
||||
/**
|
||||
* @see SecurityGroupClient#list()
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(DescribeDBSecurityGroupsResultHandler.class)
|
||||
@FormParams(keys = "Action", values = "DescribeDBSecurityGroups")
|
||||
ListenableFuture<PaginatedIterable<SecurityGroup>> list();
|
||||
|
||||
/**
|
||||
* @see SecurityGroupClient#list(ListSecurityGroupsOptions)
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(DescribeDBSecurityGroupsResultHandler.class)
|
||||
@FormParams(keys = "Action", values = "DescribeDBSecurityGroups")
|
||||
ListenableFuture<PaginatedIterable<SecurityGroup>> list(ListSecurityGroupsOptions options);
|
||||
|
||||
/**
|
||||
* @see SecurityGroupClient#delete()
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||
@FormParams(keys = ACTION, values = "DeleteDBSecurityGroup")
|
||||
ListenableFuture<Void> delete(@FormParam("DBSecurityGroupName") String name);
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.features;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.rds.domain.SecurityGroup;
|
||||
import org.jclouds.rds.options.ListSecurityGroupsOptions;
|
||||
|
||||
/**
|
||||
* Provides access to Amazon RDS via the Query API
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference" >doc</a>
|
||||
* @see SecurityGroupAsyncClient
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
||||
public interface SecurityGroupClient {
|
||||
|
||||
/**
|
||||
* Retrieves information about the specified {@link SecurityGroup}.
|
||||
*
|
||||
* @param name
|
||||
* Name of the security group to get information about.
|
||||
* @return null if not found
|
||||
*/
|
||||
@Nullable
|
||||
SecurityGroup get(String name);
|
||||
|
||||
/**
|
||||
* Returns a list of {@link SecurityGroup}s.
|
||||
*
|
||||
* <br/>
|
||||
* You can paginate the results using the {@link ListSecurityGroupsOptions parameter}
|
||||
*
|
||||
* @param options
|
||||
* the options describing the security groups query
|
||||
*
|
||||
* @return the response object
|
||||
*/
|
||||
PaginatedIterable<SecurityGroup> list(ListSecurityGroupsOptions options);
|
||||
|
||||
/**
|
||||
* Returns a list of {@link SecurityGroup}s.
|
||||
*
|
||||
* @return the response object
|
||||
*/
|
||||
PaginatedIterable<SecurityGroup> list();
|
||||
|
||||
/**
|
||||
* Deletes a DB security group.
|
||||
*
|
||||
* <h4>Naming Constraints</h4>
|
||||
*
|
||||
* <ul>
|
||||
* <li>Must be 1 to 255 alphanumeric characters</li>
|
||||
* <li>First character must be a letter</li>
|
||||
* <li>Cannot end with a hyphen or contain two consecutive hyphens</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param name
|
||||
* The name of the database security group to delete.
|
||||
*
|
||||
* <h4>Note</h4>
|
||||
*
|
||||
* You cannot delete the default security group.
|
||||
*/
|
||||
void delete(String name);
|
||||
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.features;
|
||||
|
||||
import static org.jclouds.aws.reference.FormParameters.ACTION;
|
||||
|
||||
import javax.ws.rs.FormParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.rds.domain.SubnetGroup;
|
||||
import org.jclouds.rds.options.ListSubnetGroupsOptions;
|
||||
import org.jclouds.rds.xml.DescribeDBSubnetGroupsResultHandler;
|
||||
import org.jclouds.rds.xml.SubnetGroupHandler;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.FormParams;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.VirtualHost;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* Provides access to Amazon RDS via the Query API
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference"
|
||||
* >doc</a>
|
||||
* @see SubnetGroupClient
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(FormSigner.class)
|
||||
@VirtualHost
|
||||
public interface SubnetGroupAsyncClient {
|
||||
|
||||
/**
|
||||
* @see SubnetGroupClient#get()
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(SubnetGroupHandler.class)
|
||||
@FormParams(keys = "Action", values = "DescribeDBSubnetGroups")
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<SubnetGroup> get(@FormParam("DBSubnetGroupName") String name);
|
||||
|
||||
/**
|
||||
* @see SubnetGroupClient#list()
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(DescribeDBSubnetGroupsResultHandler.class)
|
||||
@FormParams(keys = "Action", values = "DescribeDBSubnetGroups")
|
||||
ListenableFuture<PaginatedIterable<SubnetGroup>> list();
|
||||
|
||||
/**
|
||||
* @see SubnetGroupClient#list(ListSubnetGroupsOptions)
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(DescribeDBSubnetGroupsResultHandler.class)
|
||||
@FormParams(keys = "Action", values = "DescribeDBSubnetGroups")
|
||||
ListenableFuture<PaginatedIterable<SubnetGroup>> list(ListSubnetGroupsOptions options);
|
||||
|
||||
/**
|
||||
* @see SubnetGroupClient#delete()
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||
@FormParams(keys = ACTION, values = "DeleteDBSubnetGroup")
|
||||
ListenableFuture<Void> delete(@FormParam("DBSubnetGroupName") String name);
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.features;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.rds.domain.SubnetGroup;
|
||||
import org.jclouds.rds.options.ListSubnetGroupsOptions;
|
||||
|
||||
/**
|
||||
* Provides access to Amazon RDS via the Query API
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference" >doc</a>
|
||||
* @see SubnetGroupAsyncClient
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
||||
public interface SubnetGroupClient {
|
||||
|
||||
/**
|
||||
* Retrieves information about the specified {@link SubnetGroup}.
|
||||
*
|
||||
* @param name
|
||||
* Name of the subnet group to get information about.
|
||||
* @return null if not found
|
||||
*/
|
||||
@Nullable
|
||||
SubnetGroup get(String name);
|
||||
|
||||
/**
|
||||
* Returns a list of {@link SubnetGroup}s.
|
||||
*
|
||||
* <br/>
|
||||
* You can paginate the results using the {@link ListSubnetGroupsOptions parameter}
|
||||
*
|
||||
* @param options
|
||||
* the options describing the subnet groups query
|
||||
*
|
||||
* @return the response object
|
||||
*/
|
||||
PaginatedIterable<SubnetGroup> list(ListSubnetGroupsOptions options);
|
||||
|
||||
/**
|
||||
* Returns a list of {@link SubnetGroup}s.
|
||||
*
|
||||
* @return the response object
|
||||
*/
|
||||
PaginatedIterable<SubnetGroup> list();
|
||||
|
||||
/**
|
||||
* Deletes a DB subnet group.
|
||||
*
|
||||
* <h4>Note</h4>
|
||||
*
|
||||
* The specified database subnet group must not be associated with any DB instances.
|
||||
*
|
||||
* <h4>Note</h4>
|
||||
*
|
||||
* By design, if the SubnetGroup does not exist or has already been deleted, DeleteSubnetGroup
|
||||
* still succeeds.
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* The name of the database subnet group to delete.
|
||||
*
|
||||
* <h4>Note</h4>
|
||||
*
|
||||
* You cannot delete the default subnet group.
|
||||
*/
|
||||
void delete(String name);
|
||||
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.options;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Options used to list available instances.
|
||||
*
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_DescribeInstances.html"
|
||||
* >docs</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ListInstancesOptions extends BaseHttpRequestOptions implements Cloneable {
|
||||
|
||||
private Object marker;
|
||||
private Set<String> names = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* Use this parameter only when paginating results, and only in a subsequent request after you've
|
||||
* received a response where the results are truncated. Set it to the value of the Marker element
|
||||
* in the response you just received.
|
||||
*/
|
||||
public ListInstancesOptions afterMarker(Object marker) {
|
||||
this.marker = marker;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* list of names associated with the Instances at creation time.
|
||||
*/
|
||||
public ListInstancesOptions names(Set<String> names) {
|
||||
this.names = names;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #names
|
||||
*/
|
||||
public ListInstancesOptions name(String name) {
|
||||
this.names.add(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
/**
|
||||
* @see ListInstancesOptions#getMarker()
|
||||
*/
|
||||
public static ListInstancesOptions afterMarker(Object marker) {
|
||||
return new ListInstancesOptions().afterMarker(marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListInstancesOptions#getNames()
|
||||
*/
|
||||
public static ListInstancesOptions name(String name) {
|
||||
return new ListInstancesOptions().name(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListInstancesOptions#getNames()
|
||||
*/
|
||||
public static ListInstancesOptions names(Set<String> names) {
|
||||
return new ListInstancesOptions().names(names);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, String> buildFormParameters() {
|
||||
Multimap<String, String> params = super.buildFormParameters();
|
||||
if (marker != null)
|
||||
params.put("Marker", marker.toString());
|
||||
if (names.size() > 0) {
|
||||
int nameIndex = 1;
|
||||
for (String name : names) {
|
||||
params.put("InstanceNames.member." + nameIndex, name);
|
||||
nameIndex++;
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(marker, names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListInstancesOptions clone() {
|
||||
return new ListInstancesOptions().afterMarker(marker).names(names);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ListInstancesOptions other = ListInstancesOptions.class.cast(obj);
|
||||
return Objects.equal(this.marker, other.marker) && Objects.equal(this.names, other.names);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("marker", marker).add("names", names).toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.options;
|
||||
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
* Options used to list available instances.
|
||||
*
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_DescribeSecurityGroups.html"
|
||||
* >docs</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ListSecurityGroupsOptions extends BaseHttpRequestOptions implements Cloneable {
|
||||
|
||||
private Object marker;
|
||||
|
||||
/**
|
||||
* Use this parameter only when paginating results, and only in a subsequent request after you've
|
||||
* received a response where the results are truncated. Set it to the value of the Marker element
|
||||
* in the response you just received.
|
||||
*/
|
||||
public ListSecurityGroupsOptions afterMarker(Object marker) {
|
||||
this.marker = marker;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
/**
|
||||
* @see ListSecurityGroupsOptions#getMarker()
|
||||
*/
|
||||
public static ListSecurityGroupsOptions afterMarker(Object marker) {
|
||||
return new ListSecurityGroupsOptions().afterMarker(marker);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, String> buildFormParameters() {
|
||||
Multimap<String, String> params = super.buildFormParameters();
|
||||
if (marker != null)
|
||||
params.put("Marker", marker.toString());
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(marker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListSecurityGroupsOptions clone() {
|
||||
return new ListSecurityGroupsOptions().afterMarker(marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ListSecurityGroupsOptions other = ListSecurityGroupsOptions.class.cast(obj);
|
||||
return Objects.equal(this.marker, other.marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("marker", marker).toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.options;
|
||||
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
* Options used to list available instances.
|
||||
*
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_DescribeSubnetGroups.html"
|
||||
* >docs</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ListSubnetGroupsOptions extends BaseHttpRequestOptions implements Cloneable {
|
||||
|
||||
private Object marker;
|
||||
|
||||
/**
|
||||
* Use this parameter only when paginating results, and only in a subsequent request after you've
|
||||
* received a response where the results are truncated. Set it to the value of the Marker element
|
||||
* in the response you just received.
|
||||
*/
|
||||
public ListSubnetGroupsOptions afterMarker(Object marker) {
|
||||
this.marker = marker;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
/**
|
||||
* @see ListSubnetGroupsOptions#getMarker()
|
||||
*/
|
||||
public static ListSubnetGroupsOptions afterMarker(Object marker) {
|
||||
return new ListSubnetGroupsOptions().afterMarker(marker);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, String> buildFormParameters() {
|
||||
Multimap<String, String> params = super.buildFormParameters();
|
||||
if (marker != null)
|
||||
params.put("Marker", marker.toString());
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(marker);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListSubnetGroupsOptions clone() {
|
||||
return new ListSubnetGroupsOptions().afterMarker(marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ListSubnetGroupsOptions other = ListSubnetGroupsOptions.class.cast(obj);
|
||||
return Objects.equal(this.marker, other.marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return Objects.toStringHelper(this).omitNullValues().add("marker", marker).toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.collect.PaginatedIterables;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.rds.domain.Instance;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_DescribeInstances.html"
|
||||
* >docs</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DescribeDBInstancesResultHandler extends
|
||||
ParseSax.HandlerForGeneratedRequestWithResult<PaginatedIterable<Instance>> {
|
||||
|
||||
private final InstanceHandler instanceHandler;
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private Set<Instance> instances = Sets.newLinkedHashSet();
|
||||
private boolean inInstances;
|
||||
private String marker;
|
||||
|
||||
protected int memberDepth;
|
||||
|
||||
@Inject
|
||||
public DescribeDBInstancesResultHandler(InstanceHandler instanceHandler) {
|
||||
this.instanceHandler = instanceHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public PaginatedIterable<Instance> getResult() {
|
||||
return PaginatedIterables.forwardWithMarker(instances, marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "DBInstances")) {
|
||||
inInstances = true;
|
||||
}
|
||||
if (inInstances) {
|
||||
instanceHandler.startElement(url, name, qName, attributes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "DBInstances")) {
|
||||
inInstances = false;
|
||||
} else if (equalsOrSuffix(qName, "DBInstance")) {
|
||||
instances.add(instanceHandler.getResult());
|
||||
} else if (equalsOrSuffix(qName, "Marker")) {
|
||||
marker = currentOrNull(currentText);
|
||||
} else if (inInstances) {
|
||||
instanceHandler.endElement(uri, name, qName);
|
||||
}
|
||||
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) {
|
||||
if (inInstances) {
|
||||
instanceHandler.characters(ch, start, length);
|
||||
} else {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.collect.PaginatedIterables;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.rds.domain.SecurityGroup;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_DescribeDBSecurityGroups.html"
|
||||
* >docs</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DescribeDBSecurityGroupsResultHandler extends
|
||||
ParseSax.HandlerForGeneratedRequestWithResult<PaginatedIterable<SecurityGroup>> {
|
||||
|
||||
private final SecurityGroupHandler securityGroupHander;
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private Builder<SecurityGroup> securityGroups = ImmutableSet.<SecurityGroup> builder();
|
||||
private boolean inSecurityGroups;
|
||||
private String marker;
|
||||
|
||||
@Inject
|
||||
public DescribeDBSecurityGroupsResultHandler(SecurityGroupHandler securityGroupHander) {
|
||||
this.securityGroupHander = securityGroupHander;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public PaginatedIterable<SecurityGroup> getResult() {
|
||||
return PaginatedIterables.forwardWithMarker(securityGroups.build(), marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "DBSecurityGroups")) {
|
||||
inSecurityGroups = true;
|
||||
}
|
||||
if (inSecurityGroups) {
|
||||
securityGroupHander.startElement(url, name, qName, attributes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "DBSecurityGroups")) {
|
||||
inSecurityGroups = false;
|
||||
} else if (equalsOrSuffix(qName, "DBSecurityGroup")) {
|
||||
securityGroups.add(securityGroupHander.getResult());
|
||||
} else if (equalsOrSuffix(qName, "Marker")) {
|
||||
marker = currentOrNull(currentText);
|
||||
} else if (inSecurityGroups) {
|
||||
securityGroupHander.endElement(uri, name, qName);
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) {
|
||||
if (inSecurityGroups) {
|
||||
securityGroupHander.characters(ch, start, length);
|
||||
} else {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.collect.PaginatedIterables;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.rds.domain.SubnetGroup;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_DescribeDBSubnetGroups.html"
|
||||
* >docs</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DescribeDBSubnetGroupsResultHandler extends
|
||||
ParseSax.HandlerForGeneratedRequestWithResult<PaginatedIterable<SubnetGroup>> {
|
||||
|
||||
private final SubnetGroupHandler subnetGroupHander;
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private Builder<SubnetGroup> subnetGroups = ImmutableSet.<SubnetGroup> builder();
|
||||
private boolean inSubnetGroups;
|
||||
private String marker;
|
||||
|
||||
@Inject
|
||||
public DescribeDBSubnetGroupsResultHandler(SubnetGroupHandler subnetGroupHander) {
|
||||
this.subnetGroupHander = subnetGroupHander;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public PaginatedIterable<SubnetGroup> getResult() {
|
||||
return PaginatedIterables.forwardWithMarker(subnetGroups.build(), marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "DBSubnetGroups")) {
|
||||
inSubnetGroups = true;
|
||||
}
|
||||
if (inSubnetGroups) {
|
||||
subnetGroupHander.startElement(url, name, qName, attributes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "DBSubnetGroups")) {
|
||||
inSubnetGroups = false;
|
||||
} else if (equalsOrSuffix(qName, "DBSubnetGroup")) {
|
||||
subnetGroups.add(subnetGroupHander.getResult());
|
||||
} else if (equalsOrSuffix(qName, "Marker")) {
|
||||
marker = currentOrNull(currentText);
|
||||
} else if (inSubnetGroups) {
|
||||
subnetGroupHander.endElement(uri, name, qName);
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) {
|
||||
if (inSubnetGroups) {
|
||||
subnetGroupHander.characters(ch, start, length);
|
||||
} else {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import org.jclouds.rds.domain.EC2SecurityGroup;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_EC2SecurityGroup.html"
|
||||
* >xml</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class EC2SecurityGroupHandler extends ParseSax.HandlerForGeneratedRequestWithResult<EC2SecurityGroup> {
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private EC2SecurityGroup.Builder builder = EC2SecurityGroup.builder();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public EC2SecurityGroup getResult() {
|
||||
try {
|
||||
return builder.build();
|
||||
} finally {
|
||||
builder = EC2SecurityGroup.builder();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "EC2SecurityGroupId")) {
|
||||
builder.id(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "EC2SecurityGroupName")) {
|
||||
builder.name(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "EC2SecurityGroupOwnerId")) {
|
||||
builder.ownerId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "Status")) {
|
||||
builder.status(currentOrNull(currentText));
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import org.jclouds.rds.domain.IPRange;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_IPRange.html"
|
||||
* >xml</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class IPRangeHandler extends ParseSax.HandlerForGeneratedRequestWithResult<IPRange> {
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private IPRange.Builder builder = IPRange.builder();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public IPRange getResult() {
|
||||
try {
|
||||
return builder.build();
|
||||
} finally {
|
||||
builder = IPRange.builder();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "CIDRIP")) {
|
||||
builder.cidrIp(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "Status")) {
|
||||
builder.status(currentOrNull(currentText));
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.rds.domain.Instance;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.net.HostAndPort;
|
||||
|
||||
/**
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_GetInstance.html"
|
||||
* />
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class InstanceHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Instance> {
|
||||
|
||||
protected final DateService dateService;
|
||||
protected final SubnetGroupHandler subnetGroupHandler;
|
||||
|
||||
@Inject
|
||||
protected InstanceHandler(DateService dateService, SubnetGroupHandler subnetGroupHandler) {
|
||||
this.dateService = dateService;
|
||||
this.subnetGroupHandler = subnetGroupHandler;
|
||||
}
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private Instance.Builder<?> builder = Instance.builder();
|
||||
|
||||
private boolean inSubnetGroup;
|
||||
|
||||
private String address;
|
||||
private Integer port;
|
||||
|
||||
private ImmutableMap.Builder<String, String> securityGroupBuilder = ImmutableMap.<String, String> builder();
|
||||
|
||||
private String groupName;
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Instance getResult() {
|
||||
try {
|
||||
return builder.build();
|
||||
} finally {
|
||||
builder = Instance.builder();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "DBSubnetGroup")) {
|
||||
inSubnetGroup = true;
|
||||
}
|
||||
if (inSubnetGroup) {
|
||||
subnetGroupHandler.startElement(url, name, qName, attributes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) throws SAXException {
|
||||
|
||||
if (equalsOrSuffix(qName, "SubnetGroup")) {
|
||||
builder.subnetGroup(subnetGroupHandler.getResult());
|
||||
inSubnetGroup = false;
|
||||
} else if (equalsOrSuffix(qName, "DBInstanceIdentifier")) {
|
||||
builder.id(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "InstanceCreateTime")) {
|
||||
builder.createdTime(dateService.iso8601DateParse(currentOrNull(currentText)));
|
||||
} else if (equalsOrSuffix(qName, "DBName")) {
|
||||
builder.name(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "AllocatedStorage")) {
|
||||
builder.allocatedStorageGB(Integer.parseInt(currentOrNull(currentText)));
|
||||
} else if (equalsOrSuffix(qName, "DBInstanceStatus")) {
|
||||
builder.status(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "Address")) {
|
||||
address = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "Port")) {
|
||||
port = new Integer(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "Endpoint")) {
|
||||
builder.endpoint(HostAndPort.fromParts(address, port));
|
||||
address = null;
|
||||
port = null;
|
||||
} else if (equalsOrSuffix(qName, "DBSecurityGroupName")) {
|
||||
groupName = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "Status")) {
|
||||
status = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "DBSecurityGroup")) {
|
||||
securityGroupBuilder.put(groupName, status);
|
||||
groupName = status = null;
|
||||
} else if (equalsOrSuffix(qName, "DBSecurityGroups")) {
|
||||
builder.securityGroupNameToStatus(securityGroupBuilder.build());
|
||||
securityGroupBuilder = ImmutableMap.<String, String> builder();
|
||||
} else if (equalsOrSuffix(qName, "DBInstanceClass")) {
|
||||
builder.instanceClass(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "AvailabilityZone")) {
|
||||
builder.availabilityZone(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "MultiAZ")) {
|
||||
builder.multiAZ(Boolean.parseBoolean(currentOrNull(currentText)));
|
||||
} else if (equalsOrSuffix(qName, "Engine")) {
|
||||
builder.engine(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "EngineVersion")) {
|
||||
builder.engineVersion(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "LicenseModel")) {
|
||||
builder.licenseModel(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "MasterUsername")) {
|
||||
builder.masterUsername(currentOrNull(currentText));
|
||||
} else if (inSubnetGroup) {
|
||||
subnetGroupHandler.endElement(uri, name, qName);
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) {
|
||||
if (inSubnetGroup) {
|
||||
subnetGroupHandler.characters(ch, start, length);
|
||||
} else {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.rds.domain.SecurityGroup;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_DBSecurityGroup.html"
|
||||
* >xml</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SecurityGroupHandler extends ParseSax.HandlerForGeneratedRequestWithResult<SecurityGroup> {
|
||||
protected final EC2SecurityGroupHandler ec2SecurityGroupHandler;
|
||||
protected final IPRangeHandler ipRangeHandler;
|
||||
|
||||
@Inject
|
||||
protected SecurityGroupHandler(EC2SecurityGroupHandler ec2SecurityGroupHandler, IPRangeHandler ipRangeHandler) {
|
||||
this.ec2SecurityGroupHandler = ec2SecurityGroupHandler;
|
||||
this.ipRangeHandler = ipRangeHandler;
|
||||
}
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private SecurityGroup.Builder<?> builder = SecurityGroup.builder();
|
||||
|
||||
private boolean inEC2SecurityGroups;
|
||||
private boolean inIPRanges;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public SecurityGroup getResult() {
|
||||
try {
|
||||
return builder.build();
|
||||
} finally {
|
||||
builder = SecurityGroup.builder();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "EC2SecurityGroups")) {
|
||||
inEC2SecurityGroups = true;
|
||||
} else if (equalsOrSuffix(qName, "IPRanges")) {
|
||||
inIPRanges = true;
|
||||
}
|
||||
if (inEC2SecurityGroups) {
|
||||
ec2SecurityGroupHandler.startElement(url, name, qName, attributes);
|
||||
} else if (inIPRanges) {
|
||||
ipRangeHandler.startElement(url, name, qName, attributes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "EC2SecurityGroups")) {
|
||||
inEC2SecurityGroups = false;
|
||||
} else if (equalsOrSuffix(qName, "IPRanges")) {
|
||||
inIPRanges = false;
|
||||
} else if (equalsOrSuffix(qName, "DBSecurityGroupName")) {
|
||||
builder.name(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "DBSecurityGroupDescription")) {
|
||||
builder.description(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "EC2SecurityGroup")) {
|
||||
builder.ec2SecurityGroup(ec2SecurityGroupHandler.getResult());
|
||||
} else if (equalsOrSuffix(qName, "IPRange")) {
|
||||
builder.ipRange(ipRangeHandler.getResult());
|
||||
} else if (equalsOrSuffix(qName, "OwnerId")) {
|
||||
builder.ownerId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "VpcId")) {
|
||||
builder.vpcId(currentOrNull(currentText));
|
||||
} else if (inEC2SecurityGroups) {
|
||||
ec2SecurityGroupHandler.endElement(uri, name, qName);
|
||||
} else if (inIPRanges) {
|
||||
ipRangeHandler.endElement(uri, name, qName);
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) {
|
||||
if (inEC2SecurityGroups) {
|
||||
ec2SecurityGroupHandler.characters(ch, start, length);
|
||||
} else if (inIPRanges) {
|
||||
ipRangeHandler.characters(ch, start, length);
|
||||
} else {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.rds.domain.SubnetGroup;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_DBSubnetGroup.html"
|
||||
* >xml</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SubnetGroupHandler extends ParseSax.HandlerForGeneratedRequestWithResult<SubnetGroup> {
|
||||
protected final SubnetHandler subnetHandler;
|
||||
|
||||
@Inject
|
||||
protected SubnetGroupHandler(SubnetHandler subnetHandler) {
|
||||
this.subnetHandler = subnetHandler;
|
||||
}
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private SubnetGroup.Builder<?> builder = SubnetGroup.builder();
|
||||
|
||||
private boolean inSubnets;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public SubnetGroup getResult() {
|
||||
try {
|
||||
return builder.build();
|
||||
} finally {
|
||||
builder = SubnetGroup.builder();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "Subnets")) {
|
||||
inSubnets = true;
|
||||
}
|
||||
if (inSubnets) {
|
||||
subnetHandler.startElement(url, name, qName, attributes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "Subnets")) {
|
||||
inSubnets = false;
|
||||
} else if (equalsOrSuffix(qName, "DBSubnetGroupName")) {
|
||||
builder.name(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "DBSubnetGroupDescription")) {
|
||||
builder.description(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "SubnetGroupStatus")) {
|
||||
builder.status(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "Subnet")) {
|
||||
builder.subnet(subnetHandler.getResult());
|
||||
} else if (equalsOrSuffix(qName, "VpcId")) {
|
||||
builder.vpcId(currentOrNull(currentText));
|
||||
} else if (inSubnets) {
|
||||
subnetHandler.endElement(uri, name, qName);
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) {
|
||||
if (inSubnets) {
|
||||
subnetHandler.characters(ch, start, length);
|
||||
} else {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import org.jclouds.rds.domain.Subnet;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AmazonRDS/latest/APIReference/API_Subnet.html"
|
||||
* >xml</a>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SubnetHandler extends ParseSax.HandlerForGeneratedRequestWithResult<Subnet> {
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private Subnet.Builder builder = Subnet.builder();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Subnet getResult() {
|
||||
try {
|
||||
return builder.build();
|
||||
} finally {
|
||||
builder = Subnet.builder();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void endElement(String uri, String name, String qName) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "SubnetIdentifier")) {
|
||||
builder.id(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "Name")) {
|
||||
builder.availabilityZone(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "SubnetStatus")) {
|
||||
builder.status(currentOrNull(currentText));
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
org.jclouds.rds.RDSApiMetadata
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds;
|
||||
|
||||
import org.jclouds.View;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadataTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "RDSApiMetadataTest")
|
||||
public class RDSApiMetadataTest extends BaseRestApiMetadataTest {
|
||||
|
||||
// no database abstraction, yet
|
||||
public RDSApiMetadataTest() {
|
||||
super(new RDSApiMetadata(), ImmutableSet.<TypeToken<? extends View>> of());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
package org.jclouds.rds;
|
||||
|
||||
import static org.easymock.EasyMock.anyObject;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.collect.PaginatedIterables;
|
||||
import org.jclouds.rds.domain.Instance;
|
||||
import org.jclouds.rds.domain.SecurityGroup;
|
||||
import org.jclouds.rds.domain.SubnetGroup;
|
||||
import org.jclouds.rds.features.InstanceClient;
|
||||
import org.jclouds.rds.features.SecurityGroupClient;
|
||||
import org.jclouds.rds.features.SubnetGroupClient;
|
||||
import org.jclouds.rds.options.ListInstancesOptions;
|
||||
import org.jclouds.rds.options.ListSecurityGroupsOptions;
|
||||
import org.jclouds.rds.options.ListSubnetGroupsOptions;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code RDS}.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(testName = "RDSTest")
|
||||
public class RDSTest {
|
||||
|
||||
@Test
|
||||
public void testSinglePageResultInstance() throws Exception {
|
||||
InstanceClient instanceClient = createMock(InstanceClient.class);
|
||||
ListInstancesOptions options = new ListInstancesOptions();
|
||||
PaginatedIterable<Instance> response = PaginatedIterables.forward(ImmutableSet.of(createMock(Instance.class)));
|
||||
|
||||
expect(instanceClient.list(options)).andReturn(response).once();
|
||||
|
||||
EasyMock.replay(instanceClient);
|
||||
|
||||
Assert.assertEquals(1, Iterables.size(RDS.listInstances(instanceClient, options)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiPageResultInstance() throws Exception {
|
||||
InstanceClient instanceClient = createMock(InstanceClient.class);
|
||||
ListInstancesOptions options = new ListInstancesOptions();
|
||||
PaginatedIterable<Instance> response1 = PaginatedIterables.forwardWithMarker(
|
||||
ImmutableSet.of(createMock(Instance.class)), "NEXTTOKEN");
|
||||
PaginatedIterable<Instance> response2 = PaginatedIterables.forward(ImmutableSet.of(createMock(Instance.class)));
|
||||
|
||||
expect(instanceClient.list(anyObject(ListInstancesOptions.class))).andReturn(response1).once();
|
||||
expect(instanceClient.list(anyObject(ListInstancesOptions.class))).andReturn(response2).once();
|
||||
|
||||
EasyMock.replay(instanceClient);
|
||||
|
||||
Assert.assertEquals(2, Iterables.size(RDS.listInstances(instanceClient, options)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSinglePageResultSubnetGroup() throws Exception {
|
||||
SubnetGroupClient subnetGroupClient = createMock(SubnetGroupClient.class);
|
||||
ListSubnetGroupsOptions options = new ListSubnetGroupsOptions();
|
||||
PaginatedIterable<SubnetGroup> response = PaginatedIterables.forward(ImmutableSet
|
||||
.of(createMock(SubnetGroup.class)));
|
||||
|
||||
expect(subnetGroupClient.list(options)).andReturn(response).once();
|
||||
|
||||
EasyMock.replay(subnetGroupClient);
|
||||
|
||||
Assert.assertEquals(1, Iterables.size(RDS.listSubnetGroups(subnetGroupClient, options)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiPageResultSubnetGroup() throws Exception {
|
||||
SubnetGroupClient subnetGroupClient = createMock(SubnetGroupClient.class);
|
||||
ListSubnetGroupsOptions options = new ListSubnetGroupsOptions();
|
||||
PaginatedIterable<SubnetGroup> response1 = PaginatedIterables.forwardWithMarker(
|
||||
ImmutableSet.of(createMock(SubnetGroup.class)), "NEXTTOKEN");
|
||||
PaginatedIterable<SubnetGroup> response2 = PaginatedIterables.forward(ImmutableSet
|
||||
.of(createMock(SubnetGroup.class)));
|
||||
|
||||
expect(subnetGroupClient.list(anyObject(ListSubnetGroupsOptions.class))).andReturn(response1).once();
|
||||
expect(subnetGroupClient.list(anyObject(ListSubnetGroupsOptions.class))).andReturn(response2).once();
|
||||
|
||||
EasyMock.replay(subnetGroupClient);
|
||||
|
||||
Assert.assertEquals(2, Iterables.size(RDS.listSubnetGroups(subnetGroupClient, options)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSinglePageResultSecurityGroup() throws Exception {
|
||||
SecurityGroupClient securityGroupClient = createMock(SecurityGroupClient.class);
|
||||
ListSecurityGroupsOptions options = new ListSecurityGroupsOptions();
|
||||
PaginatedIterable<SecurityGroup> response = PaginatedIterables.forward(ImmutableSet
|
||||
.of(createMock(SecurityGroup.class)));
|
||||
|
||||
expect(securityGroupClient.list(options)).andReturn(response).once();
|
||||
|
||||
EasyMock.replay(securityGroupClient);
|
||||
|
||||
Assert.assertEquals(1, Iterables.size(RDS.listSecurityGroups(securityGroupClient, options)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiPageResultSecurityGroup() throws Exception {
|
||||
SecurityGroupClient securityGroupClient = createMock(SecurityGroupClient.class);
|
||||
ListSecurityGroupsOptions options = new ListSecurityGroupsOptions();
|
||||
PaginatedIterable<SecurityGroup> response1 = PaginatedIterables.forwardWithMarker(
|
||||
ImmutableSet.of(createMock(SecurityGroup.class)), "NEXTTOKEN");
|
||||
PaginatedIterable<SecurityGroup> response2 = PaginatedIterables.forward(ImmutableSet
|
||||
.of(createMock(SecurityGroup.class)));
|
||||
|
||||
expect(securityGroupClient.list(anyObject(ListSecurityGroupsOptions.class))).andReturn(response1).once();
|
||||
expect(securityGroupClient.list(anyObject(ListSecurityGroupsOptions.class))).andReturn(response2).once();
|
||||
|
||||
EasyMock.replay(securityGroupClient);
|
||||
|
||||
Assert.assertEquals(2, Iterables.size(RDS.listSecurityGroups(securityGroupClient, options)));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,197 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unles required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either expres or implied. See the License for the
|
||||
* specific language governing permisions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.features;
|
||||
|
||||
import static org.jclouds.rds.options.ListInstancesOptions.Builder.afterMarker;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.rds.RDSClient;
|
||||
import org.jclouds.rds.internal.BaseRDSClientExpectTest;
|
||||
import org.jclouds.rds.parse.DescribeDBInstancesResponseTest;
|
||||
import org.jclouds.rds.parse.GetInstanceResponseTest;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "InstanceClientExpectTest")
|
||||
public class InstanceClientExpectTest extends BaseRDSClientExpectTest {
|
||||
|
||||
public InstanceClientExpectTest() {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
|
||||
}
|
||||
|
||||
HttpRequest get = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://rds.us-east-1.amazonaws.com/"))
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Host", "rds.us-east-1.amazonaws.com")
|
||||
.build())
|
||||
.payload(
|
||||
payloadFromStringWithContentType(
|
||||
"Action=DescribeDBInstances" +
|
||||
"&DBInstanceIdentifier=id" +
|
||||
"&Signature=jcvzapwazR2OuWnMILEt48ycu226NOn2AuEBKSxV2O0%3D" +
|
||||
"&SignatureMethod=HmacSHA256" +
|
||||
"&SignatureVersion=2" +
|
||||
"&Timestamp=2009-11-08T15%3A54%3A08.897Z" +
|
||||
"&Version=2012-04-23" +
|
||||
"&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded"))
|
||||
.build();
|
||||
|
||||
|
||||
public void testGetWhenResponseIs2xx() throws Exception {
|
||||
|
||||
HttpResponse getResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/get_instance.xml", "text/xml")).build();
|
||||
|
||||
RDSClient clientWhenExist = requestSendsResponse(
|
||||
get, getResponse);
|
||||
|
||||
assertEquals(clientWhenExist.getInstanceClient().get("id").toString(), new GetInstanceResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testGetWhenResponseIs404() throws Exception {
|
||||
|
||||
HttpResponse getResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RDSClient clientWhenDontExist = requestSendsResponse(
|
||||
get, getResponse);
|
||||
|
||||
assertNull(clientWhenDontExist.getInstanceClient().get("id"));
|
||||
}
|
||||
|
||||
HttpRequest list = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://rds.us-east-1.amazonaws.com/"))
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Host", "rds.us-east-1.amazonaws.com")
|
||||
.build())
|
||||
.payload(
|
||||
payloadFromStringWithContentType(
|
||||
"Action=DescribeDBInstances" +
|
||||
"&Signature=SnClCujZG9Sq9sMdf59xZWsjQxIbMOp5YEF%2FFBsurf4%3D" +
|
||||
"&SignatureMethod=HmacSHA256" +
|
||||
"&SignatureVersion=2" +
|
||||
"&Timestamp=2009-11-08T15%3A54%3A08.897Z" +
|
||||
"&Version=2012-04-23" +
|
||||
"&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded"))
|
||||
.build();
|
||||
|
||||
public void testListWhenResponseIs2xx() throws Exception {
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/describe_instances.xml", "text/xml")).build();
|
||||
|
||||
RDSClient clientWhenExist = requestSendsResponse(
|
||||
list, listResponse);
|
||||
|
||||
assertEquals(clientWhenExist.getInstanceClient().list().toString(), new DescribeDBInstancesResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
// TODO: this should really be an empty set
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testListWhenResponseIs404() throws Exception {
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RDSClient clientWhenDontExist = requestSendsResponse(
|
||||
list, listResponse);
|
||||
|
||||
clientWhenDontExist.getInstanceClient().list();
|
||||
}
|
||||
|
||||
public void testListWithOptionsWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listWithOptions =
|
||||
HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://rds.us-east-1.amazonaws.com/"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Host", "rds.us-east-1.amazonaws.com")
|
||||
.build())
|
||||
.payload(payloadFromStringWithContentType(
|
||||
"Action=DescribeDBInstances" +
|
||||
"&Marker=MARKER" +
|
||||
"&Signature=TFW8vaU2IppmBey0ZHttbWz4rMFh%2F5ACWl6Xyt58sQU%3D" +
|
||||
"&SignatureMethod=HmacSHA256" +
|
||||
"&SignatureVersion=2" +
|
||||
"&Timestamp=2009-11-08T15%3A54%3A08.897Z" +
|
||||
"&Version=2012-04-23" +
|
||||
"&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded"))
|
||||
.build();
|
||||
|
||||
HttpResponse listWithOptionsResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/describe_instances.xml", "text/xml")).build();
|
||||
|
||||
RDSClient clientWhenWithOptionsExist = requestSendsResponse(listWithOptions,
|
||||
listWithOptionsResponse);
|
||||
|
||||
assertEquals(clientWhenWithOptionsExist.getInstanceClient().list(afterMarker("MARKER")).toString(),
|
||||
new DescribeDBInstancesResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpRequest delete = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://rds.us-east-1.amazonaws.com/"))
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Host", "rds.us-east-1.amazonaws.com")
|
||||
.build())
|
||||
.payload(
|
||||
payloadFromStringWithContentType(
|
||||
"Action=DeleteDBInstance" +
|
||||
"&DBInstanceIdentifier=id" +
|
||||
"&Signature=3UFxv5zaG%2B3dZRAhinJZ10De0LAxkJtr3Nb6kfspC7w%3D" +
|
||||
"&SignatureMethod=HmacSHA256" +
|
||||
"&SignatureVersion=2" +
|
||||
"&Timestamp=2009-11-08T15%3A54%3A08.897Z" +
|
||||
"&Version=2012-04-23" +
|
||||
"&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded"))
|
||||
.build();
|
||||
|
||||
public void testDeleteWhenResponseIs2xx() throws Exception {
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(200).build();
|
||||
|
||||
RDSClient clientWhenExist = requestSendsResponse(delete, deleteResponse);
|
||||
|
||||
clientWhenExist.getInstanceClient().delete("id");
|
||||
}
|
||||
|
||||
public void testDeleteWhenResponseIs404() throws Exception {
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RDSClient clientWhenDontExist = requestSendsResponse(delete, deleteResponse);
|
||||
|
||||
clientWhenDontExist.getInstanceClient().delete("id");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.features;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.rds.domain.Instance;
|
||||
import org.jclouds.rds.internal.BaseRDSClientLiveTest;
|
||||
import org.jclouds.rds.options.ListInstancesOptions;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", testName = "InstanceClientLiveTest")
|
||||
public class InstanceClientLiveTest extends BaseRDSClientLiveTest {
|
||||
|
||||
private void checkInstance(Instance instance) {
|
||||
checkNotNull(instance.getId(), "Id cannot be null for a Instance: %s", instance);
|
||||
checkNotNull(instance.getCreatedTime(), "CreatedTime cannot be null for a Instance: %s", instance);
|
||||
checkNotNull(instance.getName(), "While Name can be null for a Instance, its Optional wrapper cannot: %s",
|
||||
instance);
|
||||
checkNotNull(instance.getSubnetGroup(),
|
||||
"While SubnetGroup can be null for a Instance, its Optional wrapper cannot: %s", instance);
|
||||
// TODO: other checks
|
||||
if (instance.getSubnetGroup().isPresent())
|
||||
SubnetGroupClientLiveTest.checkSubnetGroup(instance.getSubnetGroup().get());
|
||||
}
|
||||
|
||||
@Test
|
||||
protected void testDescribeInstances() {
|
||||
PaginatedIterable<Instance> response = client().list();
|
||||
|
||||
for (Instance instance : response) {
|
||||
checkInstance(instance);
|
||||
}
|
||||
|
||||
if (Iterables.size(response) > 0) {
|
||||
Instance instance = response.iterator().next();
|
||||
Assert.assertEquals(client().get(instance.getId()), instance);
|
||||
}
|
||||
|
||||
// Test with a Marker, even if it's null
|
||||
response = client().list(ListInstancesOptions.Builder.afterMarker(response.getNextMarker()));
|
||||
for (Instance instance : response) {
|
||||
checkInstance(instance);
|
||||
}
|
||||
}
|
||||
|
||||
protected InstanceClient client() {
|
||||
return context.getApi().getInstanceClient();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,197 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unles required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either expres or implied. See the License for the
|
||||
* specific language governing permisions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.features;
|
||||
|
||||
import static org.jclouds.rds.options.ListSecurityGroupsOptions.Builder.afterMarker;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.rds.RDSClient;
|
||||
import org.jclouds.rds.internal.BaseRDSClientExpectTest;
|
||||
import org.jclouds.rds.parse.DescribeDBSecurityGroupsResponseTest;
|
||||
import org.jclouds.rds.parse.GetSecurityGroupResponseTest;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "SecurityGroupClientExpectTest")
|
||||
public class SecurityGroupClientExpectTest extends BaseRDSClientExpectTest {
|
||||
|
||||
public SecurityGroupClientExpectTest() {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
|
||||
}
|
||||
|
||||
HttpRequest get = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://rds.us-east-1.amazonaws.com/"))
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Host", "rds.us-east-1.amazonaws.com")
|
||||
.build())
|
||||
.payload(
|
||||
payloadFromStringWithContentType(
|
||||
"Action=DescribeDBSecurityGroups" +
|
||||
"&DBSecurityGroupName=name" +
|
||||
"&Signature=F019%2B74qM%2FivsW6ngZWfILFBss4RqPGlppawtAjwUPg%3D" +
|
||||
"&SignatureMethod=HmacSHA256" +
|
||||
"&SignatureVersion=2" +
|
||||
"&Timestamp=2009-11-08T15%3A54%3A08.897Z" +
|
||||
"&Version=2012-04-23" +
|
||||
"&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded"))
|
||||
.build();
|
||||
|
||||
|
||||
public void testGetWhenResponseIs2xx() throws Exception {
|
||||
|
||||
HttpResponse getResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/get_securitygroup.xml", "text/xml")).build();
|
||||
|
||||
RDSClient clientWhenExist = requestSendsResponse(
|
||||
get, getResponse);
|
||||
|
||||
assertEquals(clientWhenExist.getSecurityGroupClient().get("name").toString(), new GetSecurityGroupResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testGetWhenResponseIs404() throws Exception {
|
||||
|
||||
HttpResponse getResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RDSClient clientWhenDontExist = requestSendsResponse(
|
||||
get, getResponse);
|
||||
|
||||
assertNull(clientWhenDontExist.getSecurityGroupClient().get("name"));
|
||||
}
|
||||
|
||||
HttpRequest list = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://rds.us-east-1.amazonaws.com/"))
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Host", "rds.us-east-1.amazonaws.com")
|
||||
.build())
|
||||
.payload(
|
||||
payloadFromStringWithContentType(
|
||||
"Action=DescribeDBSecurityGroups" +
|
||||
"&Signature=6PMtOHuBCxE%2FuujPnvn%2FnN8NIZrwcx9X0Jy6hz%2FRXtg%3D" +
|
||||
"&SignatureMethod=HmacSHA256" +
|
||||
"&SignatureVersion=2" +
|
||||
"&Timestamp=2009-11-08T15%3A54%3A08.897Z" +
|
||||
"&Version=2012-04-23" +
|
||||
"&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded"))
|
||||
.build();
|
||||
|
||||
public void testListWhenResponseIs2xx() throws Exception {
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/describe_securitygroups.xml", "text/xml")).build();
|
||||
|
||||
RDSClient clientWhenExist = requestSendsResponse(
|
||||
list, listResponse);
|
||||
|
||||
assertEquals(clientWhenExist.getSecurityGroupClient().list().toString(), new DescribeDBSecurityGroupsResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
// TODO: this should really be an empty set
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testListWhenResponseIs404() throws Exception {
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RDSClient clientWhenDontExist = requestSendsResponse(
|
||||
list, listResponse);
|
||||
|
||||
clientWhenDontExist.getSecurityGroupClient().list();
|
||||
}
|
||||
|
||||
public void testListWithOptionsWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listWithOptions =
|
||||
HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://rds.us-east-1.amazonaws.com/"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Host", "rds.us-east-1.amazonaws.com")
|
||||
.build())
|
||||
.payload(payloadFromStringWithContentType(
|
||||
"Action=DescribeDBSecurityGroups" +
|
||||
"&Marker=MARKER" +
|
||||
"&Signature=DeZcA5ViQu%2FbB3PY9EmRZavRgYxLFMvdbq7topMKKhw%3D" +
|
||||
"&SignatureMethod=HmacSHA256" +
|
||||
"&SignatureVersion=2" +
|
||||
"&Timestamp=2009-11-08T15%3A54%3A08.897Z" +
|
||||
"&Version=2012-04-23" +
|
||||
"&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded"))
|
||||
.build();
|
||||
|
||||
HttpResponse listWithOptionsResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/describe_securitygroups.xml", "text/xml")).build();
|
||||
|
||||
RDSClient clientWhenWithOptionsExist = requestSendsResponse(listWithOptions,
|
||||
listWithOptionsResponse);
|
||||
|
||||
assertEquals(clientWhenWithOptionsExist.getSecurityGroupClient().list(afterMarker("MARKER")).toString(),
|
||||
new DescribeDBSecurityGroupsResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpRequest delete = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://rds.us-east-1.amazonaws.com/"))
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Host", "rds.us-east-1.amazonaws.com")
|
||||
.build())
|
||||
.payload(
|
||||
payloadFromStringWithContentType(
|
||||
"Action=DeleteDBSecurityGroup" +
|
||||
"&DBSecurityGroupName=name" +
|
||||
"&Signature=7lQqK7wJUuc7nONYnXdHVibudxqnfJPFrfdnzwEEKxE%3D" +
|
||||
"&SignatureMethod=HmacSHA256" +
|
||||
"&SignatureVersion=2" +
|
||||
"&Timestamp=2009-11-08T15%3A54%3A08.897Z" +
|
||||
"&Version=2012-04-23" +
|
||||
"&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded"))
|
||||
.build();
|
||||
|
||||
public void testDeleteWhenResponseIs2xx() throws Exception {
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(200).build();
|
||||
|
||||
RDSClient clientWhenExist = requestSendsResponse(delete, deleteResponse);
|
||||
|
||||
clientWhenExist.getSecurityGroupClient().delete("name");
|
||||
}
|
||||
|
||||
public void testDeleteWhenResponseIs404() throws Exception {
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RDSClient clientWhenDontExist = requestSendsResponse(delete, deleteResponse);
|
||||
|
||||
clientWhenDontExist.getSecurityGroupClient().delete("name");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.features;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.rds.domain.EC2SecurityGroup;
|
||||
import org.jclouds.rds.domain.SecurityGroup;
|
||||
import org.jclouds.rds.internal.BaseRDSClientLiveTest;
|
||||
import org.jclouds.rds.options.ListSecurityGroupsOptions;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", testName = "SecurityGroupClientLiveTest")
|
||||
public class SecurityGroupClientLiveTest extends BaseRDSClientLiveTest {
|
||||
|
||||
static void checkSecurityGroup(SecurityGroup securityGroup) {
|
||||
checkNotNull(securityGroup.getName(), "Name cannot be null for a SecurityGroup: %s", securityGroup);
|
||||
checkNotNull(securityGroup.getDescription(), "Description cannot be null for a SecurityGroup: %s", securityGroup);
|
||||
checkNotNull(securityGroup.getOwnerId(), "OwnerId cannot be null for a SecurityGroup: %s", securityGroup);
|
||||
checkNotNull(securityGroup.getVpcId(), "VpcId cannot be null for a SecurityGroup: %s", securityGroup);
|
||||
for (EC2SecurityGroup security : securityGroup.getEC2SecurityGroups()) {
|
||||
checkEC2SecurityGroup(security);
|
||||
}
|
||||
}
|
||||
|
||||
static void checkEC2SecurityGroup(EC2SecurityGroup security) {
|
||||
checkNotNull(security.getId(), "Id can be null for a SecurityGroup, but its Optional Wrapper cannot: %s", security);
|
||||
checkNotNull(security.getStatus(), "Status cannot be null for a SecurityGroup: %s", security);
|
||||
checkNotNull(security.getName(), "Name cannot be null for a SecurityGroup: %s", security);
|
||||
checkNotNull(security.getOwnerId(), "Name cannot be null for a SecurityGroup: %s", security);
|
||||
}
|
||||
|
||||
@Test
|
||||
protected void testDescribeSecurityGroups() {
|
||||
PaginatedIterable<SecurityGroup> response = client().list();
|
||||
|
||||
for (SecurityGroup securityGroup : response) {
|
||||
checkSecurityGroup(securityGroup);
|
||||
}
|
||||
|
||||
if (Iterables.size(response) > 0) {
|
||||
SecurityGroup securityGroup = response.iterator().next();
|
||||
Assert.assertEquals(client().get(securityGroup.getName()), securityGroup);
|
||||
}
|
||||
|
||||
// Test with a Marker, even if it's null
|
||||
response = client().list(ListSecurityGroupsOptions.Builder.afterMarker(response.getNextMarker()));
|
||||
for (SecurityGroup securityGroup : response) {
|
||||
checkSecurityGroup(securityGroup);
|
||||
}
|
||||
}
|
||||
|
||||
protected SecurityGroupClient client() {
|
||||
return context.getApi().getSecurityGroupClient();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,197 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unles required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either expres or implied. See the License for the
|
||||
* specific language governing permisions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.features;
|
||||
|
||||
import static org.jclouds.rds.options.ListSubnetGroupsOptions.Builder.afterMarker;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.rds.RDSClient;
|
||||
import org.jclouds.rds.internal.BaseRDSClientExpectTest;
|
||||
import org.jclouds.rds.parse.DescribeDBSubnetGroupsResponseTest;
|
||||
import org.jclouds.rds.parse.GetSubnetGroupResponseTest;
|
||||
import org.jclouds.rest.ResourceNotFoundException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "SubnetGroupClientExpectTest")
|
||||
public class SubnetGroupClientExpectTest extends BaseRDSClientExpectTest {
|
||||
|
||||
public SubnetGroupClientExpectTest() {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
|
||||
}
|
||||
|
||||
HttpRequest get = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://rds.us-east-1.amazonaws.com/"))
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Host", "rds.us-east-1.amazonaws.com")
|
||||
.build())
|
||||
.payload(
|
||||
payloadFromStringWithContentType(
|
||||
"Action=DescribeDBSubnetGroups" +
|
||||
"&DBSubnetGroupName=name" +
|
||||
"&Signature=U7DwaG%2BDARTb1iQxztQN%2BBe042ywyD7wxEVUlm4%2FA20%3D" +
|
||||
"&SignatureMethod=HmacSHA256" +
|
||||
"&SignatureVersion=2" +
|
||||
"&Timestamp=2009-11-08T15%3A54%3A08.897Z" +
|
||||
"&Version=2012-04-23" +
|
||||
"&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded"))
|
||||
.build();
|
||||
|
||||
|
||||
public void testGetWhenResponseIs2xx() throws Exception {
|
||||
|
||||
HttpResponse getResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/get_subnetgroup.xml", "text/xml")).build();
|
||||
|
||||
RDSClient clientWhenExist = requestSendsResponse(
|
||||
get, getResponse);
|
||||
|
||||
assertEquals(clientWhenExist.getSubnetGroupClient().get("name").toString(), new GetSubnetGroupResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testGetWhenResponseIs404() throws Exception {
|
||||
|
||||
HttpResponse getResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RDSClient clientWhenDontExist = requestSendsResponse(
|
||||
get, getResponse);
|
||||
|
||||
assertNull(clientWhenDontExist.getSubnetGroupClient().get("name"));
|
||||
}
|
||||
|
||||
HttpRequest list = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://rds.us-east-1.amazonaws.com/"))
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Host", "rds.us-east-1.amazonaws.com")
|
||||
.build())
|
||||
.payload(
|
||||
payloadFromStringWithContentType(
|
||||
"Action=DescribeDBSubnetGroups" +
|
||||
"&Signature=KLYL7jWGWT2ItwBv2z0ZNAFv1KAnPwNUhVqTHm0nWcI%3D" +
|
||||
"&SignatureMethod=HmacSHA256" +
|
||||
"&SignatureVersion=2" +
|
||||
"&Timestamp=2009-11-08T15%3A54%3A08.897Z" +
|
||||
"&Version=2012-04-23" +
|
||||
"&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded"))
|
||||
.build();
|
||||
|
||||
public void testListWhenResponseIs2xx() throws Exception {
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/describe_subnetgroups.xml", "text/xml")).build();
|
||||
|
||||
RDSClient clientWhenExist = requestSendsResponse(
|
||||
list, listResponse);
|
||||
|
||||
assertEquals(clientWhenExist.getSubnetGroupClient().list().toString(), new DescribeDBSubnetGroupsResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
// TODO: this should really be an empty set
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testListWhenResponseIs404() throws Exception {
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RDSClient clientWhenDontExist = requestSendsResponse(
|
||||
list, listResponse);
|
||||
|
||||
clientWhenDontExist.getSubnetGroupClient().list();
|
||||
}
|
||||
|
||||
public void testListWithOptionsWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listWithOptions =
|
||||
HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://rds.us-east-1.amazonaws.com/"))
|
||||
.headers(ImmutableMultimap.<String, String>builder()
|
||||
.put("Host", "rds.us-east-1.amazonaws.com")
|
||||
.build())
|
||||
.payload(payloadFromStringWithContentType(
|
||||
"Action=DescribeDBSubnetGroups" +
|
||||
"&Marker=MARKER" +
|
||||
"&Signature=1yK3VgSfUKDNHEwicyYbnMvSPAeJ7DZvi52gQeUUFSQ%3D" +
|
||||
"&SignatureMethod=HmacSHA256" +
|
||||
"&SignatureVersion=2" +
|
||||
"&Timestamp=2009-11-08T15%3A54%3A08.897Z" +
|
||||
"&Version=2012-04-23" +
|
||||
"&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded"))
|
||||
.build();
|
||||
|
||||
HttpResponse listWithOptionsResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/describe_subnetgroups.xml", "text/xml")).build();
|
||||
|
||||
RDSClient clientWhenWithOptionsExist = requestSendsResponse(listWithOptions,
|
||||
listWithOptionsResponse);
|
||||
|
||||
assertEquals(clientWhenWithOptionsExist.getSubnetGroupClient().list(afterMarker("MARKER")).toString(),
|
||||
new DescribeDBSubnetGroupsResponseTest().expected().toString());
|
||||
}
|
||||
|
||||
HttpRequest delete = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://rds.us-east-1.amazonaws.com/"))
|
||||
.headers(ImmutableMultimap.<String, String> builder()
|
||||
.put("Host", "rds.us-east-1.amazonaws.com")
|
||||
.build())
|
||||
.payload(
|
||||
payloadFromStringWithContentType(
|
||||
"Action=DeleteDBSubnetGroup" +
|
||||
"&DBSubnetGroupName=name" +
|
||||
"&Signature=BbT14zD9UyRQzelQYzg%2F0FVcX%2Fs46ZyRtyxsdylOw7o%3D" +
|
||||
"&SignatureMethod=HmacSHA256" +
|
||||
"&SignatureVersion=2" +
|
||||
"&Timestamp=2009-11-08T15%3A54%3A08.897Z" +
|
||||
"&Version=2012-04-23" +
|
||||
"&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded"))
|
||||
.build();
|
||||
|
||||
public void testDeleteWhenResponseIs2xx() throws Exception {
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(200).build();
|
||||
|
||||
RDSClient clientWhenExist = requestSendsResponse(delete, deleteResponse);
|
||||
|
||||
clientWhenExist.getSubnetGroupClient().delete("name");
|
||||
}
|
||||
|
||||
public void testDeleteWhenResponseIs404() throws Exception {
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RDSClient clientWhenDontExist = requestSendsResponse(delete, deleteResponse);
|
||||
|
||||
clientWhenDontExist.getSubnetGroupClient().delete("name");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.features;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.rds.domain.Subnet;
|
||||
import org.jclouds.rds.domain.SubnetGroup;
|
||||
import org.jclouds.rds.internal.BaseRDSClientLiveTest;
|
||||
import org.jclouds.rds.options.ListSubnetGroupsOptions;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", testName = "SubnetGroupClientLiveTest")
|
||||
public class SubnetGroupClientLiveTest extends BaseRDSClientLiveTest {
|
||||
|
||||
static void checkSubnetGroup(SubnetGroup subnetGroup) {
|
||||
checkNotNull(subnetGroup.getName(), "Name cannot be null for a SubnetGroup: %s", subnetGroup);
|
||||
checkNotNull(subnetGroup.getDescription(), "Description cannot be null for a SubnetGroup: %s", subnetGroup);
|
||||
checkNotNull(subnetGroup.getStatus(), "Status cannot be null for a SubnetGroup: %s", subnetGroup);
|
||||
checkState(subnetGroup.getSubnets().size() > 0, "Subnets must have at least one one: %s", subnetGroup);
|
||||
for (Subnet subnet : subnetGroup.getSubnets()) {
|
||||
checkSubnet(subnet);
|
||||
}
|
||||
}
|
||||
|
||||
static void checkSubnet(Subnet subnet) {
|
||||
checkNotNull(subnet.getId(), "Id cannot be null for a SubnetGroup: %s", subnet);
|
||||
checkNotNull(subnet.getStatus(), "Status cannot be null for a SubnetGroup: %s", subnet);
|
||||
checkNotNull(subnet.getAvailabilityZone(), "AvailabilityZone cannot be null for a SubnetGroup: %s", subnet);
|
||||
}
|
||||
|
||||
@Test
|
||||
protected void testDescribeSubnetGroups() {
|
||||
PaginatedIterable<SubnetGroup> response = client().list();
|
||||
|
||||
for (SubnetGroup subnetGroup : response) {
|
||||
checkSubnetGroup(subnetGroup);
|
||||
}
|
||||
|
||||
if (Iterables.size(response) > 0) {
|
||||
SubnetGroup subnetGroup = response.iterator().next();
|
||||
Assert.assertEquals(client().get(subnetGroup.getName()), subnetGroup);
|
||||
}
|
||||
|
||||
// Test with a Marker, even if it's null
|
||||
response = client().list(ListSubnetGroupsOptions.Builder.afterMarker(response.getNextMarker()));
|
||||
for (SubnetGroup subnetGroup : response) {
|
||||
checkSubnetGroup(subnetGroup);
|
||||
}
|
||||
}
|
||||
|
||||
protected SubnetGroupClient client() {
|
||||
return context.getApi().getSubnetGroupClient();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.internal;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.rds.RDSAsyncClient;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BaseRDSAsyncClientExpectTest extends BaseRDSExpectTest<RDSAsyncClient> {
|
||||
public RDSAsyncClient createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
|
||||
return createInjector(fn, module, props).getInstance(RDSAsyncClient.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.internal;
|
||||
|
||||
import org.jclouds.rds.RDSClient;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BaseRDSClientExpectTest extends BaseRDSExpectTest<RDSClient> {
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.internal;
|
||||
|
||||
import org.jclouds.apis.BaseContextLiveTest;
|
||||
import org.jclouds.rds.RDSApiMetadata;
|
||||
import org.jclouds.rds.RDSAsyncClient;
|
||||
import org.jclouds.rds.RDSClient;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live")
|
||||
public class BaseRDSClientLiveTest extends BaseContextLiveTest<RestContext<RDSClient, RDSAsyncClient>> {
|
||||
|
||||
public BaseRDSClientLiveTest() {
|
||||
provider = "rds";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypeToken<RestContext<RDSClient, RDSAsyncClient>> contextType() {
|
||||
return RDSApiMetadata.CONTEXT_TOKEN;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.internal;
|
||||
|
||||
import static com.google.common.collect.Maps.transformValues;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.aws.domain.Region;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.rds.config.RDSRestClientModule;
|
||||
import org.jclouds.location.config.LocationModule;
|
||||
import org.jclouds.location.suppliers.RegionIdToURISupplier;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.internal.BaseRestClientExpectTest;
|
||||
import org.jclouds.util.Suppliers2;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BaseRDSExpectTest<T> extends BaseRestClientExpectTest<T> {
|
||||
|
||||
public BaseRDSExpectTest() {
|
||||
provider = "rds";
|
||||
}
|
||||
|
||||
@ConfiguresRestClient
|
||||
private static final class TestRDSRestClientModule extends RDSRestClientModule {
|
||||
|
||||
@Override
|
||||
protected void installLocations() {
|
||||
install(new LocationModule());
|
||||
bind(RegionIdToURISupplier.class).toInstance(new RegionIdToURISupplier() {
|
||||
|
||||
@Override
|
||||
public Map<String, Supplier<URI>> get() {
|
||||
return transformValues(ImmutableMap.<String, URI> of(Region.EU_WEST_1, URI
|
||||
.create("https://rds.eu-west-1.amazonaws.com"), Region.US_EAST_1, URI
|
||||
.create("https://rds.us-east-1.amazonaws.com"), Region.US_WEST_1, URI
|
||||
.create("https://rds.us-west-1.amazonaws.com")), Suppliers2.<URI> ofInstanceFunction());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String provideTimeStamp(final DateService dateService) {
|
||||
return "2009-11-08T15:54:08.897Z";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Module createModule() {
|
||||
return new TestRDSRestClientModule();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.options;
|
||||
|
||||
import static org.jclouds.rds.options.ListInstancesOptions.Builder.afterMarker;
|
||||
import static org.jclouds.rds.options.ListInstancesOptions.Builder.name;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ListInstancesOptions}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ListInstancesOptionsTest")
|
||||
public class ListInstancesOptionsTest {
|
||||
|
||||
public void testMarker() {
|
||||
ListInstancesOptions options = new ListInstancesOptions().afterMarker("FFFFF");
|
||||
assertEquals(ImmutableSet.of("FFFFF"), options.buildFormParameters().get("Marker"));
|
||||
}
|
||||
|
||||
public void testMarkerStatic() {
|
||||
ListInstancesOptions options = afterMarker("FFFFF");
|
||||
assertEquals(ImmutableSet.of("FFFFF"), options.buildFormParameters().get("Marker"));
|
||||
}
|
||||
|
||||
public void testName() {
|
||||
ListInstancesOptions options = new ListInstancesOptions().name("my-load-balancer");
|
||||
assertEquals(ImmutableSet.of("my-load-balancer"), options.buildFormParameters().get("InstanceNames.member.1"));
|
||||
}
|
||||
|
||||
public void testNameStatic() {
|
||||
ListInstancesOptions options = name("my-load-balancer");
|
||||
assertEquals(ImmutableSet.of("my-load-balancer"), options.buildFormParameters().get("InstanceNames.member.1"));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.options;
|
||||
|
||||
import static org.jclouds.rds.options.ListSecurityGroupsOptions.Builder.afterMarker;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ListSecurityGroupsOptions}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ListSecurityGroupsOptionsTest")
|
||||
public class ListSecurityGroupsOptionsTest {
|
||||
|
||||
public void testMarker() {
|
||||
ListSecurityGroupsOptions options = new ListSecurityGroupsOptions().afterMarker("FFFFF");
|
||||
assertEquals(ImmutableSet.of("FFFFF"), options.buildFormParameters().get("Marker"));
|
||||
}
|
||||
|
||||
public void testMarkerStatic() {
|
||||
ListSecurityGroupsOptions options = afterMarker("FFFFF");
|
||||
assertEquals(ImmutableSet.of("FFFFF"), options.buildFormParameters().get("Marker"));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.options;
|
||||
|
||||
import static org.jclouds.rds.options.ListSubnetGroupsOptions.Builder.afterMarker;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ListSubnetGroupsOptions}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ListSubnetGroupsOptionsTest")
|
||||
public class ListSubnetGroupsOptionsTest {
|
||||
|
||||
public void testMarker() {
|
||||
ListSubnetGroupsOptions options = new ListSubnetGroupsOptions().afterMarker("FFFFF");
|
||||
assertEquals(ImmutableSet.of("FFFFF"), options.buildFormParameters().get("Marker"));
|
||||
}
|
||||
|
||||
public void testMarkerStatic() {
|
||||
ListSubnetGroupsOptions options = afterMarker("FFFFF");
|
||||
assertEquals(ImmutableSet.of("FFFFF"), options.buildFormParameters().get("Marker"));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.collect.PaginatedIterables;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.rds.domain.Instance;
|
||||
import org.jclouds.rds.xml.DescribeDBInstancesResultHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.HostAndPort;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "DescribeDBInstancesResponseTest")
|
||||
public class DescribeDBInstancesResponseTest extends BaseHandlerTest {
|
||||
protected final DateService dateService = new SimpleDateFormatDateService();
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/describe_instances.xml");
|
||||
|
||||
PaginatedIterable<Instance> expected = expected();
|
||||
|
||||
DescribeDBInstancesResultHandler handler = injector.getInstance(DescribeDBInstancesResultHandler.class);
|
||||
PaginatedIterable<Instance> result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result.toString(), expected.toString());
|
||||
|
||||
}
|
||||
|
||||
public PaginatedIterable<Instance> expected() {
|
||||
return PaginatedIterables.forward(ImmutableSet.<Instance>builder()
|
||||
.add(Instance.builder()
|
||||
.engine("mysql")
|
||||
.multiAZ(false)
|
||||
.licenseModel("general-public-license")
|
||||
.status("available")
|
||||
.engineVersion("5.1.50")
|
||||
.endpoint(HostAndPort.fromParts("simcoprod01.cu7u2t4uz396.us-east-1.rds.amazonaws.com", 3306))
|
||||
.id("simcoprod01")
|
||||
.securityGroupNameToStatus("default", "active")
|
||||
.availabilityZone("us-east-1a")
|
||||
.createdTime(dateService.iso8601DateParse("2011-05-23T06:06:43.110Z"))
|
||||
.allocatedStorageGB(10)
|
||||
.instanceClass("db.m1.large")
|
||||
.masterUsername("master").build()).build());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.collect.PaginatedIterables;
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.rds.domain.EC2SecurityGroup;
|
||||
import org.jclouds.rds.domain.IPRange;
|
||||
import org.jclouds.rds.domain.SecurityGroup;
|
||||
import org.jclouds.rds.xml.DescribeDBSecurityGroupsResultHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "DescribeDBSecurityGroupsResponseTest")
|
||||
public class DescribeDBSecurityGroupsResponseTest extends BaseHandlerTest {
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/describe_securitygroups.xml");
|
||||
|
||||
PaginatedIterable<SecurityGroup> expected = expected();
|
||||
|
||||
DescribeDBSecurityGroupsResultHandler handler = injector.getInstance(DescribeDBSecurityGroupsResultHandler.class);
|
||||
PaginatedIterable<SecurityGroup> result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result.toString(), expected.toString());
|
||||
|
||||
}
|
||||
|
||||
public PaginatedIterable<SecurityGroup> expected() {
|
||||
return PaginatedIterables.forward(ImmutableSet.<SecurityGroup>builder()
|
||||
.add(SecurityGroup.builder()
|
||||
.ec2SecurityGroup(EC2SecurityGroup.builder()
|
||||
.status("authorized")
|
||||
.name("myec2securitygroup")
|
||||
.ownerId("054794666394").build())
|
||||
.description("default")
|
||||
.ipRange(IPRange.builder().cidrIp("127.0.0.1/30").status("authorized").build())
|
||||
.ownerId("621567473609")
|
||||
.name("default")
|
||||
.vpcId("vpc-1ab2c3d4").build())
|
||||
.add(SecurityGroup.builder()
|
||||
.description("My new DBSecurityGroup")
|
||||
.ipRange(IPRange.builder().cidrIp("192.168.1.1/24").status("authorized").build())
|
||||
.ownerId("621567473609")
|
||||
.name("mydbsecuritygroup")
|
||||
.vpcId("vpc-1ab2c3d5").build())
|
||||
.add(SecurityGroup.builder()
|
||||
.description("My new DBSecurityGroup")
|
||||
.ownerId("621567473609")
|
||||
.name("mydbsecuritygroup4")
|
||||
.vpcId("vpc-1ab2c3d6").build()).build());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.collect.PaginatedIterable;
|
||||
import org.jclouds.collect.PaginatedIterables;
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.rds.domain.Subnet;
|
||||
import org.jclouds.rds.domain.SubnetGroup;
|
||||
import org.jclouds.rds.xml.DescribeDBSubnetGroupsResultHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "DescribeDBSubnetGroupsResponseTest")
|
||||
public class DescribeDBSubnetGroupsResponseTest extends BaseHandlerTest {
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/describe_subnetgroups.xml");
|
||||
|
||||
PaginatedIterable<SubnetGroup> expected = expected();
|
||||
|
||||
DescribeDBSubnetGroupsResultHandler handler = injector.getInstance(DescribeDBSubnetGroupsResultHandler.class);
|
||||
PaginatedIterable<SubnetGroup> result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result.toString(), expected.toString());
|
||||
|
||||
}
|
||||
|
||||
public PaginatedIterable<SubnetGroup> expected() {
|
||||
return PaginatedIterables.forward(ImmutableSet.<SubnetGroup>builder()
|
||||
.add(SubnetGroup.builder()
|
||||
.vpcId("990524496922")
|
||||
.status("Complete")
|
||||
.description("description")
|
||||
.name("subnet_grp1")
|
||||
.subnets(ImmutableSet.<Subnet>builder()
|
||||
.add(Subnet.builder()
|
||||
.status("Active")
|
||||
.id("subnet-7c5b4115")
|
||||
.availabilityZone("us-east-1c").build())
|
||||
.add(Subnet.builder()
|
||||
.status("Active")
|
||||
.id("subnet-7b5b4112")
|
||||
.availabilityZone("us-east-1b").build())
|
||||
.add(Subnet.builder()
|
||||
.status("Active")
|
||||
.id("subnet-3ea6bd57")
|
||||
.availabilityZone("us-east-1d").build()).build()).build())
|
||||
.add(SubnetGroup.builder()
|
||||
.vpcId("990524496922")
|
||||
.status("Complete")
|
||||
.description("description")
|
||||
.name("subnet_grp2")
|
||||
.subnets(ImmutableSet.<Subnet>builder()
|
||||
.add(Subnet.builder()
|
||||
.status("Active")
|
||||
.id("subnet-7c5b4115")
|
||||
.availabilityZone("us-east-1c").build())
|
||||
.add(Subnet.builder()
|
||||
.status("Active")
|
||||
.id("subnet-7b5b4112")
|
||||
.availabilityZone("us-east-1b").build())
|
||||
.add(Subnet.builder()
|
||||
.status("Active")
|
||||
.id("subnet-3ea6bd57")
|
||||
.availabilityZone("us-east-1d").build()).build()).build()).build());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.rds.domain.Instance;
|
||||
import org.jclouds.rds.xml.InstanceHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.net.HostAndPort;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "GetInstanceResponseTest")
|
||||
public class GetInstanceResponseTest extends BaseHandlerTest {
|
||||
protected final DateService dateService = new SimpleDateFormatDateService();
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/get_instance.xml");
|
||||
|
||||
Instance expected = expected();
|
||||
|
||||
InstanceHandler handler = injector.getInstance(InstanceHandler.class);
|
||||
Instance result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result.toString(), expected.toString());
|
||||
}
|
||||
|
||||
public Instance expected() {
|
||||
return Instance.builder()
|
||||
.engine("mysql")
|
||||
.multiAZ(false)
|
||||
.licenseModel("general-public-license")
|
||||
.status("available")
|
||||
.engineVersion("5.1.50")
|
||||
.endpoint(HostAndPort.fromParts("simcoprod01.cu7u2t4uz396.us-east-1.rds.amazonaws.com", 3306))
|
||||
.id("simcoprod01")
|
||||
.securityGroupNameToStatus("default", "active")
|
||||
.availabilityZone("us-east-1a")
|
||||
.createdTime(dateService.iso8601DateParse("2011-05-23T06:06:43.110Z"))
|
||||
.allocatedStorageGB(10)
|
||||
.instanceClass("db.m1.large")
|
||||
.masterUsername("master").build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.rds.domain.EC2SecurityGroup;
|
||||
import org.jclouds.rds.domain.IPRange;
|
||||
import org.jclouds.rds.domain.SecurityGroup;
|
||||
import org.jclouds.rds.xml.SecurityGroupHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "GetSecurityGroupResponseTest")
|
||||
public class GetSecurityGroupResponseTest extends BaseHandlerTest {
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/get_securitygroup.xml");
|
||||
|
||||
SecurityGroup expected = expected();
|
||||
|
||||
SecurityGroupHandler handler = injector.getInstance(SecurityGroupHandler.class);
|
||||
SecurityGroup result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result.toString(), expected.toString());
|
||||
}
|
||||
|
||||
public SecurityGroup expected() {
|
||||
return SecurityGroup.builder()
|
||||
.ec2SecurityGroup(EC2SecurityGroup.builder()
|
||||
.status("authorized")
|
||||
.name("myec2securitygroup")
|
||||
.ownerId("054794666394").build())
|
||||
.description("default")
|
||||
.ipRange(IPRange.builder().cidrIp("127.0.0.1/30").status("authorized").build())
|
||||
.ownerId("621567473609")
|
||||
.name("default")
|
||||
.vpcId("vpc-1ab2c3d4").build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.rds.parse;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.jclouds.rds.domain.Subnet;
|
||||
import org.jclouds.rds.domain.SubnetGroup;
|
||||
import org.jclouds.rds.xml.SubnetGroupHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "GetSubnetGroupResponseTest")
|
||||
public class GetSubnetGroupResponseTest extends BaseHandlerTest {
|
||||
|
||||
public void test() {
|
||||
InputStream is = getClass().getResourceAsStream("/get_subnetgroup.xml");
|
||||
|
||||
SubnetGroup expected = expected();
|
||||
|
||||
SubnetGroupHandler handler = injector.getInstance(SubnetGroupHandler.class);
|
||||
SubnetGroup result = factory.create(handler).parse(is);
|
||||
|
||||
assertEquals(result.toString(), expected.toString());
|
||||
}
|
||||
|
||||
public SubnetGroup expected() {
|
||||
return SubnetGroup.builder()
|
||||
.vpcId("990524496922")
|
||||
.status("Complete")
|
||||
.description("description")
|
||||
.name("subnet_grp1")
|
||||
.subnets(ImmutableSet.<Subnet>builder()
|
||||
.add(Subnet.builder()
|
||||
.status("Active")
|
||||
.id("subnet-7c5b4115")
|
||||
.availabilityZone("us-east-1c").build())
|
||||
.add(Subnet.builder()
|
||||
.status("Active")
|
||||
.id("subnet-7b5b4112")
|
||||
.availabilityZone("us-east-1b").build())
|
||||
.add(Subnet.builder()
|
||||
.status("Active")
|
||||
.id("subnet-3ea6bd57")
|
||||
.availabilityZone("us-east-1d").build()).build()).build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<DescribeDBInstancesResponse xmlns="http://rds.amazonaws.com/doc/2012-04-23/">
|
||||
<DescribeDBInstancesResult>
|
||||
<DBInstances>
|
||||
<DBInstance>
|
||||
<ReadReplicaDBInstanceIdentifiers/>
|
||||
<LatestRestorableTime>2011-05-23T06:50:00Z</LatestRestorableTime>
|
||||
<Engine>mysql</Engine>
|
||||
<PendingModifiedValues/>
|
||||
<BackupRetentionPeriod>1</BackupRetentionPeriod>
|
||||
<MultiAZ>false</MultiAZ>
|
||||
<LicenseModel>general-public-license</LicenseModel>
|
||||
<DBInstanceStatus>available</DBInstanceStatus>
|
||||
<EngineVersion>5.1.50</EngineVersion>
|
||||
<Endpoint>
|
||||
<Port>3306</Port>
|
||||
<Address>simcoprod01.cu7u2t4uz396.us-east-1.rds.amazonaws.com</Address>
|
||||
</Endpoint>
|
||||
<DBInstanceIdentifier>simcoprod01</DBInstanceIdentifier>
|
||||
<DBParameterGroups>
|
||||
<DBParameterGroup>
|
||||
<ParameterApplyStatus>in-sync</ParameterApplyStatus>
|
||||
<DBParameterGroupName>default.mysql5.1</DBParameterGroupName>
|
||||
</DBParameterGroup>
|
||||
</DBParameterGroups>
|
||||
<DBSecurityGroups>
|
||||
<DBSecurityGroup>
|
||||
<Status>active</Status>
|
||||
<DBSecurityGroupName>default</DBSecurityGroupName>
|
||||
</DBSecurityGroup>
|
||||
</DBSecurityGroups>
|
||||
<PreferredBackupWindow>00:00-00:30</PreferredBackupWindow>
|
||||
<AutoMinorVersionUpgrade>true</AutoMinorVersionUpgrade>
|
||||
<PreferredMaintenanceWindow>sat:07:30-sat:08:00</PreferredMaintenanceWindow>
|
||||
<AvailabilityZone>us-east-1a</AvailabilityZone>
|
||||
<InstanceCreateTime>2011-05-23T06:06:43.110Z</InstanceCreateTime>
|
||||
<AllocatedStorage>10</AllocatedStorage>
|
||||
<DBInstanceClass>db.m1.large</DBInstanceClass>
|
||||
<MasterUsername>master</MasterUsername>
|
||||
</DBInstance>
|
||||
</DBInstances>
|
||||
</DescribeDBInstancesResult>
|
||||
<ResponseMetadata>
|
||||
<RequestId>9135fff3-8509-11e0-bd9b-a7b1ece36d51</RequestId>
|
||||
</ResponseMetadata>
|
||||
</DescribeDBInstancesResponse>
|
|
@ -0,0 +1,49 @@
|
|||
<DescribeDBSecurityGroupsResponse xmlns="http://rds.amazonaws.com/doc/2012-04-23/">
|
||||
<DescribeDBSecurityGroupsResult>
|
||||
<DBSecurityGroups>
|
||||
<DBSecurityGroup>
|
||||
<EC2SecurityGroups>
|
||||
<EC2SecurityGroup>
|
||||
<Status>authorized</Status>
|
||||
<EC2SecurityGroupName>myec2securitygroup</EC2SecurityGroupName>
|
||||
<EC2SecurityGroupOwnerId>054794666394</EC2SecurityGroupOwnerId>
|
||||
</EC2SecurityGroup>
|
||||
</EC2SecurityGroups>
|
||||
<DBSecurityGroupDescription>default</DBSecurityGroupDescription>
|
||||
<IPRanges>
|
||||
<IPRange>
|
||||
<CIDRIP>127.0.0.1/30</CIDRIP>
|
||||
<Status>authorized</Status>
|
||||
</IPRange>
|
||||
</IPRanges>
|
||||
<OwnerId>621567473609</OwnerId>
|
||||
<DBSecurityGroupName>default</DBSecurityGroupName>
|
||||
<VpcId>vpc-1ab2c3d4</VpcId>
|
||||
</DBSecurityGroup>
|
||||
<DBSecurityGroup>
|
||||
<EC2SecurityGroups/>
|
||||
<DBSecurityGroupDescription>My new DBSecurityGroup</DBSecurityGroupDescription>
|
||||
<IPRanges>
|
||||
<IPRange>
|
||||
<CIDRIP>192.168.1.1/24</CIDRIP>
|
||||
<Status>authorized</Status>
|
||||
</IPRange>
|
||||
</IPRanges>
|
||||
<OwnerId>621567473609</OwnerId>
|
||||
<DBSecurityGroupName>mydbsecuritygroup</DBSecurityGroupName>
|
||||
<VpcId>vpc-1ab2c3d5</VpcId>
|
||||
</DBSecurityGroup>
|
||||
<DBSecurityGroup>
|
||||
<EC2SecurityGroups/>
|
||||
<DBSecurityGroupDescription>My new DBSecurityGroup</DBSecurityGroupDescription>
|
||||
<IPRanges/>
|
||||
<OwnerId>621567473609</OwnerId>
|
||||
<DBSecurityGroupName>mydbsecuritygroup4</DBSecurityGroupName>
|
||||
<VpcId>vpc-1ab2c3d6</VpcId>
|
||||
</DBSecurityGroup>
|
||||
</DBSecurityGroups>
|
||||
</DescribeDBSecurityGroupsResult>
|
||||
<ResponseMetadata>
|
||||
<RequestId>bbdad154-bf42-11de-86a4-97241dfaadff</RequestId>
|
||||
</ResponseMetadata>
|
||||
</DescribeDBSecurityGroupsResponse>
|
|
@ -0,0 +1,70 @@
|
|||
<DescribeDBSubnetGroupsResponse
|
||||
xmlns="http://rds.amazonaws.com/doc/2012-04-23/">
|
||||
<DescribeDBSubnetGroupsResult>
|
||||
<DBSubnetGroups>
|
||||
<DBSubnetGroup>
|
||||
<VpcId>990524496922</VpcId>
|
||||
<SubnetGroupStatus>Complete</SubnetGroupStatus>
|
||||
<DBSubnetGroupDescription>description
|
||||
</DBSubnetGroupDescription>
|
||||
<DBSubnetGroupName>subnet_grp1</DBSubnetGroupName>
|
||||
<Subnets>
|
||||
<Subnet>
|
||||
<SubnetStatus>Active</SubnetStatus>
|
||||
<SubnetIdentifier>subnet-7c5b4115</SubnetIdentifier>
|
||||
<SubnetAvailabilityZone>
|
||||
<Name>us-east-1c</Name>
|
||||
</SubnetAvailabilityZone>
|
||||
</Subnet>
|
||||
<Subnet>
|
||||
<SubnetStatus>Active</SubnetStatus>
|
||||
<SubnetIdentifier>subnet-7b5b4112</SubnetIdentifier>
|
||||
<SubnetAvailabilityZone>
|
||||
<Name>us-east-1b</Name>
|
||||
</SubnetAvailabilityZone>
|
||||
</Subnet>
|
||||
<Subnet>
|
||||
<SubnetStatus>Active</SubnetStatus>
|
||||
<SubnetIdentifier>subnet-3ea6bd57</SubnetIdentifier>
|
||||
<SubnetAvailabilityZone>
|
||||
<Name>us-east-1d</Name>
|
||||
</SubnetAvailabilityZone>
|
||||
</Subnet>
|
||||
</Subnets>
|
||||
</DBSubnetGroup>
|
||||
<DBSubnetGroup>
|
||||
<VpcId>990524496922</VpcId>
|
||||
<SubnetGroupStatus>Complete</SubnetGroupStatus>
|
||||
<DBSubnetGroupDescription>description
|
||||
</DBSubnetGroupDescription>
|
||||
<DBSubnetGroupName>subnet_grp2</DBSubnetGroupName>
|
||||
<Subnets>
|
||||
<Subnet>
|
||||
<SubnetStatus>Active</SubnetStatus>
|
||||
<SubnetIdentifier>subnet-7c5b4115</SubnetIdentifier>
|
||||
<SubnetAvailabilityZone>
|
||||
<Name>us-east-1c</Name>
|
||||
</SubnetAvailabilityZone>
|
||||
</Subnet>
|
||||
<Subnet>
|
||||
<SubnetStatus>Active</SubnetStatus>
|
||||
<SubnetIdentifier>subnet-7b5b4112</SubnetIdentifier>
|
||||
<SubnetAvailabilityZone>
|
||||
<Name>us-east-1b</Name>
|
||||
</SubnetAvailabilityZone>
|
||||
</Subnet>
|
||||
<Subnet>
|
||||
<SubnetStatus>Active</SubnetStatus>
|
||||
<SubnetIdentifier>subnet-3ea6bd57</SubnetIdentifier>
|
||||
<SubnetAvailabilityZone>
|
||||
<Name>us-east-1d</Name>
|
||||
</SubnetAvailabilityZone>
|
||||
</Subnet>
|
||||
</Subnets>
|
||||
</DBSubnetGroup>
|
||||
</DBSubnetGroups>
|
||||
</DescribeDBSubnetGroupsResult>
|
||||
<ResponseMetadata>
|
||||
<RequestId>31d0faee-229b-11e1-81f1-df3a2a803dad</RequestId>
|
||||
</ResponseMetadata>
|
||||
</DescribeDBSubnetGroupsResponse>
|
|
@ -0,0 +1,45 @@
|
|||
<DescribeDBInstancesResponse xmlns="http://rds.amazonaws.com/doc/2012-04-23/">
|
||||
<DescribeDBInstancesResult>
|
||||
<DBInstances>
|
||||
<DBInstance>
|
||||
<ReadReplicaDBInstanceIdentifiers/>
|
||||
<LatestRestorableTime>2011-05-23T06:50:00Z</LatestRestorableTime>
|
||||
<Engine>mysql</Engine>
|
||||
<PendingModifiedValues/>
|
||||
<BackupRetentionPeriod>1</BackupRetentionPeriod>
|
||||
<MultiAZ>false</MultiAZ>
|
||||
<LicenseModel>general-public-license</LicenseModel>
|
||||
<DBInstanceStatus>available</DBInstanceStatus>
|
||||
<EngineVersion>5.1.50</EngineVersion>
|
||||
<Endpoint>
|
||||
<Port>3306</Port>
|
||||
<Address>simcoprod01.cu7u2t4uz396.us-east-1.rds.amazonaws.com</Address>
|
||||
</Endpoint>
|
||||
<DBInstanceIdentifier>simcoprod01</DBInstanceIdentifier>
|
||||
<DBParameterGroups>
|
||||
<DBParameterGroup>
|
||||
<ParameterApplyStatus>in-sync</ParameterApplyStatus>
|
||||
<DBParameterGroupName>default.mysql5.1</DBParameterGroupName>
|
||||
</DBParameterGroup>
|
||||
</DBParameterGroups>
|
||||
<DBSecurityGroups>
|
||||
<DBSecurityGroup>
|
||||
<Status>active</Status>
|
||||
<DBSecurityGroupName>default</DBSecurityGroupName>
|
||||
</DBSecurityGroup>
|
||||
</DBSecurityGroups>
|
||||
<PreferredBackupWindow>00:00-00:30</PreferredBackupWindow>
|
||||
<AutoMinorVersionUpgrade>true</AutoMinorVersionUpgrade>
|
||||
<PreferredMaintenanceWindow>sat:07:30-sat:08:00</PreferredMaintenanceWindow>
|
||||
<AvailabilityZone>us-east-1a</AvailabilityZone>
|
||||
<InstanceCreateTime>2011-05-23T06:06:43.110Z</InstanceCreateTime>
|
||||
<AllocatedStorage>10</AllocatedStorage>
|
||||
<DBInstanceClass>db.m1.large</DBInstanceClass>
|
||||
<MasterUsername>master</MasterUsername>
|
||||
</DBInstance>
|
||||
</DBInstances>
|
||||
</DescribeDBInstancesResult>
|
||||
<ResponseMetadata>
|
||||
<RequestId>9135fff3-8509-11e0-bd9b-a7b1ece36d51</RequestId>
|
||||
</ResponseMetadata>
|
||||
</DescribeDBInstancesResponse>
|
|
@ -0,0 +1,28 @@
|
|||
<DescribeDBSecurityGroupsResponse xmlns="http://rds.amazonaws.com/doc/2012-04-23/">
|
||||
<DescribeDBSecurityGroupsResult>
|
||||
<DBSecurityGroups>
|
||||
<DBSecurityGroup>
|
||||
<EC2SecurityGroups>
|
||||
<EC2SecurityGroup>
|
||||
<Status>authorized</Status>
|
||||
<EC2SecurityGroupName>myec2securitygroup</EC2SecurityGroupName>
|
||||
<EC2SecurityGroupOwnerId>054794666394</EC2SecurityGroupOwnerId>
|
||||
</EC2SecurityGroup>
|
||||
</EC2SecurityGroups>
|
||||
<DBSecurityGroupDescription>default</DBSecurityGroupDescription>
|
||||
<IPRanges>
|
||||
<IPRange>
|
||||
<CIDRIP>127.0.0.1/30</CIDRIP>
|
||||
<Status>authorized</Status>
|
||||
</IPRange>
|
||||
</IPRanges>
|
||||
<OwnerId>621567473609</OwnerId>
|
||||
<DBSecurityGroupName>default</DBSecurityGroupName>
|
||||
<VpcId>vpc-1ab2c3d4</VpcId>
|
||||
</DBSecurityGroup>
|
||||
</DBSecurityGroups>
|
||||
</DescribeDBSecurityGroupsResult>
|
||||
<ResponseMetadata>
|
||||
<RequestId>bbdad154-bf42-11de-86a4-97241dfaadff</RequestId>
|
||||
</ResponseMetadata>
|
||||
</DescribeDBSecurityGroupsResponse>
|
|
@ -0,0 +1,40 @@
|
|||
<DescribeDBSubnetGroupsResponse
|
||||
xmlns="http://rds.amazonaws.com/doc/2012-04-23/">
|
||||
<DescribeDBSubnetGroupsResult>
|
||||
<DBSubnetGroups>
|
||||
<DBSubnetGroup>
|
||||
<VpcId>990524496922</VpcId>
|
||||
<SubnetGroupStatus>Complete</SubnetGroupStatus>
|
||||
<DBSubnetGroupDescription>description
|
||||
</DBSubnetGroupDescription>
|
||||
<DBSubnetGroupName>subnet_grp1</DBSubnetGroupName>
|
||||
<Subnets>
|
||||
<Subnet>
|
||||
<SubnetStatus>Active</SubnetStatus>
|
||||
<SubnetIdentifier>subnet-7c5b4115</SubnetIdentifier>
|
||||
<SubnetAvailabilityZone>
|
||||
<Name>us-east-1c</Name>
|
||||
</SubnetAvailabilityZone>
|
||||
</Subnet>
|
||||
<Subnet>
|
||||
<SubnetStatus>Active</SubnetStatus>
|
||||
<SubnetIdentifier>subnet-7b5b4112</SubnetIdentifier>
|
||||
<SubnetAvailabilityZone>
|
||||
<Name>us-east-1b</Name>
|
||||
</SubnetAvailabilityZone>
|
||||
</Subnet>
|
||||
<Subnet>
|
||||
<SubnetStatus>Active</SubnetStatus>
|
||||
<SubnetIdentifier>subnet-3ea6bd57</SubnetIdentifier>
|
||||
<SubnetAvailabilityZone>
|
||||
<Name>us-east-1d</Name>
|
||||
</SubnetAvailabilityZone>
|
||||
</Subnet>
|
||||
</Subnets>
|
||||
</DBSubnetGroup>
|
||||
</DBSubnetGroups>
|
||||
</DescribeDBSubnetGroupsResult>
|
||||
<ResponseMetadata>
|
||||
<RequestId>31d0faee-229b-11e1-81f1-df3a2a803dad</RequestId>
|
||||
</ResponseMetadata>
|
||||
</DescribeDBSubnetGroupsResponse>
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0"?>
|
||||
<configuration scan="false">
|
||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||
<file>target/test-data/jclouds.log</file>
|
||||
|
||||
<encoder>
|
||||
<Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="WIREFILE" class="ch.qos.logback.core.FileAppender">
|
||||
<file>target/test-data/jclouds-wire.log</file>
|
||||
|
||||
<encoder>
|
||||
<Pattern>%d %-5p [%c] [%thread] %m%n</Pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root>
|
||||
<level value="warn" />
|
||||
</root>
|
||||
|
||||
<logger name="org.jclouds">
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="FILE" />
|
||||
</logger>
|
||||
|
||||
<logger name="jclouds.wire">
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="WIREFILE" />
|
||||
</logger>
|
||||
|
||||
<logger name="jclouds.headers">
|
||||
<level value="DEBUG" />
|
||||
<appender-ref ref="WIREFILE" />
|
||||
</logger>
|
||||
|
||||
</configuration>
|
Loading…
Reference in New Issue