Issue 36: combined Attribute parameters

git-svn-id: http://jclouds.googlecode.com/svn/trunk@1418 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-06-11 21:01:42 +00:00
parent cb5c918918
commit e0b68edf7d
4 changed files with 43 additions and 47 deletions

View File

@ -233,6 +233,31 @@ sub build_contents {
} }
push @params, \%param; push @params, \%param;
} }
# Attribute query parameters come in as separate parameters, so
# we coallate them into one
my %attribute;
for ( 0 .. $#params ) {
my $param = $params[$_];
if ( $param->{name} =~ /Attribute=/ ) {
delete $params[$_];
if ( !defined %attribute ) {
$attribute{name} = "Attribute";
$attribute{type} = "String";
$attribute{optional} = "true";
$attribute{defaultValue} = "true";
}
my $enum = $attribute{valueMap};
$_ = $param->{name};
s/Attribute=//;
$enum->{$_} = $param->{desc};
$attribute{valueMap} = $enum;
}
}
if ( defined %attribute ) {
push @params, \%attribute;
}
return \@params; return \@params;
} }
@ -264,6 +289,7 @@ sub build_item {
return {}; return {};
} }
unless ( $class =~ /Response/ ) { unless ( $class =~ /Response/ ) {
#$tree->dump; #$tree->dump;
my ${descriptionDiv} = my ${descriptionDiv} =
$tree->look_down( '_tag', 'h2', 'id', $tree->look_down( '_tag', 'h2', 'id',

View File

@ -223,10 +223,8 @@ public class AmazonEC2QueryAPIExpectations {
"DeregisterImage", ImmutableSet.of("ImageId")).put( "DeregisterImage", ImmutableSet.of("ImageId")).put(
"ModifyImageAttribute", "ModifyImageAttribute",
ImmutableSet.of("Group.n", "UserId.n", "ImageId", "ProductCode.n", "Group.n", ImmutableSet.of("Group.n", "UserId.n", "ImageId", "ProductCode.n", "Group.n",
"UserId.n")).put( "UserId.n")).put("DescribeImageAttribute",
"DescribeImageAttribute", ImmutableSet.of("Attribute", "ImageId")).put("DescribeImages",
ImmutableSet.of("Attribute=productCodes", "ImageId", "Attribute=platform", "Attribute=blockDeviceMapping",
"Attribute=launchPermission", "Attribute=ramdisk", "Attribute=kernel")).put("DescribeImages",
ImmutableSet.of("explicit", "public", "implicit")).put( ImmutableSet.of("explicit", "public", "implicit")).put(
"DescribeAvailabilityZones", ImmutableSet.of("ZoneName")).put( "DescribeAvailabilityZones", ImmutableSet.of("ZoneName")).put(
"DescribeRegions", ImmutableSet.of("RegionName.n")).put("DeleteVolume", "DescribeRegions", ImmutableSet.of("RegionName.n")).put("DeleteVolume",

View File

@ -298,46 +298,18 @@
"defaultValue" : "None" "defaultValue" : "None"
}, },
{ {
"desc" : "Describes the launch permissions of the AMI.", "name" : "Attribute",
"name" : "Attribute=launchPermission",
"type" : "String", "type" : "String",
"optional" : "true", "optional" : "true",
"defaultValue" : "None" "defaultValue" : "true",
}, "valueMap" : {
{ "productCodes" : "Describes the product code associated with the AMI.",
"desc" : "Describes the product code associated with the AMI.", "ramdisk" : "Describes the ID of the RAM disk associated with the AMI.",
"name" : "Attribute=productCodes", "kernel" : "Describes the ID of the kernel associated with the AMI.",
"type" : "String", "launchPermission" : "Describes the launch permissions of the AMI.",
"optional" : "true", "platform" : "Describes the operating system platform.",
"defaultValue" : "None" "blockDeviceMapping" : "Describes the mapping that defines native device names to use when exposing virtual devices."
}, }
{
"desc" : "Describes the ID of the kernel associated with the AMI.",
"name" : "Attribute=kernel",
"type" : "String",
"optional" : "true",
"defaultValue" : "None"
},
{
"desc" : "Describes the ID of the RAM disk associated with the AMI.",
"name" : "Attribute=ramdisk",
"type" : "String",
"optional" : "true",
"defaultValue" : "None"
},
{
"desc" : "Describes the mapping that defines native device names to use when exposing virtual devices.",
"name" : "Attribute=blockDeviceMapping",
"type" : "String",
"optional" : "true",
"defaultValue" : "None"
},
{
"desc" : "Describes the operating system platform.",
"name" : "Attribute=platform",
"type" : "String",
"optional" : "true",
"defaultValue" : "None"
} }
], ],
"type" : "DescribeImageAttribute", "type" : "DescribeImageAttribute",
@ -716,8 +688,8 @@
"name" : "Availability Zones and Regions", "name" : "Availability Zones and Regions",
"queries" : { "queries" : {
"DescribeAvailabilityZones" : { "DescribeAvailabilityZones" : {
"exampleCode" : "https://ec2.amazonaws.com/?Action=DescribeAvailabilityZones&ZoneName.0=us-east-1a&ZoneName.1=us-east-1b&ZoneName.1=us-east-1c&AuthParams", "exampleCode" : "https://ec2.amazonaws.com/?Action=DescribeAvailabilityZones&ZoneName.0=us-east-1a&ZoneName.1=us-east-1b&ZoneName.2=us-east-1c&ZoneName.3=us-east-1d&AuthParams",
"exampleHTML" : "<div class=\"section\" lang=\"en\"><div class=\"titlepage\"><div><div><h3 class=\"title\" id=\"ApiReference-query-DescribeAvailabilityZones-Example-Request-1\">Example Request</h3></div></div></div><p>This example displays information about Availability Zones that are available to the account.<pre class=\"programlisting\">https://ec2.amazonaws.com/?Action=DescribeAvailabilityZones&amp;ZoneName.0=us-east-1a&amp;ZoneName.1=us-east-1b&amp;ZoneName.1=us-east-1c&amp;AuthParams</pre></div>\n", "exampleHTML" : "<div class=\"section\" lang=\"en\"><div class=\"titlepage\"><div><div><h3 class=\"title\" id=\"ApiReference-query-DescribeAvailabilityZones-Example-Request-1\">Example Request</h3></div></div></div><p>This example displays information about Availability Zones that are available to the account.<pre class=\"programlisting\">https://ec2.amazonaws.com/?Action=DescribeAvailabilityZones&amp;ZoneName.0=us-east-1a&amp;ZoneName.1=us-east-1b&amp;ZoneName.2=us-east-1c&amp;ZoneName.3=us-east-1d&amp;AuthParams</pre></div>\n",
"contents" : [ "contents" : [
{ {
"desc" : "Availability Zone name.", "desc" : "Availability Zone name.",
@ -2927,8 +2899,8 @@
] ]
}, },
"DescribeAvailabilityZonesResponse" : { "DescribeAvailabilityZonesResponse" : {
"exampleCode" : "<DescribeAvailabilityZonesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\n <availabilityZoneInfo>\n <item>\n <zoneName>us-east-1a</zoneName>\n <zoneState>available</zoneState>\n </item>\n <item>\n <zoneName>us-east-1b</zoneName>\n <zoneState>available</zoneState>\n </item>\n <item>\n <zoneName>us-east-1c</zoneName>\n <zoneState>available</zoneState>\n </item>\n </availabilityZoneInfo>\n</DescribeAvailabilityZonesResponse>", "exampleCode" : "<DescribeAvailabilityZonesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\n <availabilityZoneInfo>\n <item>\n <zoneName>us-east-1a</zoneName>\n <zoneState>available</zoneState>\n </item>\n <item>\n <zoneName>us-east-1b</zoneName>\n <zoneState>available</zoneState>\n </item>\n <item>\n <zoneName>us-east-1c</zoneName>\n <zoneState>available</zoneState>\n </item>\n <item>\n <zoneName>us-east-1d</zoneName>\n <zoneState>available</zoneState>\n </item>\n </availabilityZoneInfo>\n</DescribeAvailabilityZonesResponse>",
"exampleHTML" : "<div class=\"section\" lang=\"en\"><div class=\"titlepage\"><div><div><h3 class=\"title\" id=\"ApiReference-query-DescribeAvailabilityZones-Example-Response-1\">Example Response</h3></div></div></div><pre class=\"programlisting\">&lt;DescribeAvailabilityZonesResponse xmlns=&quot;http://ec2.amazonaws.com/doc/2009-04-04/&quot;&gt;\n &lt;availabilityZoneInfo&gt;\n &lt;item&gt;\n &lt;zoneName&gt;us-east-1a&lt;/zoneName&gt;\n &lt;zoneState&gt;available&lt;/zoneState&gt;\n &lt;/item&gt;\n &lt;item&gt;\n &lt;zoneName&gt;us-east-1b&lt;/zoneName&gt;\n &lt;zoneState&gt;available&lt;/zoneState&gt;\n &lt;/item&gt;\n &lt;item&gt;\n &lt;zoneName&gt;us-east-1c&lt;/zoneName&gt;\n &lt;zoneState&gt;available&lt;/zoneState&gt;\n &lt;/item&gt;\n &lt;/availabilityZoneInfo&gt;\n&lt;/DescribeAvailabilityZonesResponse&gt;</pre></div>\n", "exampleHTML" : "<div class=\"section\" lang=\"en\"><div class=\"titlepage\"><div><div><h3 class=\"title\" id=\"ApiReference-query-DescribeAvailabilityZones-Example-Response-1\">Example Response</h3></div></div></div><pre class=\"programlisting\">&lt;DescribeAvailabilityZonesResponse xmlns=&quot;http://ec2.amazonaws.com/doc/2009-04-04/&quot;&gt;\n &lt;availabilityZoneInfo&gt;\n &lt;item&gt;\n &lt;zoneName&gt;us-east-1a&lt;/zoneName&gt;\n &lt;zoneState&gt;available&lt;/zoneState&gt;\n &lt;/item&gt;\n &lt;item&gt;\n &lt;zoneName&gt;us-east-1b&lt;/zoneName&gt;\n &lt;zoneState&gt;available&lt;/zoneState&gt;\n &lt;/item&gt;\n &lt;item&gt;\n &lt;zoneName&gt;us-east-1c&lt;/zoneName&gt;\n &lt;zoneState&gt;available&lt;/zoneState&gt;\n &lt;/item&gt;\n &lt;item&gt;\n &lt;zoneName&gt;us-east-1d&lt;/zoneName&gt;\n &lt;zoneState&gt;available&lt;/zoneState&gt;\n &lt;/item&gt;\n &lt;/availabilityZoneInfo&gt;\n&lt;/DescribeAvailabilityZonesResponse&gt;</pre></div>\n",
"contents" : [ "contents" : [
{ {
"desc" : "Availability Zone information.", "desc" : "Availability Zone information.",

View File

@ -38,7 +38,7 @@ import org.testng.annotations.Test;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(testName = "ec2.AmazonEC2QueryAPIParser") @Test(testName = "ec2.AmazonEC2QueryAPIParserTest")
public class AmazonEC2QueryAPIParserTest extends AmazonEC2QueryAPIValidator { public class AmazonEC2QueryAPIParserTest extends AmazonEC2QueryAPIValidator {
@BeforeTest @BeforeTest
public void setUp() throws Exception { public void setUp() throws Exception {