From 5f3b8d3fa7e5ee0f17096138eb5f80919f8c350f Mon Sep 17 00:00:00 2001 From: Andrew Bayer Date: Mon, 1 Jul 2013 12:12:26 -0700 Subject: [PATCH] JCLOUDS-150 - Removal of async from AWS - specifically EC2 ...and EC2-related elsewhere. Also moved *Client -> *Api, and moved everything from .../services to .../features, and threw in a bunch of Optionals to fit the EC2Api approach. And a very big tip of the hat to nacx for figuring out the generics stuff my brain just could not handle. =) --- .../src/main/clojure/org/jclouds/ec2/ami2.clj | 6 +- .../clojure/org/jclouds/ec2/elastic_ip2.clj | 6 +- .../org/jclouds/ec2/security_group2.clj | 8 +- .../src/main/java/org/jclouds/ec2/EC2Api.java | 81 +++- .../java/org/jclouds/ec2/EC2ApiMetadata.java | 27 +- .../java/org/jclouds/ec2/EC2AsyncApi.java | 78 ---- .../java/org/jclouds/ec2/EC2AsyncClient.java | 87 ----- .../main/java/org/jclouds/ec2/EC2Client.java | 84 ---- .../ec2/compute/EC2ComputeService.java | 16 +- .../compute/extensions/EC2ImageExtension.java | 14 +- .../extensions/EC2SecurityGroupExtension.java | 34 +- .../functions/CreateUniqueKeyPair.java | 10 +- ...asswordCredentialsFromWindowsInstance.java | 10 +- .../compute/functions/PresentInstances.java | 8 +- .../loaders/CreateSecurityGroupIfNeeded.java | 12 +- .../LoadPublicIpForInstanceOrNull.java | 8 +- .../compute/loaders/RegionAndIdToImage.java | 8 +- .../predicates/SecurityGroupPresent.java | 8 +- .../strategy/DescribeImagesParallel.java | 42 +- .../EC2CreateNodesInGroupThenAddToSet.java | 12 +- .../strategy/EC2DestroyNodeStrategy.java | 12 +- .../compute/strategy/EC2GetImageStrategy.java | 8 +- .../strategy/EC2GetNodeMetadataStrategy.java | 8 +- .../strategy/EC2ListNodesStrategy.java | 10 +- .../strategy/EC2RebootNodeStrategy.java | 10 +- .../strategy/EC2ResumeNodeStrategy.java | 10 +- .../strategy/EC2SuspendNodeStrategy.java | 10 +- .../ec2/config/BaseEC2HttpApiModule.java | 78 ++++ .../jclouds/ec2/config/EC2HttpApiModule.java | 67 ++++ .../ec2/config/EC2RestClientModule.java | 134 ------- .../AMIClient.java => features/AMIApi.java} | 213 +++++++---- .../AvailabilityZoneAndRegionApi.java} | 26 +- .../ElasticBlockStoreApi.java} | 238 +++++++++--- .../ElasticIPAddressApi.java} | 72 +++- .../InstanceApi.java} | 322 ++++++++++++---- .../KeyPairApi.java} | 59 ++- .../SecurityGroupApi.java} | 95 ++++- .../org/jclouds/ec2/features/SubnetApi.java | 44 ++- .../jclouds/ec2/features/SubnetAsyncApi.java | 83 ---- .../java/org/jclouds/ec2/features/TagApi.java | 78 +++- .../org/jclouds/ec2/features/TagAsyncApi.java | 138 ------- .../org/jclouds/ec2/features/WindowsApi.java | 161 +++++++- .../jclouds/ec2/features/WindowsAsyncApi.java | 65 ---- .../BundleInstanceS3StorageOptions.java | 2 +- .../ec2/options/CreateImageOptions.java | 4 +- .../ec2/options/CreateSnapshotOptions.java | 4 +- .../DescribeAvailabilityZonesOptions.java | 4 +- .../ec2/options/DescribeImagesOptions.java | 4 +- .../ec2/options/DescribeRegionsOptions.java | 2 +- .../ec2/options/DescribeSnapshotsOptions.java | 4 +- .../ec2/options/DetachVolumeOptions.java | 4 +- .../RegisterImageBackedByEbsOptions.java | 2 +- .../ec2/options/RegisterImageOptions.java | 2 +- .../ec2/options/RunInstancesOptions.java | 2 +- .../ec2/predicates/InstanceHasIpAddress.java | 8 +- .../ec2/predicates/InstanceStateRunning.java | 8 +- .../ec2/predicates/InstanceStateStopped.java | 6 +- .../predicates/InstanceStateTerminated.java | 8 +- .../ec2/predicates/SnapshotCompleted.java | 6 +- .../ec2/predicates/VolumeAttached.java | 6 +- .../ec2/predicates/VolumeAvailable.java | 6 +- .../ec2/predicates/VolumeDetached.java | 6 +- .../jclouds/ec2/services/AMIAsyncClient.java | 192 ---------- .../AvailabilityZoneAndRegionClient.java | 57 --- .../ElasticBlockStoreAsyncClient.java | 239 ------------ .../services/ElasticIPAddressAsyncClient.java | 113 ------ .../ec2/services/InstanceAsyncClient.java | 361 ------------------ .../jclouds/ec2/services/KeyPairClient.java | 87 ----- .../services/SecurityGroupAsyncClient.java | 145 ------- .../ec2/services/WindowsAsyncClient.java | 112 ------ .../jclouds/ec2/services/WindowsClient.java | 116 ------ .../DescribeAvailabilityZonesInRegion.java | 10 +- .../DescribeRegionsForRegionURIs.java | 10 +- ...plicationArchitecturesEC2ApiLiveTest.java} | 92 ++--- ...veTest.java => EBSBootEC2ApiLiveTest.java} | 102 ++--- .../org/jclouds/ec2/EC2AsyncClientTest.java | 75 ---- .../BindS3UploadPolicyAndSignatureTest.java | 6 +- .../compute/EC2ComputeServiceLiveTest.java | 44 +-- .../compute/EC2TemplateBuilderLiveTest.java | 10 +- .../functions/CreateUniqueKeyPairTest.java | 21 +- .../functions/PresentInstancesTest.java | 11 +- ...aseEC2ComputeServiceContextExpectTest.java | 4 +- .../CreateSecurityGroupIfNeededTest.java | 8 +- .../LoadPublicIpForInstanceOrNullTest.java | 23 +- .../loaders/RegionAndIdToImageTest.java | 23 +- ...EC2CreateNodesInGroupThenAddToSetTest.java | 20 +- .../strategy/EC2DestroyNodeStrategyTest.java | 39 +- ...t.java => EC2HttpApiModuleExpectTest.java} | 6 +- .../AMIApiLiveTest.java} | 32 +- .../AMIApiTest.java} | 36 +- ...AvailabilityZoneAndRegionApiLiveTest.java} | 22 +- .../AvailabilityZoneAndRegionApiTest.java} | 18 +- .../BaseEC2ApiTest.java} | 23 +- .../EC2ElasticBlockStoreApiExpectTest.java} | 14 +- .../ElasticBlockStoreApiLiveTest.java} | 26 +- .../ElasticBlockStoreApiTest.java} | 36 +- .../ElasticIPAddressApiLiveTest.java} | 23 +- .../ElasticIPAddressApiTest.java} | 18 +- .../InstanceApiLiveTest.java} | 22 +- .../InstanceApiTest.java} | 56 +-- .../KeyPairApiLiveTest.java} | 22 +- .../KeyPairApiTest.java} | 14 +- .../SecurityGroupApiLiveTest.java} | 30 +- .../SecurityGroupApiTest.java} | 24 +- .../WindowsApiTest.java} | 16 +- .../ec2/internal/BaseEC2ApiExpectTest.java | 15 +- .../ec2/internal/BaseEC2ClientExpectTest.java | 64 ---- .../ec2/predicates/VolumeDetachedTest.java | 6 +- ...DescribeAvailabilityZonesInRegionTest.java | 23 +- .../{NovaEC2Client.java => NovaEC2Api.java} | 19 +- .../nova/ec2/NovaEC2ApiMetadata.java | 15 +- .../nova/ec2/NovaEC2AsyncClient.java | 38 -- .../nova/ec2/config/NovaEC2HttpApiModule.java | 81 ++++ .../ec2/config/NovaEC2RestClientModule.java | 118 ------ .../NovaEC2KeyPairApi.java} | 37 +- .../NovaCreateSecurityGroupIfNeeded.java | 6 +- .../services/NovaEC2KeyPairAsyncClient.java | 61 --- .../NovaEC2AMIApiExpectTest.java} | 14 +- .../NovaEC2AMIApiLiveTest.java} | 10 +- ...AvailabilityZoneAndRegionApiLiveTest.java} | 10 +- .../NovaEC2ElasticBlockStoreApiLiveTest.java} | 10 +- ...ovaEC2ElasticBlockStoreExpectApiTest.java} | 14 +- .../NovaEC2ElasticIPAddressApiLiveTest.java} | 10 +- .../NovaEC2InstanceApiExpectTest.java} | 12 +- .../NovaEC2InstanceApiLiveTest.java} | 10 +- .../NovaEC2KeyPairApiExpectTest.java} | 18 +- .../NovaEC2KeyPairApiLiveTest.java} | 15 +- .../NovaEC2SecurityGroupApiLiveTest.java | 32 ++ ...java => BaseNovaEC2RestApiExpectTest.java} | 19 +- ...ailabilityZoneAndRegionClientLiveTest.java | 32 -- .../java/org/jclouds/aws/ec2/AWSEC2Api.java | 120 ++++++ .../jclouds/aws/ec2/AWSEC2ApiMetadata.java | 15 +- .../jclouds/aws/ec2/AWSEC2AsyncClient.java | 86 ----- .../org/jclouds/aws/ec2/AWSEC2Client.java | 81 ---- .../aws/ec2/compute/AWSEC2ComputeService.java | 10 +- .../AWSEC2SecurityGroupExtension.java | 14 +- .../PresentSpotRequestsAndInstances.java | 8 +- .../AWSEC2CreateSecurityGroupIfNeeded.java | 20 +- .../AWSEC2CreateNodesInGroupThenAddToSet.java | 8 +- .../strategy/AWSEC2DestroyNodeStrategy.java | 10 +- .../AWSEC2GetNodeMetadataStrategy.java | 8 +- .../strategy/AWSEC2ListNodesStrategy.java | 10 +- .../aws/ec2/config/AWSEC2HttpApiModule.java | 98 +++++ .../ec2/config/AWSEC2RestClientModule.java | 159 -------- .../AWSAMIApi.java} | 57 ++- .../AWSInstanceApi.java} | 18 +- .../AWSKeyPairApi.java} | 37 +- .../AWSSecurityGroupApi.java} | 47 +-- .../MonitoringApi.java} | 35 +- .../PlacementGroupApi.java} | 59 ++- .../SpotInstanceApi.java} | 86 ++++- .../CreatePlacementGroupIfNeeded.java | 10 +- .../ImportOrReturnExistingKeypair.java | 12 +- .../ec2/options/AWSRunInstancesOptions.java | 2 +- .../options/CreateSecurityGroupOptions.java | 2 +- .../DescribeSpotPriceHistoryOptions.java | 2 +- .../options/RequestSpotInstancesOptions.java | 2 +- .../predicates/PlacementGroupAvailable.java | 8 +- .../ec2/predicates/PlacementGroupDeleted.java | 8 +- .../predicates/SpotInstanceRequestActive.java | 8 +- .../aws/ec2/services/AWSAMIClient.java | 85 ----- .../aws/ec2/services/AWSInstanceClient.java | 43 --- .../ec2/services/AWSKeyPairAsyncClient.java | 61 --- .../ec2/services/AWSSecurityGroupClient.java | 51 --- .../aws/ec2/services/MonitoringClient.java | 64 ---- .../ec2/services/PlacementGroupClient.java | 89 ----- .../ec2/services/SpotInstanceAsyncClient.java | 128 ------- .../aws/ec2/AWSEC2AsyncClientTest.java | 79 ---- .../compute/AWSEC2ComputeServiceLiveTest.java | 37 +- .../AWSEC2TemplateBuilderLiveTest.java | 12 +- .../AWSEC2ImageExtensionLiveTest.java | 6 +- .../PresentSpotRequestsAndInstancesTest.java | 31 +- .../BaseAWSEC2ComputeServiceExpectTest.java | 10 +- ...AWSEC2CreateSecurityGroupIfNeededTest.java | 4 +- .../AWSAMIApiLiveTest.java} | 10 +- .../AWSAMIApiTest.java} | 44 +-- .../AWSInstanceApiLiveTest.java} | 15 +- .../AWSInstanceApiTest.java} | 54 +-- .../AWSKeyPairApiLiveTest.java} | 22 +- .../AWSKeyPairApiTest.java} | 18 +- .../AWSSecurityGroupApiLiveTest.java} | 18 +- .../AWSSecurityGroupApiTest.java} | 26 +- .../BaseAWSEC2ApiTest.java} | 16 +- .../MonitoringApiLiveTest.java} | 13 +- .../MonitoringApiTest.java} | 12 +- .../PlacementGroupApiLiveTest.java} | 36 +- .../PlacementGroupApiTest.java} | 18 +- .../SpotInstanceApiLiveTest.java} | 34 +- .../SpotInstanceApiTest.java} | 14 +- .../features/TagSecurityGroupLiveTest.java | 8 +- .../ImportOrReturnExistingKeypairTest.java | 49 +-- 191 files changed, 2946 insertions(+), 4836 deletions(-) delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/EC2AsyncApi.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/EC2AsyncClient.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/EC2Client.java create mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/config/BaseEC2HttpApiModule.java create mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/config/EC2HttpApiModule.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java rename apis/ec2/src/main/java/org/jclouds/ec2/{services/AMIClient.java => features/AMIApi.java} (59%) rename apis/ec2/src/main/java/org/jclouds/ec2/{services/AvailabilityZoneAndRegionAsyncClient.java => features/AvailabilityZoneAndRegionApi.java} (75%) rename apis/ec2/src/main/java/org/jclouds/ec2/{services/ElasticBlockStoreClient.java => features/ElasticBlockStoreApi.java} (69%) rename apis/ec2/src/main/java/org/jclouds/ec2/{services/ElasticIPAddressClient.java => features/ElasticIPAddressApi.java} (59%) rename apis/ec2/src/main/java/org/jclouds/ec2/{services/InstanceClient.java => features/InstanceApi.java} (66%) rename apis/ec2/src/main/java/org/jclouds/ec2/{services/KeyPairAsyncClient.java => features/KeyPairApi.java} (59%) rename apis/ec2/src/main/java/org/jclouds/ec2/{services/SecurityGroupClient.java => features/SecurityGroupApi.java} (69%) delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/features/SubnetAsyncApi.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/features/TagAsyncApi.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/features/WindowsAsyncApi.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/services/AMIAsyncClient.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClient.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClient.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClient.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/services/InstanceAsyncClient.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/services/KeyPairClient.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/services/SecurityGroupAsyncClient.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/services/WindowsAsyncClient.java delete mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/services/WindowsClient.java rename apis/ec2/src/test/java/org/jclouds/ec2/{CloudApplicationArchitecturesEC2ClientLiveTest.java => CloudApplicationArchitecturesEC2ApiLiveTest.java} (78%) rename apis/ec2/src/test/java/org/jclouds/ec2/{EBSBootEC2ClientLiveTest.java => EBSBootEC2ApiLiveTest.java} (82%) delete mode 100644 apis/ec2/src/test/java/org/jclouds/ec2/EC2AsyncClientTest.java rename apis/ec2/src/test/java/org/jclouds/ec2/config/{EC2RestClientModuleExpectTest.java => EC2HttpApiModuleExpectTest.java} (97%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/AMIClientLiveTest.java => features/AMIApiLiveTest.java} (87%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/AMIAsyncClientTest.java => features/AMIApiTest.java} (94%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/AvailabilityZoneAndRegionClientLiveTest.java => features/AvailabilityZoneAndRegionApiLiveTest.java} (83%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/AvailabilityZoneAndRegionAsyncClientTest.java => features/AvailabilityZoneAndRegionApiTest.java} (91%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/BaseEC2AsyncClientTest.java => features/BaseEC2ApiTest.java} (89%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/EC2ElasticBlockStoreClientExpectTest.java => features/EC2ElasticBlockStoreApiExpectTest.java} (88%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/ElasticBlockStoreClientLiveTest.java => features/ElasticBlockStoreApiLiveTest.java} (91%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/ElasticBlockStoreAsyncClientTest.java => features/ElasticBlockStoreApiTest.java} (92%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/ElasticIPAddressClientLiveTest.java => features/ElasticIPAddressApiLiveTest.java} (79%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/ElasticIPAddressAsyncClientTest.java => features/ElasticIPAddressApiTest.java} (88%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/InstanceClientLiveTest.java => features/InstanceApiLiveTest.java} (77%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/InstanceAsyncClientTest.java => features/InstanceApiTest.java} (91%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/KeyPairClientLiveTest.java => features/KeyPairApiLiveTest.java} (85%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/KeyPairAsyncClientTest.java => features/KeyPairApiTest.java} (86%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/SecurityGroupClientLiveTest.java => features/SecurityGroupApiLiveTest.java} (92%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/SecurityGroupAsyncClientTest.java => features/SecurityGroupApiTest.java} (91%) rename apis/ec2/src/test/java/org/jclouds/ec2/{services/WindowsAsyncClientTest.java => features/WindowsApiTest.java} (92%) delete mode 100644 apis/ec2/src/test/java/org/jclouds/ec2/internal/BaseEC2ClientExpectTest.java rename apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/{NovaEC2Client.java => NovaEC2Api.java} (62%) delete mode 100644 apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2AsyncClient.java create mode 100644 apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2HttpApiModule.java delete mode 100644 apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java rename apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/{services/NovaEC2KeyPairClient.java => features/NovaEC2KeyPairApi.java} (63%) delete mode 100644 apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairAsyncClient.java rename apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/{services/NovaEC2AMIClientExpectTest.java => features/NovaEC2AMIApiExpectTest.java} (82%) rename apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/{services/NovaEC2AMIClientLiveTest.java => features/NovaEC2AMIApiLiveTest.java} (81%) rename apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/{services/NovaEC2ElasticBlockStoreClientLiveTest.java => features/NovaEC2AvailabilityZoneAndRegionApiLiveTest.java} (75%) rename apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/{services/NovaEC2ElasticIPAddressClientLiveTest.java => features/NovaEC2ElasticBlockStoreApiLiveTest.java} (77%) rename apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/{services/NovaEC2ElasticBlockStoreExpectClientTest.java => features/NovaEC2ElasticBlockStoreExpectApiTest.java} (83%) rename apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/{services/NovaEC2SecurityGroupClientLiveTest.java => features/NovaEC2ElasticIPAddressApiLiveTest.java} (78%) rename apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/{services/NovaEC2InstanceClientExpectTest.java => features/NovaEC2InstanceApiExpectTest.java} (87%) rename apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/{services/NovaEC2InstanceClientLiveTest.java => features/NovaEC2InstanceApiLiveTest.java} (79%) rename apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/{services/NovaEC2KeyPairClientExpectTest.java => features/NovaEC2KeyPairApiExpectTest.java} (88%) rename apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/{services/NovaEC2KeyPairClientLiveTest.java => features/NovaEC2KeyPairApiLiveTest.java} (89%) create mode 100644 apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2SecurityGroupApiLiveTest.java rename apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/internal/{BaseNovaEC2RestClientExpectTest.java => BaseNovaEC2RestApiExpectTest.java} (81%) delete mode 100644 apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2AvailabilityZoneAndRegionClientLiveTest.java create mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java delete mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2AsyncClient.java delete mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Client.java create mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java delete mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java rename providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/{services/AWSAMIAsyncClient.java => features/AWSAMIApi.java} (62%) rename providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/{services/AWSInstanceAsyncClient.java => features/AWSInstanceApi.java} (85%) rename providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/{services/AWSKeyPairClient.java => features/AWSKeyPairApi.java} (64%) rename providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/{services/AWSSecurityGroupAsyncClient.java => features/AWSSecurityGroupApi.java} (77%) rename providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/{services/MonitoringAsyncClient.java => features/MonitoringApi.java} (69%) rename providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/{services/PlacementGroupAsyncClient.java => features/PlacementGroupApi.java} (60%) rename providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/{services/SpotInstanceClient.java => features/SpotInstanceApi.java} (62%) delete mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSAMIClient.java delete mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSInstanceClient.java delete mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClient.java delete mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClient.java delete mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/MonitoringClient.java delete mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/PlacementGroupClient.java delete mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClient.java delete mode 100644 providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2AsyncClientTest.java rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/AWSAMIClientLiveTest.java => features/AWSAMIApiLiveTest.java} (90%) rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/AWSAMIAsyncClientTest.java => features/AWSAMIApiTest.java} (92%) rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/AWSInstanceClientLiveTest.java => features/AWSInstanceApiLiveTest.java} (78%) rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/AWSInstanceAsyncClientTest.java => features/AWSInstanceApiTest.java} (90%) rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/AWSKeyPairClientLiveTest.java => features/AWSKeyPairApiLiveTest.java} (90%) rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/AWSKeyPairAsyncClientTest.java => features/AWSKeyPairApiTest.java} (87%) rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/AWSSecurityGroupClientLiveTest.java => features/AWSSecurityGroupApiLiveTest.java} (81%) rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/AWSSecurityGroupAsyncClientTest.java => features/AWSSecurityGroupApiTest.java} (88%) rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/BaseAWSEC2AsyncClientTest.java => features/BaseAWSEC2ApiTest.java} (90%) rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/MonitoringClientLiveTest.java => features/MonitoringApiLiveTest.java} (85%) rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/MonitoringAsyncClientTest.java => features/MonitoringApiTest.java} (85%) rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/PlacementGroupClientLiveTest.java => features/PlacementGroupApiLiveTest.java} (83%) rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/PlacementGroupAsyncClientTest.java => features/PlacementGroupApiTest.java} (88%) rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/SpotInstanceClientLiveTest.java => features/SpotInstanceApiLiveTest.java} (84%) rename providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/{services/SpotInstanceAsyncClientTest.java => features/SpotInstanceApiTest.java} (87%) diff --git a/apis/ec2/src/main/clojure/org/jclouds/ec2/ami2.clj b/apis/ec2/src/main/clojure/org/jclouds/ec2/ami2.clj index 5d6f666a52..d58eb6bc80 100644 --- a/apis/ec2/src/main/clojure/org/jclouds/ec2/ami2.clj +++ b/apis/ec2/src/main/clojure/org/jclouds/ec2/ami2.clj @@ -21,12 +21,12 @@ org.jclouds.ec2.ami2 (:use org.jclouds.compute2) (:import org.jclouds.aws.domain.Region - org.jclouds.ec2.services.AMIClient + org.jclouds.ec2.features.AMIApi org.jclouds.ec2.options.CreateImageOptions org.jclouds.compute.domain.NodeMetadata (org.jclouds.ec2.domain Volume Volume$Status Snapshot Snapshot$Status AvailabilityZoneInfo))) -(defn ^org.jclouds.ec2.services.AMIClient +(defn ^org.jclouds.ec2.features.AMIApi ami-service "" [compute] @@ -34,7 +34,7 @@ .getContext .getProviderSpecificContext .getApi - .getAMIServices)) + .getAMIApi().get)) (defn get-region "Coerces the first parameter into a Region string; strings, keywords, and diff --git a/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj b/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj index a5daf1510c..68c372f831 100644 --- a/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj +++ b/apis/ec2/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj @@ -24,12 +24,12 @@ (:import org.jclouds.compute.domain.NodeMetadata (org.jclouds.ec2.domain PublicIpInstanceIdPair))) -(defn ^org.jclouds.ec2.services.ElasticIPAddressClient +(defn ^org.jclouds.ec2.features.ElasticIPAddressApi eip-service - "Returns an ElasticIPAddressClient for the given ComputeService" + "Returns an ElasticIPAddressApi for the given ComputeService" [compute] (-> compute - .getContext .getProviderSpecificContext .getApi .getElasticIPAddressServices)) + .getContext .getProviderSpecificContext .getApi .getElasticIPAddressApi().get)) (defn allocate "Claims a new elastic IP address within the (optionally) specified region for your account. diff --git a/apis/ec2/src/main/clojure/org/jclouds/ec2/security_group2.clj b/apis/ec2/src/main/clojure/org/jclouds/ec2/security_group2.clj index a6bc49cabe..a4f33cfd6c 100644 --- a/apis/ec2/src/main/clojure/org/jclouds/ec2/security_group2.clj +++ b/apis/ec2/src/main/clojure/org/jclouds/ec2/security_group2.clj @@ -22,14 +22,14 @@ (:require (org.jclouds [compute2 :as compute]) [org.jclouds.ec2.ebs2 :as ebs]) (:import org.jclouds.ec2.domain.SecurityGroup - org.jclouds.ec2.services.SecurityGroupClient + org.jclouds.ec2.features.SecurityGroupApi org.jclouds.net.domain.IpProtocol)) -(defn #^SecurityGroupClient +(defn #^SecurityGroupApi sg-service - "Returns the SecurityGroup Client associated with the specified compute service." + "Returns the SecurityGroup Api associated with the specified compute service." [compute] - (-> compute .getContext .getProviderSpecificContext .getApi .getSecurityGroupServices)) + (-> compute .getContext .getProviderSpecificContext .getApi .getSecurityGroupApi().get)) (defn create-group "Creates a new security group. diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/EC2Api.java b/apis/ec2/src/main/java/org/jclouds/ec2/EC2Api.java index 26cf10ec2b..d8637e8487 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/EC2Api.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/EC2Api.java @@ -21,6 +21,13 @@ import java.util.Set; import org.jclouds.ec2.features.SubnetApi; import org.jclouds.ec2.features.TagApi; import org.jclouds.ec2.features.WindowsApi; +import org.jclouds.ec2.features.AMIApi; +import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi; +import org.jclouds.ec2.features.ElasticBlockStoreApi; +import org.jclouds.ec2.features.ElasticIPAddressApi; +import org.jclouds.ec2.features.InstanceApi; +import org.jclouds.ec2.features.KeyPairApi; +import org.jclouds.ec2.features.SecurityGroupApi; import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.Region; import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; @@ -42,12 +49,11 @@ import com.google.inject.Provides; * Example * *
- * Optional<? extends WindowsApi> windowsOption = ec2Client.getWindowsApi();
+ * Optional<? extends WindowsApi> windowsOption = ec2Api.getWindowsApi();
  * checkState(windowsOption.isPresent(), "windows feature required, but not present");
  * 
* * @author Adrian Cole - * @see EC2AsyncApi */ public interface EC2Api extends Closeable { /** @@ -87,4 +93,75 @@ public interface EC2Api extends Closeable { @Delegate Optional getSubnetApiForRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * Provides synchronous access to AMI services. + */ + @Delegate + Optional getAMIApi(); + + @Delegate + Optional getAMIApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + + /** + * Provides synchronous access to Elastic IP Address services. + */ + @Delegate + Optional getElasticIPAddressApi(); + + @Delegate + Optional getElasticIPAddressApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * Provides synchronous access to Instance services. + */ + @Delegate + Optional getInstanceApi(); + + @Delegate + Optional getInstanceApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * Provides synchronous access to KeyPair services. + */ + @Delegate + Optional getKeyPairApi(); + + @Delegate + Optional getKeyPairApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * Provides synchronous access to SecurityGroup services. + */ + @Delegate + Optional getSecurityGroupApi(); + + @Delegate + Optional getSecurityGroupApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * Provides synchronous access to Availability Zones and Regions services. + */ + @Delegate + Optional getAvailabilityZoneAndRegionApi(); + + @Delegate + Optional getAvailabilityZoneAndRegionApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * Provides synchronous access to Elastic Block Store services. + */ + @Delegate + Optional getElasticBlockStoreApi(); + + @Delegate + Optional getElasticBlockStoreApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java b/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java index f380d464b3..47fc54ba18 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java @@ -31,8 +31,8 @@ import org.jclouds.apis.ApiMetadata; import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule; import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; -import org.jclouds.ec2.config.EC2RestClientModule; -import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.ec2.config.EC2HttpApiModule; +import org.jclouds.rest.internal.BaseHttpApiMetadata; import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; @@ -55,16 +55,8 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class EC2ApiMetadata extends BaseRestApiMetadata { +public class EC2ApiMetadata extends BaseHttpApiMetadata { - /** - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(EC2Client.class)} as - * {@link EC2AsyncClient} interface will be removed in jclouds 1.7. - */ - @Deprecated - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; @Override public Builder toBuilder() { @@ -80,7 +72,7 @@ public class EC2ApiMetadata extends BaseRestApiMetadata { } public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); + Properties properties = BaseHttpApiMetadata.defaultProperties(); properties.setProperty(PROPERTY_AUTH_TAG, "AWS"); properties.setProperty(PROPERTY_HEADER_TAG, "amz"); properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "*"); @@ -91,14 +83,8 @@ public class EC2ApiMetadata extends BaseRestApiMetadata { return properties; } - public abstract static class Builder> extends BaseRestApiMetadata.Builder { - @SuppressWarnings("deprecation") + public abstract static class Builder> extends BaseHttpApiMetadata.Builder { protected Builder() { - this(EC2Client.class, EC2AsyncClient.class); - } - - protected Builder(Class syncClient, Class asyncClient) { - super(syncClient, asyncClient); id("ec2") .name("Amazon Elastic Compute Cloud (EC2) API") .identityName("Access Key ID") @@ -107,9 +93,8 @@ public class EC2ApiMetadata extends BaseRestApiMetadata { .documentation(URI.create("http://docs.amazonwebservices.com/AWSEC2/latest/APIReference")) .version("2010-06-15") .defaultProperties(EC2ApiMetadata.defaultProperties()) - .context(CONTEXT_TOKEN) .view(EC2ComputeServiceContext.class) - .defaultModules(ImmutableSet.>of(EC2RestClientModule.class, EC2ResolveImagesModule.class, EC2ComputeServiceContextModule.class)); + .defaultModules(ImmutableSet.>of(EC2HttpApiModule.class, EC2ResolveImagesModule.class, EC2ComputeServiceContextModule.class)); } @Override diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/EC2AsyncApi.java b/apis/ec2/src/main/java/org/jclouds/ec2/EC2AsyncApi.java deleted file mode 100644 index e96c0a7bff..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/EC2AsyncApi.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2; - -import java.io.Closeable; -import java.util.Set; - -import org.jclouds.ec2.features.SubnetAsyncApi; -import org.jclouds.ec2.features.TagAsyncApi; -import org.jclouds.ec2.features.WindowsAsyncApi; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.Region; -import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.EndpointParam; - -import com.google.common.base.Optional; -import com.google.inject.Provides; - -/** - * Refer to javadoc for {@link EC2Api}, as this interface is the same, except - * features provide asynchronous return values. - * - * @author Adrian Cole - */ -public interface EC2AsyncApi extends Closeable { - /** - * - * @return the Region codes configured - */ - @Provides - @Region - Set getConfiguredRegions(); - - /** - * Provides asynchronous access to Windows features. - */ - @Delegate - Optional getWindowsApi(); - - @Delegate - Optional getWindowsApiForRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); - - /** - * Provides asynchronous access to Tag features. - */ - @Delegate - Optional getTagApi(); - - @Delegate - Optional getTagApiForRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); - - /** - * Provides asynchronous access to Subnet features. - */ - @Delegate - Optional getSubnetApi(); - - @Delegate - Optional getSubnetApiForRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/EC2AsyncClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/EC2AsyncClient.java deleted file mode 100644 index 9b1143eca7..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/EC2AsyncClient.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2; - -import org.jclouds.ec2.services.AMIAsyncClient; -import org.jclouds.ec2.services.AvailabilityZoneAndRegionAsyncClient; -import org.jclouds.ec2.services.ElasticBlockStoreAsyncClient; -import org.jclouds.ec2.services.ElasticIPAddressAsyncClient; -import org.jclouds.ec2.services.InstanceAsyncClient; -import org.jclouds.ec2.services.KeyPairAsyncClient; -import org.jclouds.ec2.services.SecurityGroupAsyncClient; -import org.jclouds.ec2.services.WindowsAsyncClient; -import org.jclouds.rest.annotations.Delegate; - -/** - * Provides asynchronous access to EC2 services. - * - * @author Adrian Cole - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(EC2Client.class)} as - * {@link EC2AsyncClient} interface will be removed in jclouds 1.7. - */ -@Deprecated -public interface EC2AsyncClient extends EC2AsyncApi { - - /** - * Provides asynchronous access to AMI services. - */ - @Delegate - AMIAsyncClient getAMIServices(); - - /** - * Provides asynchronous access to Elastic IP Address services. - */ - @Delegate - ElasticIPAddressAsyncClient getElasticIPAddressServices(); - - /** - * Provides asynchronous access to Instance services. - */ - @Delegate - InstanceAsyncClient getInstanceServices(); - - /** - * Provides asynchronous access to KeyPair services. - */ - @Delegate - KeyPairAsyncClient getKeyPairServices(); - - /** - * Provides asynchronous access to SecurityGroup services. - */ - @Delegate - SecurityGroupAsyncClient getSecurityGroupServices(); - - /** - * Provides asynchronous access to Windows services. - */ - @Delegate - WindowsAsyncClient getWindowsServices(); - - /** - * Provides asynchronous access to Availability Zones and Regions services. - */ - @Delegate - AvailabilityZoneAndRegionAsyncClient getAvailabilityZoneAndRegionServices(); - - /** - * Provides asynchronous access to Elastic Block Store services. - */ - @Delegate - ElasticBlockStoreAsyncClient getElasticBlockStoreServices(); - -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/EC2Client.java b/apis/ec2/src/main/java/org/jclouds/ec2/EC2Client.java deleted file mode 100644 index 42d1a4cf24..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/EC2Client.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2; - -import org.jclouds.ec2.services.AMIClient; -import org.jclouds.ec2.services.AvailabilityZoneAndRegionClient; -import org.jclouds.ec2.services.ElasticBlockStoreClient; -import org.jclouds.ec2.services.ElasticIPAddressClient; -import org.jclouds.ec2.services.InstanceClient; -import org.jclouds.ec2.services.KeyPairClient; -import org.jclouds.ec2.services.SecurityGroupClient; -import org.jclouds.ec2.services.WindowsClient; -import org.jclouds.rest.annotations.Delegate; - -/** - * Provides synchronous access to EC2 services. - * - * @author Adrian Cole - */ -public interface EC2Client extends EC2Api { - - /** - * Provides synchronous access to AMI services. - */ - @Delegate - AMIClient getAMIServices(); - - /** - * Provides synchronous access to Elastic IP Address services. - */ - @Delegate - ElasticIPAddressClient getElasticIPAddressServices(); - - /** - * Provides synchronous access to Instance services. - */ - @Delegate - InstanceClient getInstanceServices(); - - /** - * Provides synchronous access to KeyPair services. - */ - @Delegate - KeyPairClient getKeyPairServices(); - - /** - * Provides synchronous access to SecurityGroup services. - */ - @Delegate - SecurityGroupClient getSecurityGroupServices(); - - /** - * Provides asynchronous access to Windows services. - */ - @Delegate - WindowsClient getWindowsServices(); - - /** - * Provides synchronous access to Availability Zones and Regions services. - */ - @Delegate - AvailabilityZoneAndRegionClient getAvailabilityZoneAndRegionServices(); - - /** - * Provides synchronous access to Elastic Block Store services. - */ - @Delegate - ElasticBlockStoreClient getElasticBlockStoreServices(); - -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java index c62a259d70..4c019a42b4 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java @@ -73,7 +73,7 @@ import org.jclouds.compute.strategy.ResumeNodeStrategy; import org.jclouds.compute.strategy.SuspendNodeStrategy; import org.jclouds.domain.Credentials; import org.jclouds.domain.Location; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules; import org.jclouds.ec2.compute.options.EC2TemplateOptions; @@ -104,7 +104,7 @@ import com.google.inject.Inject; */ @Singleton public class EC2ComputeService extends BaseComputeService { - private final EC2Client client; + private final EC2Api client; private final ConcurrentMap credentialsMap; private final LoadingCache securityGroupMap; private final Factory namingConvention; @@ -125,7 +125,7 @@ public class EC2ComputeService extends BaseComputeService { InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory, RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess, PersistNodeCredentials persistNodeCredentials, Timeouts timeouts, - @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, EC2Client client, + @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, EC2Api client, ConcurrentMap credentialsMap, @Named("SECURITY") LoadingCache securityGroupMap, Optional imageExtension, GroupNamingConvention.Factory namingConvention, @@ -212,9 +212,9 @@ public class EC2ComputeService extends BaseComputeService { checkNotNull(emptyToNull(group), "group must be defined"); String groupName = namingConvention.create().sharedNameForGroup(group); - if (client.getSecurityGroupServices().describeSecurityGroupsInRegion(region, groupName).size() > 0) { + if (client.getSecurityGroupApi().get().describeSecurityGroupsInRegion(region, groupName).size() > 0) { logger.debug(">> deleting securityGroup(%s)", groupName); - client.getSecurityGroupServices().deleteSecurityGroupInRegion(region, groupName); + client.getSecurityGroupApi().get().deleteSecurityGroupInRegion(region, groupName); // TODO: test this clear happens securityGroupMap.invalidate(new RegionNameAndIngressRules(region, groupName, null, false)); logger.debug("<< deleted securityGroup(%s)", groupName); @@ -223,20 +223,20 @@ public class EC2ComputeService extends BaseComputeService { @VisibleForTesting void deleteKeyPair(String region, String group) { - for (KeyPair keyPair : client.getKeyPairServices().describeKeyPairsInRegion(region)) { + for (KeyPair keyPair : client.getKeyPairApi().get().describeKeyPairsInRegion(region)) { String keyName = keyPair.getKeyName(); Predicate keyNameMatcher = namingConvention.create().containsGroup(group); String oldKeyNameRegex = String.format("jclouds#%s#%s#%s", group, region, "[0-9a-f]+").replace('#', delimiter); // old keypair pattern too verbose as it has an unnecessary region qualifier if (keyNameMatcher.apply(keyName) || keyName.matches(oldKeyNameRegex)) { - Set instancesUsingKeyPair = extractIdsFromInstances(filter(concat(client.getInstanceServices() + Set instancesUsingKeyPair = extractIdsFromInstances(filter(concat(client.getInstanceApi().get() .describeInstancesInRegion(region)), usingKeyPairAndNotDead(keyPair))); if (instancesUsingKeyPair.size() > 0) { logger.debug("<< inUse keyPair(%s), by (%s)", keyPair.getKeyName(), instancesUsingKeyPair); } else { logger.debug(">> deleting keyPair(%s)", keyPair.getKeyName()); - client.getKeyPairServices().deleteKeyPairInRegion(region, keyPair.getKeyName()); + client.getKeyPairApi().get().deleteKeyPairInRegion(region, keyPair.getKeyName()); // TODO: test this clear happens credentialsMap.remove(new RegionAndName(region, keyPair.getKeyName())); credentialsMap.remove(new RegionAndName(region, group)); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/extensions/EC2ImageExtension.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/extensions/EC2ImageExtension.java index 3969453abf..fe3dc9bc64 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/extensions/EC2ImageExtension.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/extensions/EC2ImageExtension.java @@ -44,7 +44,7 @@ import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.extensions.ImageExtension; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.Location; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.ec2.options.CreateImageOptions; @@ -69,16 +69,16 @@ public class EC2ImageExtension implements ImageExtension { @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) protected Logger logger = Logger.NULL; - private final EC2Client ec2Client; + private final EC2Api ec2Api; private final ListeningExecutorService userExecutor; private final Supplier> locations; private final Predicate> imageAvailablePredicate; @Inject - public EC2ImageExtension(EC2Client ec2Client, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, + public EC2ImageExtension(EC2Api ec2Api, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, @Memoized Supplier> locations, @Named(TIMEOUT_IMAGE_AVAILABLE) Predicate> imageAvailablePredicate) { - this.ec2Client = checkNotNull(ec2Client, "ec2Client"); + this.ec2Api = checkNotNull(ec2Api, "ec2Api"); this.userExecutor = checkNotNull(userExecutor, "userExecutor"); this.locations = checkNotNull(locations, "locations"); this.imageAvailablePredicate = checkNotNull(imageAvailablePredicate, "imageAvailablePredicate"); @@ -89,7 +89,7 @@ public class EC2ImageExtension implements ImageExtension { String[] parts = AWSUtils.parseHandle(id); String region = parts[0]; String instanceId = parts[1]; - Reservation instance = getOnlyElement(ec2Client.getInstanceServices() + Reservation instance = getOnlyElement(ec2Api.getInstanceApi().get() .describeInstancesInRegion(region, instanceId)); if (instance == null) throw new NoSuchElementException("Cannot find server with id: " + id); @@ -105,7 +105,7 @@ public class EC2ImageExtension implements ImageExtension { String region = parts[0]; String instanceId = parts[1]; - String imageId = ec2Client.getAMIServices().createImageInRegion(region, cloneTemplate.getName(), instanceId, + String imageId = ec2Api.getAMIApi().get().createImageInRegion(region, cloneTemplate.getName(), instanceId, CreateImageOptions.NONE); final AtomicReference image = Atomics.newReference(new ImageBuilder() @@ -133,7 +133,7 @@ public class EC2ImageExtension implements ImageExtension { String region = parts[0]; String instanceId = parts[1]; try { - ec2Client.getAMIServices().deregisterImageInRegion(region, instanceId); + ec2Api.getAMIApi().get().deregisterImageInRegion(region, instanceId); return true; } catch (Exception e) { return false; diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtension.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtension.java index 4b09d56bf3..fe0201cd4f 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtension.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtension.java @@ -43,7 +43,7 @@ import org.jclouds.compute.extensions.SecurityGroupExtension; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.compute.functions.GroupNamingConvention.Factory; import org.jclouds.domain.Location; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules; import org.jclouds.ec2.domain.RunningInstance; @@ -72,7 +72,7 @@ import com.google.common.util.concurrent.UncheckedTimeoutException; */ public class EC2SecurityGroupExtension implements SecurityGroupExtension { - protected final EC2Client client; + protected final EC2Api client; protected final ListeningExecutorService userExecutor; protected final Supplier> regions; protected final Function groupConverter; @@ -81,7 +81,7 @@ public class EC2SecurityGroupExtension implements SecurityGroupExtension { protected final Factory namingConvention; @Inject - public EC2SecurityGroupExtension(EC2Client client, + public EC2SecurityGroupExtension(EC2Api client, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, @Region Supplier> regions, Function groupConverter, @@ -130,7 +130,7 @@ public class EC2SecurityGroupExtension implements SecurityGroupExtension { String region = parts[0]; String instanceId = parts[1]; - RunningInstance instance = getOnlyElement(Iterables.concat(client.getInstanceServices().describeInstancesInRegion(region, instanceId))); + RunningInstance instance = getOnlyElement(Iterables.concat(client.getInstanceApi().get().describeInstancesInRegion(region, instanceId))); if (instance == null) { return ImmutableSet.of(); @@ -138,7 +138,7 @@ public class EC2SecurityGroupExtension implements SecurityGroupExtension { Set groupNames = instance.getGroupNames(); Set rawGroups = - client.getSecurityGroupServices().describeSecurityGroupsInRegion(region, Iterables.toArray(groupNames, String.class)); + client.getSecurityGroupApi().get().describeSecurityGroupsInRegion(region, Iterables.toArray(groupNames, String.class)); return ImmutableSet.copyOf(transform(filter(rawGroups, notNull()), groupConverter)); } @@ -151,7 +151,7 @@ public class EC2SecurityGroupExtension implements SecurityGroupExtension { String groupId = parts[1]; Set rawGroups = - client.getSecurityGroupServices().describeSecurityGroupsInRegion(region, groupId); + client.getSecurityGroupApi().get().describeSecurityGroupsInRegion(region, groupId); return getOnlyElement(transform(filter(rawGroups, notNull()), groupConverter)); } @@ -183,8 +183,8 @@ public class EC2SecurityGroupExtension implements SecurityGroupExtension { String region = parts[0]; String groupName = parts[1]; - if (client.getSecurityGroupServices().describeSecurityGroupsInRegion(region, groupName).size() > 0) { - client.getSecurityGroupServices().deleteSecurityGroupInRegion(region, groupName); + if (client.getSecurityGroupApi().get().describeSecurityGroupsInRegion(region, groupName).size() > 0) { + client.getSecurityGroupApi().get().deleteSecurityGroupInRegion(region, groupName); // TODO: test this clear happens groupCreator.invalidate(new RegionNameAndIngressRules(region, groupName, null, false)); return true; @@ -201,7 +201,7 @@ public class EC2SecurityGroupExtension implements SecurityGroupExtension { if (ipPermission.getCidrBlocks().size() > 0) { for (String cidr : ipPermission.getCidrBlocks()) { - client.getSecurityGroupServices(). + client.getSecurityGroupApi().get(). authorizeSecurityGroupIngressInRegion(region, name, ipPermission.getIpProtocol(), @@ -214,7 +214,7 @@ public class EC2SecurityGroupExtension implements SecurityGroupExtension { if (ipPermission.getTenantIdGroupNamePairs().size() > 0) { for (String userId : ipPermission.getTenantIdGroupNamePairs().keySet()) { for (String groupName : ipPermission.getTenantIdGroupNamePairs().get(userId)) { - client.getSecurityGroupServices(). + client.getSecurityGroupApi().get(). authorizeSecurityGroupIngressInRegion(region, name, new UserIdGroupPair(userId, groupName)); @@ -235,7 +235,7 @@ public class EC2SecurityGroupExtension implements SecurityGroupExtension { if (Iterables.size(ipRanges) > 0) { for (String cidr : ipRanges) { - client.getSecurityGroupServices(). + client.getSecurityGroupApi().get(). authorizeSecurityGroupIngressInRegion(region, name, protocol, @@ -248,7 +248,7 @@ public class EC2SecurityGroupExtension implements SecurityGroupExtension { if (tenantIdGroupNamePairs.size() > 0) { for (String userId : tenantIdGroupNamePairs.keySet()) { for (String groupName : tenantIdGroupNamePairs.get(userId)) { - client.getSecurityGroupServices(). + client.getSecurityGroupApi().get(). authorizeSecurityGroupIngressInRegion(region, name, new UserIdGroupPair(userId, groupName)); @@ -266,7 +266,7 @@ public class EC2SecurityGroupExtension implements SecurityGroupExtension { if (ipPermission.getCidrBlocks().size() > 0) { for (String cidr : ipPermission.getCidrBlocks()) { - client.getSecurityGroupServices(). + client.getSecurityGroupApi().get(). revokeSecurityGroupIngressInRegion(region, name, ipPermission.getIpProtocol(), @@ -279,7 +279,7 @@ public class EC2SecurityGroupExtension implements SecurityGroupExtension { if (ipPermission.getTenantIdGroupNamePairs().size() > 0) { for (String userId : ipPermission.getTenantIdGroupNamePairs().keySet()) { for (String groupName : ipPermission.getTenantIdGroupNamePairs().get(userId)) { - client.getSecurityGroupServices(). + client.getSecurityGroupApi().get(). revokeSecurityGroupIngressInRegion(region, name, new UserIdGroupPair(userId, groupName)); @@ -300,7 +300,7 @@ public class EC2SecurityGroupExtension implements SecurityGroupExtension { if (Iterables.size(ipRanges) > 0) { for (String cidr : ipRanges) { - client.getSecurityGroupServices(). + client.getSecurityGroupApi().get(). revokeSecurityGroupIngressInRegion(region, name, protocol, @@ -313,7 +313,7 @@ public class EC2SecurityGroupExtension implements SecurityGroupExtension { if (tenantIdGroupNamePairs.size() > 0) { for (String userId : tenantIdGroupNamePairs.keySet()) { for (String groupName : tenantIdGroupNamePairs.get(userId)) { - client.getSecurityGroupServices(). + client.getSecurityGroupApi().get(). revokeSecurityGroupIngressInRegion(region, name, new UserIdGroupPair(userId, groupName)); @@ -356,7 +356,7 @@ public class EC2SecurityGroupExtension implements SecurityGroupExtension { @Override public Set apply(String from) { - return client.getSecurityGroupServices().describeSecurityGroupsInRegion(from); + return client.getSecurityGroupApi().get().describeSecurityGroupsInRegion(from); } }; diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPair.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPair.java index 584068299d..412cda2725 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPair.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPair.java @@ -24,7 +24,7 @@ import javax.inject.Singleton; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.domain.KeyPair; import org.jclouds.logging.Logger; @@ -42,12 +42,12 @@ public class CreateUniqueKeyPair implements Function { @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) protected Logger logger = Logger.NULL; - protected final EC2Client ec2Client; + protected final EC2Api ec2Api; protected final GroupNamingConvention.Factory namingConvention; @Inject - public CreateUniqueKeyPair(EC2Client ec2Client, GroupNamingConvention.Factory namingConvention) { - this.ec2Client = ec2Client; + public CreateUniqueKeyPair(EC2Api ec2Api, GroupNamingConvention.Factory namingConvention) { + this.ec2Api = ec2Api; this.namingConvention = checkNotNull(namingConvention, "namingConvention"); } @@ -67,7 +67,7 @@ public class CreateUniqueKeyPair implements Function { while (keyPair == null) { String keyName = namingConvention.create().uniqueNameForGroup(prefix); try { - keyPair = ec2Client.getKeyPairServices().createKeyPairInRegion(region, keyName); + keyPair = ec2Api.getKeyPairApi().get().createKeyPairInRegion(region, keyName); } catch (IllegalStateException e) { logger.trace(" invalid keyname (%s in %s); retrying", keyName, region); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/PasswordCredentialsFromWindowsInstance.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/PasswordCredentialsFromWindowsInstance.java index 14c22d6a70..939daf008d 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/PasswordCredentialsFromWindowsInstance.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/PasswordCredentialsFromWindowsInstance.java @@ -31,7 +31,7 @@ import javax.inject.Singleton; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.domain.LoginCredentials; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.PasswordDataAndPrivateKey; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.domain.KeyPair; @@ -59,20 +59,20 @@ public class PasswordCredentialsFromWindowsInstance implements Function credentialsMap; - private final EC2Client ec2Client; + private final EC2Api ec2Api; private final Function pwDataToLoginCredentials; @Inject protected PasswordCredentialsFromWindowsInstance(ConcurrentMap credentialsMap, - EC2Client ec2Client, Function pwDataToLoginCredentials) { + EC2Api ec2Api, Function pwDataToLoginCredentials) { this.credentialsMap = checkNotNull(credentialsMap, "credentialsMap"); - this.ec2Client = checkNotNull(ec2Client, "ec2Client"); + this.ec2Api = checkNotNull(ec2Api, "ec2Api"); this.pwDataToLoginCredentials = checkNotNull(pwDataToLoginCredentials, "pwDataToLoginCredentials"); } @Override public LoginCredentials apply(final RunningInstance instance) { - Optional windowsOption = ec2Client.getWindowsApiForRegion(instance.getRegion()); + Optional windowsOption = ec2Api.getWindowsApiForRegion(instance.getRegion()); checkState(windowsOption.isPresent(), "windows feature not present in region %s", instance.getRegion()); final WindowsApi windowsApi = windowsOption.get(); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/PresentInstances.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/PresentInstances.java index 7ff9d3d566..4f0d4f0880 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/PresentInstances.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/PresentInstances.java @@ -31,7 +31,7 @@ import java.util.Set; import javax.annotation.Resource; import javax.inject.Singleton; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.logging.Logger; @@ -53,10 +53,10 @@ public class PresentInstances implements Function, Set, Set instanceIds = entry.getValue(); logger.trace("looking for instances %s in region %s", instanceIds, region); - builder.addAll(concat(client.getInstanceServices().describeInstancesInRegion(region, + builder.addAll(concat(client.getInstanceApi().get().describeInstancesInRegion(region, toArray(instanceIds, String.class)))); } return builder.build(); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeeded.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeeded.java index de3b9062a0..301f41f08c 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeeded.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeeded.java @@ -24,11 +24,11 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules; import org.jclouds.ec2.domain.UserIdGroupPair; -import org.jclouds.ec2.services.SecurityGroupClient; +import org.jclouds.ec2.features.SecurityGroupApi; import org.jclouds.logging.Logger; import org.jclouds.net.domain.IpProtocol; @@ -45,16 +45,16 @@ public class CreateSecurityGroupIfNeeded extends CacheLoader securityGroupEventualConsistencyDelay; @Inject - public CreateSecurityGroupIfNeeded(EC2Client ec2Client, + public CreateSecurityGroupIfNeeded(EC2Api ec2Api, @Named("SECURITY") Predicate securityGroupEventualConsistencyDelay) { - this(checkNotNull(ec2Client, "ec2Client").getSecurityGroupServices(), securityGroupEventualConsistencyDelay); + this(checkNotNull(ec2Api, "ec2Api").getSecurityGroupApi().get(), securityGroupEventualConsistencyDelay); } - public CreateSecurityGroupIfNeeded(SecurityGroupClient securityClient, + public CreateSecurityGroupIfNeeded(SecurityGroupApi securityClient, @Named("SECURITY") Predicate securityGroupEventualConsistencyDelay) { this.securityClient = checkNotNull(securityClient, "securityClient"); this.securityGroupEventualConsistencyDelay = checkNotNull(securityGroupEventualConsistencyDelay, diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNull.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNull.java index 1a3097e83c..9161c20ad4 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNull.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNull.java @@ -21,7 +21,7 @@ import java.util.NoSuchElementException; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.domain.PublicIpInstanceIdPair; @@ -34,17 +34,17 @@ import com.google.common.collect.Iterables; */ @Singleton public class LoadPublicIpForInstanceOrNull extends CacheLoader { - private final EC2Client client; + private final EC2Api client; @Inject - public LoadPublicIpForInstanceOrNull(EC2Client client) { + public LoadPublicIpForInstanceOrNull(EC2Api client) { this.client = client; } @Override public String load(final RegionAndName key) throws Exception { try { - return Iterables.find(client.getElasticIPAddressServices().describeAddressesInRegion(key.getRegion()), + return Iterables.find(client.getElasticIPAddressApi().get().describeAddressesInRegion(key.getRegion()), new Predicate() { @Override diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImage.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImage.java index 5abfe9a805..294c528f4c 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImage.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImage.java @@ -25,7 +25,7 @@ import javax.inject.Inject; import javax.inject.Singleton; import org.jclouds.compute.domain.Image; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.functions.EC2ImageParser; import org.jclouds.logging.Logger; @@ -43,10 +43,10 @@ public class RegionAndIdToImage extends CacheLoader { protected Logger logger = Logger.NULL; private final EC2ImageParser parser; - private final EC2Client sync; + private final EC2Api sync; @Inject - public RegionAndIdToImage(EC2ImageParser parser, EC2Client sync) { + public RegionAndIdToImage(EC2ImageParser parser, EC2Api sync) { this.parser = parser; this.sync = sync; } @@ -54,7 +54,7 @@ public class RegionAndIdToImage extends CacheLoader { @Override public Image load(RegionAndName key) throws ExecutionException{ try { - org.jclouds.ec2.domain.Image image = Iterables.getOnlyElement(sync.getAMIServices() + org.jclouds.ec2.domain.Image image = Iterables.getOnlyElement(sync.getAMIApi().get() .describeImagesInRegion(key.getRegion(), imageIds(key.getName()))); return parser.apply(image); } catch (Exception e) { diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/predicates/SecurityGroupPresent.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/predicates/SecurityGroupPresent.java index aeb60440a9..33e492a617 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/predicates/SecurityGroupPresent.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/predicates/SecurityGroupPresent.java @@ -23,7 +23,7 @@ import java.util.NoSuchElementException; import javax.annotation.Resource; import javax.inject.Singleton; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.domain.SecurityGroup; import org.jclouds.logging.Logger; @@ -40,13 +40,13 @@ import com.google.inject.Inject; @Singleton public class SecurityGroupPresent implements Predicate { - private final EC2Client client; + private final EC2Api client; @Resource protected Logger logger = Logger.NULL; @Inject - public SecurityGroupPresent(EC2Client client) { + public SecurityGroupPresent(EC2Api client) { this.client = checkNotNull(client, "client"); } @@ -62,7 +62,7 @@ public class SecurityGroupPresent implements Predicate { } protected SecurityGroup refresh(RegionAndName securityGroup) { - return Iterables.getOnlyElement(client.getSecurityGroupServices().describeSecurityGroupsInRegion( + return Iterables.getOnlyElement(client.getSecurityGroupApi().get().describeSecurityGroupsInRegion( securityGroup.getRegion(), securityGroup.getName())); } } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/DescribeImagesParallel.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/DescribeImagesParallel.java index 3004d8919f..bddbbba2e0 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/DescribeImagesParallel.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/DescribeImagesParallel.java @@ -17,10 +17,14 @@ package org.jclouds.ec2.compute.strategy; import static com.google.common.collect.Iterables.concat; -import static org.jclouds.concurrent.FutureIterables.transformParallel; +import static com.google.common.collect.Iterables.transform; +import static com.google.common.util.concurrent.Futures.allAsList; +import static com.google.common.util.concurrent.Futures.getUnchecked; +import java.util.List; import java.util.Map.Entry; import java.util.Set; +import java.util.concurrent.Callable; import javax.annotation.Resource; import javax.inject.Inject; @@ -29,7 +33,7 @@ import javax.inject.Singleton; import org.jclouds.Constants; import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.ec2.EC2AsyncClient; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.options.DescribeImagesOptions; import org.jclouds.logging.Logger; @@ -48,25 +52,35 @@ public class DescribeImagesParallel implements @Named(ComputeServiceConstants.COMPUTE_LOGGER) protected Logger logger = Logger.NULL; - protected final EC2AsyncClient async; + protected final EC2Api api; final ListeningExecutorService userExecutor; @Inject - public DescribeImagesParallel(EC2AsyncClient async, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) { - this.async = async; + public DescribeImagesParallel(EC2Api api, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) { + this.api = api; this.userExecutor = userExecutor; } @Override public Iterable apply( - Iterable> queries) { - return concat(transformParallel( - queries, - new Function, ListenableFuture>>() { - public ListenableFuture> apply( - Entry from) { - return async.getAMIServices().describeImagesInRegion(from.getKey(), from.getValue()); - } - }, userExecutor, null, logger, "amis")); + final Iterable> queries) { + ListenableFuture>> futures + = allAsList(transform( + queries, + new Function, + ListenableFuture>>() { + public ListenableFuture> apply( + final Entry from) { + return userExecutor.submit(new Callable>() { + @Override + public Set call() throws Exception { + return api.getAMIApi().get().describeImagesInRegion(from.getKey(), from.getValue()); + } + }); + } + })); + logger.trace("amis"); + + return concat(getUnchecked(futures)); } } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java index c385540200..e40abe9d1a 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java @@ -45,7 +45,7 @@ import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet; import org.jclouds.compute.util.ComputeUtils; import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.functions.PresentInstances; import org.jclouds.ec2.domain.RunningInstance; @@ -82,7 +82,7 @@ public class EC2CreateNodesInGroupThenAddToSet implements CreateNodesInGroupThen boolean autoAllocateElasticIps = false; @VisibleForTesting - final EC2Client client; + final EC2Api client; @VisibleForTesting final Predicate> nodeRunning; @VisibleForTesting @@ -99,7 +99,7 @@ public class EC2CreateNodesInGroupThenAddToSet implements CreateNodesInGroupThen @Inject protected EC2CreateNodesInGroupThenAddToSet( - EC2Client client, + EC2Api client, @Named("ELASTICIP") LoadingCache elasticIpCache, @Named(TIMEOUT_NODE_RUNNING) Predicate> nodeRunning, CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions createKeyPairAndSecurityGroupsAsNeededAndReturncustomize, @@ -191,7 +191,7 @@ public class EC2CreateNodesInGroupThenAddToSet implements CreateNodesInGroupThen RunningInstance instance = entry.getValue(); try { logger.debug("<< allocating elastic IP instance(%s)", id); - String ip = client.getElasticIPAddressServices().allocateAddressInRegion(id.getRegion()); + String ip = client.getElasticIPAddressApi().get().allocateAddressInRegion(id.getRegion()); // block until instance is running logger.debug(">> awaiting status running instance(%s)", id); AtomicReference node = newReference(runningInstanceToNodeMetadata @@ -199,7 +199,7 @@ public class EC2CreateNodesInGroupThenAddToSet implements CreateNodesInGroupThen nodeRunning.apply(node); logger.trace("<< running instance(%s)", id); logger.debug(">> associating elastic IP %s to instance %s", ip, id); - client.getElasticIPAddressServices().associateAddressInRegion(id.getRegion(), ip, id.getName()); + client.getElasticIPAddressApi().get().associateAddressInRegion(id.getRegion(), ip, id.getName()); logger.trace("<< associated elastic IP %s to instance %s", ip, id); // add mapping of instance to ip into the cache elasticIpCache.put(id, ip); @@ -231,7 +231,7 @@ public class EC2CreateNodesInGroupThenAddToSet implements CreateNodesInGroupThen started = ImmutableSet.copyOf(concat( started, - client.getInstanceServices().runInstancesInRegion(region, zone, template.getImage().getProviderId(), 1, + client.getInstanceApi().get().runInstancesInRegion(region, zone, template.getImage().getProviderId(), 1, count - countStarted, instanceOptions))); countStarted = size(started); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategy.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategy.java index a3daede9ee..2061b4969f 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategy.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategy.java @@ -30,7 +30,7 @@ import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.strategy.DestroyNodeStrategy; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.reference.EC2Constants; import org.jclouds.logging.Logger; @@ -48,7 +48,7 @@ public class EC2DestroyNodeStrategy implements DestroyNodeStrategy { @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) protected Logger logger = Logger.NULL; - protected final EC2Client client; + protected final EC2Api client; protected final GetNodeMetadataStrategy getNode; protected final LoadingCache elasticIpCache; @@ -58,7 +58,7 @@ public class EC2DestroyNodeStrategy implements DestroyNodeStrategy { boolean autoAllocateElasticIps = false; @Inject - protected EC2DestroyNodeStrategy(EC2Client client, GetNodeMetadataStrategy getNode, + protected EC2DestroyNodeStrategy(EC2Api client, GetNodeMetadataStrategy getNode, @Named("ELASTICIP") LoadingCache elasticIpCache) { this.client = checkNotNull(client, "client"); this.getNode = checkNotNull(getNode, "getNode"); @@ -83,11 +83,11 @@ public class EC2DestroyNodeStrategy implements DestroyNodeStrategy { try { String ip = elasticIpCache.get(new RegionAndName(region, instanceId)); logger.debug(">> disassociating elastic IP %s", ip); - client.getElasticIPAddressServices().disassociateAddressInRegion(region, ip); + client.getElasticIPAddressApi().get().disassociateAddressInRegion(region, ip); logger.trace("<< disassociated elastic IP %s", ip); elasticIpCache.invalidate(new RegionAndName(region, instanceId)); logger.debug(">> releasing elastic IP %s", ip); - client.getElasticIPAddressServices().releaseAddressInRegion(region, ip); + client.getElasticIPAddressApi().get().releaseAddressInRegion(region, ip); logger.trace("<< released elastic IP %s", ip); } catch (CacheLoader.InvalidCacheLoadException e) { // no ip was found @@ -100,6 +100,6 @@ public class EC2DestroyNodeStrategy implements DestroyNodeStrategy { } protected void destroyInstanceInRegion(String instanceId, String region) { - client.getInstanceServices().terminateInstancesInRegion(region, instanceId); + client.getInstanceApi().get().terminateInstancesInRegion(region, instanceId); } } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetImageStrategy.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetImageStrategy.java index 4052c82c7b..a20c48c649 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetImageStrategy.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetImageStrategy.java @@ -26,7 +26,7 @@ import javax.inject.Singleton; import org.jclouds.aws.util.AWSUtils; import org.jclouds.compute.strategy.GetImageStrategy; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.domain.Image; import org.jclouds.ec2.options.DescribeImagesOptions; @@ -39,11 +39,11 @@ import com.google.common.base.Function; @Singleton public class EC2GetImageStrategy implements GetImageStrategy { - private final EC2Client client; + private final EC2Api client; private final Function imageToImage; @Inject - protected EC2GetImageStrategy(EC2Client client, Function imageToImage) { + protected EC2GetImageStrategy(EC2Api client, Function imageToImage) { this.client = checkNotNull(client, "client"); this.imageToImage = checkNotNull(imageToImage, "imageToImage"); } @@ -63,7 +63,7 @@ public class EC2GetImageStrategy implements GetImageStrategy { } public Image getImageInRegion(String region, String id) { - return getOnlyElement(client.getAMIServices().describeImagesInRegion(region, + return getOnlyElement(client.getAMIApi().get().describeImagesInRegion(region, DescribeImagesOptions.Builder.imageIds(id))); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetNodeMetadataStrategy.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetNodeMetadataStrategy.java index 620f2077d3..e446697649 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetNodeMetadataStrategy.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetNodeMetadataStrategy.java @@ -27,7 +27,7 @@ import javax.inject.Singleton; import org.jclouds.aws.util.AWSUtils; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.domain.RunningInstance; import com.google.common.base.Function; @@ -40,11 +40,11 @@ import com.google.common.collect.Iterables; @Singleton public class EC2GetNodeMetadataStrategy implements GetNodeMetadataStrategy { - private final EC2Client client; + private final EC2Api client; private final Function runningInstanceToNodeMetadata; @Inject - protected EC2GetNodeMetadataStrategy(EC2Client client, + protected EC2GetNodeMetadataStrategy(EC2Api client, Function runningInstanceToNodeMetadata) { this.client = checkNotNull(client, "client"); this.runningInstanceToNodeMetadata = checkNotNull(runningInstanceToNodeMetadata, "runningInstanceToNodeMetadata"); @@ -65,7 +65,7 @@ public class EC2GetNodeMetadataStrategy implements GetNodeMetadataStrategy { } public RunningInstance getRunningInstanceInRegion(String region, String id) { - return getOnlyElement(Iterables.concat(client.getInstanceServices().describeInstancesInRegion(region, id))); + return getOnlyElement(Iterables.concat(client.getInstanceApi().get().describeInstancesInRegion(region, id))); } } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2ListNodesStrategy.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2ListNodesStrategy.java index acb9df9a8b..d550b1e109 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2ListNodesStrategy.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2ListNodesStrategy.java @@ -42,7 +42,7 @@ import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.predicates.NodePredicates; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.strategy.ListNodesStrategy; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.location.Region; @@ -73,13 +73,13 @@ public class EC2ListNodesStrategy implements ListNodesStrategy { @Named(Constants.PROPERTY_REQUEST_TIMEOUT) protected static Long maxTime; - protected final EC2Client client; + protected final EC2Api client; protected final Supplier> regions; protected final Function runningInstanceToNodeMetadata; protected final ListeningExecutorService userExecutor; @Inject - protected EC2ListNodesStrategy(EC2Client client, @Region Supplier> regions, + protected EC2ListNodesStrategy(EC2Api client, @Region Supplier> regions, Function runningInstanceToNodeMetadata, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) { this.client = checkNotNull(client, "client"); @@ -146,7 +146,7 @@ public class EC2ListNodesStrategy implements ListNodesStrategy { @Override public Set> apply(String from) { - return client.getInstanceServices().describeInstancesInRegion(from); + return client.getInstanceApi().get().describeInstancesInRegion(from); } }; @@ -158,7 +158,7 @@ public class EC2ListNodesStrategy implements ListNodesStrategy { @Override public Set> apply(String from) { - return client.getInstanceServices() + return client.getInstanceApi().get() .describeInstancesInRegion(from, toArray(idsByRegions.get(from), String.class)); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2RebootNodeStrategy.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2RebootNodeStrategy.java index 8ea07e480c..c8cafc0e1e 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2RebootNodeStrategy.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2RebootNodeStrategy.java @@ -23,8 +23,8 @@ import org.jclouds.aws.util.AWSUtils; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.RebootNodeStrategy; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.services.InstanceClient; +import org.jclouds.ec2.EC2Api; +import org.jclouds.ec2.features.InstanceApi; /** * @@ -32,12 +32,12 @@ import org.jclouds.ec2.services.InstanceClient; */ @Singleton public class EC2RebootNodeStrategy implements RebootNodeStrategy { - private final InstanceClient client; + private final InstanceApi client; private final GetNodeMetadataStrategy getNode; @Inject - protected EC2RebootNodeStrategy(EC2Client client, GetNodeMetadataStrategy getNode) { - this.client = client.getInstanceServices(); + protected EC2RebootNodeStrategy(EC2Api client, GetNodeMetadataStrategy getNode) { + this.client = client.getInstanceApi().get(); this.getNode = getNode; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2ResumeNodeStrategy.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2ResumeNodeStrategy.java index ef6e08518b..5ecccfc549 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2ResumeNodeStrategy.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2ResumeNodeStrategy.java @@ -23,8 +23,8 @@ import org.jclouds.aws.util.AWSUtils; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.ResumeNodeStrategy; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.services.InstanceClient; +import org.jclouds.ec2.EC2Api; +import org.jclouds.ec2.features.InstanceApi; /** * @@ -32,12 +32,12 @@ import org.jclouds.ec2.services.InstanceClient; */ @Singleton public class EC2ResumeNodeStrategy implements ResumeNodeStrategy { - private final InstanceClient client; + private final InstanceApi client; private final GetNodeMetadataStrategy getNode; @Inject - protected EC2ResumeNodeStrategy(EC2Client client, GetNodeMetadataStrategy getNode) { - this.client = client.getInstanceServices(); + protected EC2ResumeNodeStrategy(EC2Api client, GetNodeMetadataStrategy getNode) { + this.client = client.getInstanceApi().get(); this.getNode = getNode; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2SuspendNodeStrategy.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2SuspendNodeStrategy.java index 5a30f977a8..cf9edd9b40 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2SuspendNodeStrategy.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/strategy/EC2SuspendNodeStrategy.java @@ -23,8 +23,8 @@ import org.jclouds.aws.util.AWSUtils; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.compute.strategy.SuspendNodeStrategy; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.services.InstanceClient; +import org.jclouds.ec2.EC2Api; +import org.jclouds.ec2.features.InstanceApi; /** * @@ -32,12 +32,12 @@ import org.jclouds.ec2.services.InstanceClient; */ @Singleton public class EC2SuspendNodeStrategy implements SuspendNodeStrategy { - private final InstanceClient client; + private final InstanceApi client; private final GetNodeMetadataStrategy getNode; @Inject - protected EC2SuspendNodeStrategy(EC2Client client, GetNodeMetadataStrategy getNode) { - this.client = client.getInstanceServices(); + protected EC2SuspendNodeStrategy(EC2Api client, GetNodeMetadataStrategy getNode) { + this.client = client.getInstanceApi().get(); this.getNode = getNode; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/config/BaseEC2HttpApiModule.java b/apis/ec2/src/main/java/org/jclouds/ec2/config/BaseEC2HttpApiModule.java new file mode 100644 index 0000000000..d976221253 --- /dev/null +++ b/apis/ec2/src/main/java/org/jclouds/ec2/config/BaseEC2HttpApiModule.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.ec2.config; + +import static org.jclouds.reflect.Reflection2.typeToken; +import static org.jclouds.rest.config.BinderUtils.bindHttpApi; + +import java.util.Map; + +import javax.inject.Singleton; + +import org.jclouds.aws.config.FormSigningHttpApiModule; +import org.jclouds.ec2.EC2Api; +import org.jclouds.ec2.features.SubnetApi; +import org.jclouds.ec2.features.TagApi; +import org.jclouds.ec2.features.WindowsApi; +import org.jclouds.ec2.features.AMIApi; +import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi; +import org.jclouds.ec2.features.ElasticBlockStoreApi; +import org.jclouds.ec2.features.ElasticIPAddressApi; +import org.jclouds.ec2.features.InstanceApi; +import org.jclouds.ec2.features.KeyPairApi; +import org.jclouds.ec2.features.SecurityGroupApi; +import org.jclouds.ec2.suppliers.DescribeAvailabilityZonesInRegion; +import org.jclouds.ec2.suppliers.DescribeRegionsForRegionURIs; +import org.jclouds.location.config.LocationModule; +import org.jclouds.location.suppliers.RegionIdToURISupplier; +import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; +import org.jclouds.location.suppliers.RegionIdsSupplier; +import org.jclouds.location.suppliers.ZoneIdToURISupplier; +import org.jclouds.location.suppliers.ZoneIdsSupplier; +import org.jclouds.location.suppliers.derived.RegionIdsFromRegionIdToURIKeySet; +import org.jclouds.location.suppliers.derived.ZoneIdToURIFromJoinOnRegionIdToURI; +import org.jclouds.location.suppliers.derived.ZoneIdsFromRegionIdToZoneIdsValues; +import org.jclouds.rest.ConfiguresHttpApi; + +import com.google.common.collect.ImmutableMap; +import com.google.common.reflect.TypeToken; +import com.google.inject.Provides; +import com.google.inject.Scopes; + +/** + * Configures the EC2 connection. + * + * @author Adrian Cole (EDIT: Nick Terry nterry@familysearch.org) + */ +@ConfiguresHttpApi +public abstract class BaseEC2HttpApiModule extends + FormSigningHttpApiModule { + + protected BaseEC2HttpApiModule(Class api) { + super(api); + } + + @Override + protected void installLocations() { + install(new LocationModule()); + bind(RegionIdToZoneIdsSupplier.class).to(DescribeAvailabilityZonesInRegion.class).in(Scopes.SINGLETON); + bind(RegionIdToURISupplier.class).to(DescribeRegionsForRegionURIs.class).in(Scopes.SINGLETON); + bind(ZoneIdsSupplier.class).to(ZoneIdsFromRegionIdToZoneIdsValues.class).in(Scopes.SINGLETON); + bind(RegionIdsSupplier.class).to(RegionIdsFromRegionIdToURIKeySet.class).in(Scopes.SINGLETON); + bind(ZoneIdToURISupplier.class).to(ZoneIdToURIFromJoinOnRegionIdToURI.class).in(Scopes.SINGLETON); + } +} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2HttpApiModule.java b/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2HttpApiModule.java new file mode 100644 index 0000000000..a7e1d05e28 --- /dev/null +++ b/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2HttpApiModule.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.ec2.config; + +import static org.jclouds.reflect.Reflection2.typeToken; +import static org.jclouds.rest.config.BinderUtils.bindHttpApi; + +import java.util.Map; + +import javax.inject.Singleton; + +import org.jclouds.aws.config.FormSigningHttpApiModule; +import org.jclouds.ec2.EC2Api; +import org.jclouds.ec2.features.SubnetApi; +import org.jclouds.ec2.features.TagApi; +import org.jclouds.ec2.features.WindowsApi; +import org.jclouds.ec2.features.AMIApi; +import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi; +import org.jclouds.ec2.features.ElasticBlockStoreApi; +import org.jclouds.ec2.features.ElasticIPAddressApi; +import org.jclouds.ec2.features.InstanceApi; +import org.jclouds.ec2.features.KeyPairApi; +import org.jclouds.ec2.features.SecurityGroupApi; +import org.jclouds.ec2.suppliers.DescribeAvailabilityZonesInRegion; +import org.jclouds.ec2.suppliers.DescribeRegionsForRegionURIs; +import org.jclouds.location.config.LocationModule; +import org.jclouds.location.suppliers.RegionIdToURISupplier; +import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; +import org.jclouds.location.suppliers.RegionIdsSupplier; +import org.jclouds.location.suppliers.ZoneIdToURISupplier; +import org.jclouds.location.suppliers.ZoneIdsSupplier; +import org.jclouds.location.suppliers.derived.RegionIdsFromRegionIdToURIKeySet; +import org.jclouds.location.suppliers.derived.ZoneIdToURIFromJoinOnRegionIdToURI; +import org.jclouds.location.suppliers.derived.ZoneIdsFromRegionIdToZoneIdsValues; +import org.jclouds.rest.ConfiguresHttpApi; + +import com.google.common.collect.ImmutableMap; +import com.google.common.reflect.TypeToken; +import com.google.inject.Provides; +import com.google.inject.Scopes; + +/** + * Configures the EC2 connection. + * + * @author Adrian Cole (EDIT: Nick Terry nterry@familysearch.org) + */ +@ConfiguresHttpApi +public class EC2HttpApiModule extends BaseEC2HttpApiModule { + + public EC2HttpApiModule() { + super(EC2Api.class); + } +} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java b/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java deleted file mode 100644 index 589ce9969a..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/config/EC2RestClientModule.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.config; - -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.util.Map; - -import javax.inject.Singleton; - -import org.jclouds.aws.config.WithZonesFormSigningRestClientModule; -import org.jclouds.ec2.EC2Api; -import org.jclouds.ec2.EC2AsyncApi; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.features.SubnetApi; -import org.jclouds.ec2.features.SubnetAsyncApi; -import org.jclouds.ec2.features.TagApi; -import org.jclouds.ec2.features.TagAsyncApi; -import org.jclouds.ec2.features.WindowsApi; -import org.jclouds.ec2.features.WindowsAsyncApi; -import org.jclouds.ec2.services.AMIAsyncClient; -import org.jclouds.ec2.services.AMIClient; -import org.jclouds.ec2.services.AvailabilityZoneAndRegionAsyncClient; -import org.jclouds.ec2.services.AvailabilityZoneAndRegionClient; -import org.jclouds.ec2.services.ElasticBlockStoreAsyncClient; -import org.jclouds.ec2.services.ElasticBlockStoreClient; -import org.jclouds.ec2.services.ElasticIPAddressAsyncClient; -import org.jclouds.ec2.services.ElasticIPAddressClient; -import org.jclouds.ec2.services.InstanceAsyncClient; -import org.jclouds.ec2.services.InstanceClient; -import org.jclouds.ec2.services.KeyPairAsyncClient; -import org.jclouds.ec2.services.KeyPairClient; -import org.jclouds.ec2.services.SecurityGroupAsyncClient; -import org.jclouds.ec2.services.SecurityGroupClient; -import org.jclouds.ec2.services.WindowsAsyncClient; -import org.jclouds.ec2.services.WindowsClient; -import org.jclouds.ec2.suppliers.DescribeAvailabilityZonesInRegion; -import org.jclouds.ec2.suppliers.DescribeRegionsForRegionURIs; -import org.jclouds.location.config.LocationModule; -import org.jclouds.location.suppliers.RegionIdToURISupplier; -import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; -import org.jclouds.location.suppliers.RegionIdsSupplier; -import org.jclouds.location.suppliers.ZoneIdToURISupplier; -import org.jclouds.location.suppliers.ZoneIdsSupplier; -import org.jclouds.location.suppliers.derived.RegionIdsFromRegionIdToURIKeySet; -import org.jclouds.location.suppliers.derived.ZoneIdToURIFromJoinOnRegionIdToURI; -import org.jclouds.location.suppliers.derived.ZoneIdsFromRegionIdToZoneIdsValues; -import org.jclouds.rest.ConfiguresRestClient; - -import com.google.common.collect.ImmutableMap; -import com.google.common.reflect.TypeToken; -import com.google.inject.Provides; -import com.google.inject.Scopes; - -/** - * Configures the EC2 connection. - * - * @author Adrian Cole (EDIT: Nick Terry nterry@familysearch.org) - */ -@ConfiguresRestClient -// EC2Api not EC2Client so that this can be used for new apps that only depend on EC2Api -public class EC2RestClientModule extends - WithZonesFormSigningRestClientModule { - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// - .put(AMIClient.class, AMIAsyncClient.class)// - .put(ElasticIPAddressClient.class, ElasticIPAddressAsyncClient.class)// - .put(InstanceClient.class, InstanceAsyncClient.class)// - .put(KeyPairClient.class, KeyPairAsyncClient.class)// - .put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)// - .put(WindowsClient.class, WindowsAsyncClient.class)// - .put(AvailabilityZoneAndRegionClient.class, AvailabilityZoneAndRegionAsyncClient.class)// - .put(ElasticBlockStoreClient.class, ElasticBlockStoreAsyncClient.class)// - .put(WindowsApi.class, WindowsAsyncApi.class)// - .put(TagApi.class, TagAsyncApi.class)// - .put(SubnetApi.class, SubnetAsyncApi.class)// - .build(); - - @SuppressWarnings("unchecked") - public EC2RestClientModule() { - // retaining top-level type of EC2Client vs EC2Api until we migrate all functionality up - super(TypeToken.class.cast(typeToken(EC2Client.class)), TypeToken.class.cast(typeToken(EC2AsyncClient.class)), DELEGATE_MAP); - } - - protected EC2RestClientModule(TypeToken syncClientType, TypeToken asyncClientType, - Map, Class> sync2Async) { - super(syncClientType, asyncClientType, sync2Async); - } - - - /** - * so that we can make bindings to {@link EC2Api directly} until we switch - * off {@link @EC2Client} - */ - @Singleton - @Provides - EC2Api provideEC2Api(EC2Client in) { - return in; - } - - /** - * so that we can make bindings to {@link EC2AsyncApi directly} until we switch - * off {@link @EC2AsyncClient} - */ - @Singleton - @Provides - EC2AsyncApi provideEC2Api(EC2AsyncClient in) { - return in; - } - - @Override - protected void installLocations() { - install(new LocationModule()); - bind(RegionIdToZoneIdsSupplier.class).to(DescribeAvailabilityZonesInRegion.class).in(Scopes.SINGLETON); - bind(RegionIdToURISupplier.class).to(DescribeRegionsForRegionURIs.class).in(Scopes.SINGLETON); - bind(ZoneIdsSupplier.class).to(ZoneIdsFromRegionIdToZoneIdsValues.class).in(Scopes.SINGLETON); - bind(RegionIdsSupplier.class).to(RegionIdsFromRegionIdToURIKeySet.class).in(Scopes.SINGLETON); - bind(ZoneIdToURISupplier.class).to(ZoneIdToURIFromJoinOnRegionIdToURI.class).in(Scopes.SINGLETON); - } -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/AMIClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/features/AMIApi.java similarity index 59% rename from apis/ec2/src/main/java/org/jclouds/ec2/services/AMIClient.java rename to apis/ec2/src/main/java/org/jclouds/ec2/features/AMIApi.java index ebaec35a80..40540aaf25 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/AMIClient.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/features/AMIApi.java @@ -14,10 +14,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; + +import static org.jclouds.aws.reference.FormParameters.ACTION; import java.util.Map; import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.aws.filters.FormSigner; +import org.jclouds.ec2.binders.BindUserGroupsToIndexedFormParams; +import org.jclouds.ec2.binders.BindUserIdsToIndexedFormParams; import org.jclouds.ec2.domain.Image; import org.jclouds.ec2.domain.Image.EbsBlockDevice; import org.jclouds.ec2.domain.Permission; @@ -25,15 +37,29 @@ import org.jclouds.ec2.options.CreateImageOptions; import org.jclouds.ec2.options.DescribeImagesOptions; import org.jclouds.ec2.options.RegisterImageBackedByEbsOptions; import org.jclouds.ec2.options.RegisterImageOptions; +import org.jclouds.ec2.xml.BlockDeviceMappingHandler; +import org.jclouds.ec2.xml.DescribeImagesResponseHandler; +import org.jclouds.ec2.xml.ImageIdHandler; +import org.jclouds.ec2.xml.PermissionHandler; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.FormParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.VirtualHost; +import org.jclouds.rest.annotations.XMLResponseParser; /** - * Provides access to EC2 via their REST API. + * Provides access to AMI Services. *

* * @author Adrian Cole */ -public interface AMIClient { +@RequestFilters(FormSigner.class) +@VirtualHost +public interface AMIApi { /** * Returns information about AMIs, AKIs, and ARIs. This includes image type, product codes, @@ -43,29 +69,21 @@ public interface AMIClient { * * @param region * AMIs are tied to the Region where its files are located within Amazon S3. - * @see InstanceClient#describeInstances + * @see InstanceApi#describeInstances * @see #describeImageAttribute * @see * @see DescribeImagesOptions */ - Set describeImagesInRegion(@Nullable String region, DescribeImagesOptions... options); - - /** - * Returns a map of device name to block device for the image. - * - * @param region - * AMIs are tied to the Region where its files are located within Amazon S3. - * @param imageId - * The ID of the AMI for which an attribute will be described - * @see #describeImages - * @see #modifyImageAttribute - * @see #resetImageAttribute - * @see - * @see DescribeImagesOptions - */ - Map getBlockDeviceMappingsForImageInRegion(@Nullable String region, String imageId); + @Named("DescribeImages") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DescribeImages") + @XMLResponseParser(DescribeImagesResponseHandler.class) + @Fallback(EmptySetOnNotFoundOr404.class) + Set describeImagesInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + DescribeImagesOptions... options); /** * Creates an AMI that uses an Amazon EBS root device from a "running" or "stopped" instance. @@ -82,14 +100,21 @@ public interface AMIClient { * @see * @see CreateImageOptions - * @see InstanceClient#runInstances - * @see InstanceClient#describeInstances - * @see InstanceClient#terminateInstances + * @see InstanceApi#runInstances + * @see InstanceApi#describeInstances + * @see InstanceApi#terminateInstances * @see */ - String createImageInRegion(@Nullable String region, String name, String instanceId, CreateImageOptions... options); + @Named("CreateImage") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "CreateImage") + @XMLResponseParser(ImageIdHandler.class) + String createImageInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("Name") String name, @FormParam("InstanceId") String instanceId, CreateImageOptions... options); /** * @@ -108,11 +133,17 @@ public interface AMIClient { * @see */ - void deregisterImageInRegion(@Nullable String region, String imageId); + @Named("DeregisterImage") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DeregisterImage") + void deregisterImageInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("ImageId") String imageId); /** * Registers an AMI with Amazon EC2. Images must be registered before they can be launched. To - * launch instances, use the {@link InstanceClient#runInstances} operation. + * launch instances, use the {@link InstanceApi#runInstances} operation. *

* Each AMI is associated with an unique ID which is provided by the Amazon EC2 service through * this operation. If needed, you can deregister an AMI at any time. @@ -138,12 +169,19 @@ public interface AMIClient { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html" * /> */ - String registerImageFromManifestInRegion(@Nullable String region, String name, String pathToManifest, + @Named("RegisterImage") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "RegisterImage") + @XMLResponseParser(ImageIdHandler.class) + String registerImageFromManifestInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("Name") String imageName, @FormParam("ImageLocation") String pathToManifest, RegisterImageOptions... options); /** * Registers an AMI with Amazon EC2. Images must be registered before they can be launched. To - * launch instances, use the {@link InstanceClient#runInstances} operation. The root device name + * launch instances, use the {@link InstanceApi#runInstances} operation. The root device name * is /dev/sda1 *

* Each AMI is associated with an unique ID which is provided by the Amazon EC2 service through @@ -173,24 +211,39 @@ public interface AMIClient { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html" * /> */ - String registerUnixImageBackedByEbsInRegion(@Nullable String region, String name, String ebsSnapshotId, + @Named("RegisterImage") + @POST + @Path("/") + @FormParams(keys = { ACTION, "RootDeviceName", "BlockDeviceMapping.0.DeviceName" }, values = { "RegisterImage", + "/dev/sda1", "/dev/sda1" }) + @XMLResponseParser(ImageIdHandler.class) + String registerUnixImageBackedByEbsInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("Name") String imageName, + @FormParam("BlockDeviceMapping.0.Ebs.SnapshotId") String ebsSnapshotId, RegisterImageBackedByEbsOptions... options); /** - * Returns the {@link Permission}s of an image. + * Resets the {@code launchPermission}s on an AMI. * * @param region * AMIs are tied to the Region where its files are located within Amazon S3. * @param imageId - * The ID of the AMI for which an attribute will be described - * @see #describeImages - * @see #modifyImageAttribute - * @see #resetImageAttribute - * @see - * @see DescribeImagesOptions */ - Permission getLaunchPermissionForImageInRegion(@Nullable String region, String imageId); + @Named("ResetImageAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "ResetImageAttribute", "launchPermission" }) + void resetLaunchPermissionsOnImageInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("ImageId") String imageId); /** * Adds {@code launchPermission}s to an AMI. @@ -210,44 +263,74 @@ public interface AMIClient { * @see */ - void addLaunchPermissionsToImageInRegion(@Nullable String region, Iterable userIds, - Iterable userGroups, String imageId); + @Named("ModifyImageAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute", "add", + "launchPermission" }) + void addLaunchPermissionsToImageInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @BinderParam(BindUserIdsToIndexedFormParams.class) Iterable userIds, + @BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable userGroups, + @FormParam("ImageId") String imageId); /** - * Resets the {@code launchPermission}s on an AMI. - * - * @param region - * AMIs are tied to the Region where its files are located within Amazon S3. - * @param imageId - * ID of the AMI on which the attribute will be reset. - * - * @see #addLaunchPermissionsToImage - * @see #describeImageAttribute - * @see #removeProductCodesFromImage - * @see + * @see AMIApi#removeLaunchPermissionsToImageInRegion */ - void resetLaunchPermissionsOnImageInRegion(@Nullable String region, String imageId); + @Named("ModifyImageAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute", "remove", + "launchPermission" }) + void removeLaunchPermissionsFromImageInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @BinderParam(BindUserIdsToIndexedFormParams.class) Iterable userIds, + @BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable userGroups, + @FormParam("ImageId") String imageId); /** - * Removes {@code launchPermission}s from an AMI. + * Returns the {@link Permission}s of an image. * * @param region * AMIs are tied to the Region where its files are located within Amazon S3. - * @param userIds - * AWS Access Key ID. - * @param userGroups - * Name of the groups. Currently supports \"all.\"" * @param imageId - * The AMI ID. - * - * @see #addLaunchPermissionsToImage - * @see #describeImageAttribute + * The ID of the AMI for which an attribute will be described + * @see #describeImages + * @see #modifyImageAttribute * @see #resetImageAttribute - * @see + * @see DescribeImagesOptions */ - void removeLaunchPermissionsFromImageInRegion(@Nullable String region, Iterable userIds, - Iterable userGroups, String imageId); + @Named("DescribeImageAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute", "launchPermission" }) + @XMLResponseParser(PermissionHandler.class) + Permission getLaunchPermissionForImageInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("ImageId") String imageId); + /** + * Returns a map of device name to block device for the image. + * + * @param region + * AMIs are tied to the Region where its files are located within Amazon S3. + * @param imageId + * The ID of the AMI for which an attribute will be described + * @see #describeImages + * @see #modifyImageAttribute + * @see #resetImageAttribute + * @see + * @see DescribeImagesOptions + */ + @Named("DescribeImageAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute", "blockDeviceMapping" }) + @XMLResponseParser(BlockDeviceMappingHandler.class) + Map getBlockDeviceMappingsForImageInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("ImageId") String imageId); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApi.java similarity index 75% rename from apis/ec2/src/main/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClient.java rename to apis/ec2/src/main/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApi.java index 3c5b3798d3..7de7a48a13 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClient.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApi.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.jclouds.aws.reference.FormParameters.ACTION; @@ -42,8 +42,6 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.VirtualHost; import org.jclouds.rest.annotations.XMLResponseParser; -import com.google.common.util.concurrent.ListenableFuture; - /** * Provides access to EC2 Availability Zones and Regions via their REST API. *

@@ -52,10 +50,16 @@ import com.google.common.util.concurrent.ListenableFuture; */ @RequestFilters(FormSigner.class) @VirtualHost -public interface AvailabilityZoneAndRegionAsyncClient { +public interface AvailabilityZoneAndRegionApi { /** - * @see AvailabilityZoneAndRegionClient#describeAvailabilityZonesInRegion + * Displays Availability Zones that are currently available to the identity and their states. + * + * @see InstanceApi#runInstances + * @see #describeRegions + * + * @see */ @Named("DescribeAvailabilityZones") @POST @@ -63,18 +67,24 @@ public interface AvailabilityZoneAndRegionAsyncClient { @FormParams(keys = ACTION, values = "DescribeAvailabilityZones") @XMLResponseParser(DescribeAvailabilityZonesResponseHandler.class) @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> describeAvailabilityZonesInRegion( + Set describeAvailabilityZonesInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, DescribeAvailabilityZonesOptions... options); /** - * @see AvailabilityZoneAndRegionClient#describeRegions + * Describes Regions that are currently available to the identity. + * + * @see InstanceApi#runInstances + * @see #describeAvailabilityZones + * + * @see */ @Named("DescribeRegions") @POST @Path("/") @FormParams(keys = ACTION, values = "DescribeRegions") @XMLResponseParser(DescribeRegionsResponseHandler.class) - ListenableFuture> describeRegions(DescribeRegionsOptions... options); + Map describeRegions(DescribeRegionsOptions... options); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/ElasticBlockStoreClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/features/ElasticBlockStoreApi.java similarity index 69% rename from apis/ec2/src/main/java/org/jclouds/ec2/services/ElasticBlockStoreClient.java rename to apis/ec2/src/main/java/org/jclouds/ec2/features/ElasticBlockStoreApi.java index b12df616ef..8e56f7711e 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/ElasticBlockStoreClient.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/features/ElasticBlockStoreApi.java @@ -14,9 +14,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; + +import static org.jclouds.aws.reference.FormParameters.ACTION; import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.aws.filters.FormSigner; +import org.jclouds.ec2.EC2Fallbacks.VoidOnVolumeAvailable; +import org.jclouds.ec2.binders.BindUserGroupsToIndexedFormParams; +import org.jclouds.ec2.binders.BindUserIdsToIndexedFormParams; +import org.jclouds.ec2.binders.BindVolumeIdsToIndexedFormParams; import org.jclouds.ec2.domain.Attachment; import org.jclouds.ec2.domain.Permission; import org.jclouds.ec2.domain.Snapshot; @@ -24,15 +38,32 @@ import org.jclouds.ec2.domain.Volume; import org.jclouds.ec2.options.CreateSnapshotOptions; import org.jclouds.ec2.options.DescribeSnapshotsOptions; import org.jclouds.ec2.options.DetachVolumeOptions; +import org.jclouds.ec2.xml.AttachmentHandler; +import org.jclouds.ec2.xml.CreateVolumeResponseHandler; +import org.jclouds.ec2.xml.DescribeSnapshotsResponseHandler; +import org.jclouds.ec2.xml.DescribeVolumesResponseHandler; +import org.jclouds.ec2.xml.PermissionHandler; +import org.jclouds.ec2.xml.SnapshotHandler; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; +import org.jclouds.location.functions.ZoneToEndpoint; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.FormParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.VirtualHost; +import org.jclouds.rest.annotations.XMLResponseParser; /** - * Provides access to EC2 Elastic Block Store services. + * Provides access to EC2 Elastic Block Store services via their REST API. *

* * @author Adrian Cole */ -public interface ElasticBlockStoreClient { +@RequestFilters(FormSigner.class) +@VirtualHost +public interface ElasticBlockStoreApi { /** * Creates a new Amazon EBS volume to which any Amazon EC2 instance can attach within the same @@ -49,15 +80,21 @@ public interface ElasticBlockStoreClient { * @see #deleteVolumeInRegion * @see #attachVolumeInRegion * @see #detachVolumeInRegion - * @see AvailabilityZoneAndRegionClient#describeAvailabilityZonesInRegion + * @see AvailabilityZoneAndRegionApi#describeAvailabilityZonesInRegion * * * @see */ - Volume createVolumeFromSnapshotInAvailabilityZone(String availabilityZone, - String snapshotId); + @Named("CreateVolume") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "CreateVolume") + @XMLResponseParser(CreateVolumeResponseHandler.class) + Volume createVolumeFromSnapshotInAvailabilityZone( + @EndpointParam(parser = ZoneToEndpoint.class) @FormParam("AvailabilityZone") String availabilityZone, + @FormParam("SnapshotId") String snapshotId); /** * Creates a new Amazon EBS volume to which any Amazon EC2 instance can attach within the same @@ -79,15 +116,21 @@ public interface ElasticBlockStoreClient { * @see #deleteVolumeInRegion * @see #attachVolumeInRegion * @see #detachVolumeInRegion - * @see AvailabilityZoneAndRegionClient#describeAvailabilityZonesInRegion + * @see AvailabilityZoneAndRegionApi#describeAvailabilityZonesInRegion * * * @see */ - Volume createVolumeFromSnapshotInAvailabilityZone(String availabilityZone, - int size, String snapshotId); + @Named("CreateVolume") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "CreateVolume") + @XMLResponseParser(CreateVolumeResponseHandler.class) + Volume createVolumeFromSnapshotInAvailabilityZone( + @EndpointParam(parser = ZoneToEndpoint.class) @FormParam("AvailabilityZone") String availabilityZone, + @FormParam("Size") int size, @FormParam("SnapshotId") String snapshotId); /** * Creates a new Amazon EBS volume to which any Amazon EC2 instance can attach within the same @@ -106,12 +149,19 @@ public interface ElasticBlockStoreClient { * @see #deleteVolumeInRegion * @see #attachVolumeInRegion * @see #detachVolumeInRegion - * @see AvailabilityZoneAndRegionClient#describeAvailabilityZonesInRegion + * @see AvailabilityZoneAndRegionApi#describeAvailabilityZonesInRegion * @see */ - Volume createVolumeInAvailabilityZone(String availabilityZone, int size); + @Named("CreateVolume") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "CreateVolume") + @XMLResponseParser(CreateVolumeResponseHandler.class) + Volume createVolumeInAvailabilityZone( + @EndpointParam(parser = ZoneToEndpoint.class) @FormParam("AvailabilityZone") String availabilityZone, + @FormParam("Size") int size); /** * Describes the specified Amazon EBS volumes that you own. If you do not specify one or more @@ -129,7 +179,14 @@ public interface ElasticBlockStoreClient { * @see */ - Set describeVolumesInRegion(@Nullable String region, String... volumeIds); + @POST + @Named("DescribeVolumes") + @Path("/") + @FormParams(keys = ACTION, values = "DescribeVolumes") + @XMLResponseParser(DescribeVolumesResponseHandler.class) + Set describeVolumesInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @BinderParam(BindVolumeIdsToIndexedFormParams.class) String... volumeIds); /** * Deletes an Amazon EBS volume that you own. For more information about Amazon EBS, go to the @@ -150,7 +207,12 @@ public interface ElasticBlockStoreClient { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteVolume.html" * /> */ - void deleteVolumeInRegion(@Nullable String region, String volumeId); + @Named("DeleteVolume") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DeleteVolume") + void deleteVolumeInRegion(@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("VolumeId") String volumeId); /** * Attaches an Amazon EBS volume to a running instance and exposes it as the specified device. @@ -190,8 +252,13 @@ public interface ElasticBlockStoreClient { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DetachVolume.html" * /> */ - void detachVolumeInRegion(@Nullable String region, String volumeId, boolean force, - DetachVolumeOptions... options); + @Named("DetachVolume") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DetachVolume") + @Fallback(VoidOnVolumeAvailable.class) + void detachVolumeInRegion(@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("VolumeId") String volumeId, @FormParam("Force") boolean force, DetachVolumeOptions... options); /** * Attaches an Amazon EBS volume to a running instance and exposes it as the specified device. @@ -223,7 +290,15 @@ public interface ElasticBlockStoreClient { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-AttachVolume.html" * /> */ - Attachment attachVolumeInRegion(@Nullable String region, String volumeId, String instanceId, String device); + @Named("AttachVolume") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "AttachVolume") + @XMLResponseParser(AttachmentHandler.class) + Attachment attachVolumeInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("VolumeId") String volumeId, @FormParam("InstanceId") String instanceId, + @FormParam("Device") String device); /** * Creates a snapshot of an Amazon EBS volume and stores it in Amazon S3. You can use snapshots @@ -260,7 +335,14 @@ public interface ElasticBlockStoreClient { * @see */ - Snapshot createSnapshotInRegion(@Nullable String region, String volumeId, CreateSnapshotOptions... options); + @Named("CreateSnapshot") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "CreateSnapshot") + @XMLResponseParser(SnapshotHandler.class) + Snapshot createSnapshotInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("VolumeId") String volumeId, CreateSnapshotOptions... options); /** * Returns information about Amazon EBS snapshots available to the user. Information returned @@ -321,7 +403,15 @@ public interface ElasticBlockStoreClient { * @see */ - Set describeSnapshotsInRegion(@Nullable String region, DescribeSnapshotsOptions... options); + @Named("DescribeSnapshots") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DescribeSnapshots") + @XMLResponseParser(DescribeSnapshotsResponseHandler.class) + @Fallback(EmptySetOnNotFoundOr404.class) + Set describeSnapshotsInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + DescribeSnapshotsOptions... options); /** * Deletes a snapshot of an Amazon EBS volume that you own. For more information, go to the @@ -338,23 +428,13 @@ public interface ElasticBlockStoreClient { * @see */ - void deleteSnapshotInRegion(@Nullable String region, String snapshotId); - - /** - * Returns the {@link Permission}s of an snapshot. - * - * @param region - * AMIs are tied to the Region where its files are located within Amazon S3. - * @param snapshotId - * The ID of the AMI for which an attribute will be described - * @see #describeSnapshots - * @see #modifySnapshotAttribute - * @see #resetSnapshotAttribute - * @see - * @see DescribeSnapshotsOptions - */ - Permission getCreateVolumePermissionForSnapshotInRegion(@Nullable String region, String snapshotId); + @Named("DeleteSnapshot") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DeleteSnapshot") + void deleteSnapshotInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("SnapshotId") String snapshotId); /** * Adds {@code createVolumePermission}s to an EBS snapshot. @@ -375,25 +455,16 @@ public interface ElasticBlockStoreClient { * @see */ - void addCreateVolumePermissionsToSnapshotInRegion(@Nullable String region, Iterable userIds, - Iterable userGroups, String snapshotId); - - /** - * Resets the {@code createVolumePermission}s on an EBS snapshot. - * - * @param region - * Snapshots are tied to Regions and can only be used for volumes within the same - * Region. - * @param snapshotId - * The ID of the Amazon EBS snapshot. - * - * @see #addCreateVolumePermissionsToSnapshot - * @see #describeSnapshotAttribute - * @see #removeProductCodesFromSnapshot - * @see - */ - void resetCreateVolumePermissionsOnSnapshotInRegion(@Nullable String region, String snapshotId); + @Named("ModifySnapshotAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifySnapshotAttribute", "add", + "createVolumePermission" }) + void addCreateVolumePermissionsToSnapshotInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @BinderParam(BindUserIdsToIndexedFormParams.class) Iterable userIds, + @BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable userGroups, + @FormParam("SnapshotId") String snapshotId); /** * Removes {@code createVolumePermission}s from an EBS snapshot. @@ -414,6 +485,61 @@ public interface ElasticBlockStoreClient { * @see */ - void removeCreateVolumePermissionsFromSnapshotInRegion(@Nullable String region, Iterable userIds, - Iterable userGroups, String snapshotId); + @Named("ModifySnapshotAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifySnapshotAttribute", "remove", + "createVolumePermission" }) + void removeCreateVolumePermissionsFromSnapshotInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @BinderParam(BindUserIdsToIndexedFormParams.class) Iterable userIds, + @BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable userGroups, + @FormParam("SnapshotId") String snapshotId); + + /** + * Returns the {@link Permission}s of an snapshot. + * + * @param region + * AMIs are tied to the Region where its files are located within Amazon S3. + * @param snapshotId + * The ID of the AMI for which an attribute will be described + * @see #describeSnapshots + * @see #modifySnapshotAttribute + * @see #resetSnapshotAttribute + * @see + * @see DescribeSnapshotsOptions + */ + @Named("DescribeSnapshotAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeSnapshotAttribute", "createVolumePermission" }) + @XMLResponseParser(PermissionHandler.class) + Permission getCreateVolumePermissionForSnapshotInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("SnapshotId") String snapshotId); + + /** + * Resets the {@code createVolumePermission}s on an EBS snapshot. + * + * @param region + * Snapshots are tied to Regions and can only be used for volumes within the same + * Region. + * @param snapshotId + * The ID of the Amazon EBS snapshot. + * + * @see #addCreateVolumePermissionsToSnapshot + * @see #describeSnapshotAttribute + * @see #removeProductCodesFromSnapshot + * @see + */ + @Named("ResetSnapshotAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "ResetSnapshotAttribute", "createVolumePermission" }) + void resetCreateVolumePermissionsOnSnapshotInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("SnapshotId") String snapshotId); + } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/ElasticIPAddressClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/features/ElasticIPAddressApi.java similarity index 59% rename from apis/ec2/src/main/java/org/jclouds/ec2/services/ElasticIPAddressClient.java rename to apis/ec2/src/main/java/org/jclouds/ec2/features/ElasticIPAddressApi.java index 2eaec4db88..47d93a7a63 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/ElasticIPAddressClient.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/features/ElasticIPAddressApi.java @@ -14,19 +14,42 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; + +import static org.jclouds.aws.reference.FormParameters.ACTION; import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.aws.filters.FormSigner; +import org.jclouds.ec2.binders.BindPublicIpsToIndexedFormParams; import org.jclouds.ec2.domain.PublicIpInstanceIdPair; +import org.jclouds.ec2.xml.AllocateAddressResponseHandler; +import org.jclouds.ec2.xml.DescribeAddressesResponseHandler; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.FormParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.VirtualHost; +import org.jclouds.rest.annotations.XMLResponseParser; /** - * Provides access to EC2 via their REST API. + * Provides access to EC2 Elastic IP Addresses via REST API. *

* * @author Adrian Cole */ -public interface ElasticIPAddressClient { +@RequestFilters(FormSigner.class) +@VirtualHost +public interface ElasticIPAddressApi { /** * Acquires an elastic IP address for use with your identity. @@ -39,7 +62,13 @@ public interface ElasticIPAddressClient { * @see #disassociateAddress * @see */ - Set describeAddressesInRegion(@Nullable String region, - String... publicIps); + @Named("DescribeAddresses") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DescribeAddresses") + @XMLResponseParser(DescribeAddressesResponseHandler.class) + @Fallback(EmptySetOnNotFoundOr404.class) + Set describeAddressesInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @BinderParam(BindPublicIpsToIndexedFormParams.class) String... publicIps); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/InstanceClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/features/InstanceApi.java similarity index 66% rename from apis/ec2/src/main/java/org/jclouds/ec2/services/InstanceClient.java rename to apis/ec2/src/main/java/org/jclouds/ec2/features/InstanceApi.java index 2bd6e26318..2b56324ffa 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/InstanceClient.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/features/InstanceApi.java @@ -14,25 +14,60 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; + +import static org.jclouds.aws.reference.FormParameters.ACTION; import java.util.Map; import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.aws.filters.FormSigner; +import org.jclouds.ec2.binders.BindBlockDeviceMappingToIndexedFormParams; +import org.jclouds.ec2.binders.BindInstanceIdsToIndexedFormParams; +import org.jclouds.ec2.binders.IfNotNullBindAvailabilityZoneToFormParam; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.InstanceStateChange; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior; +import org.jclouds.ec2.functions.ConvertUnencodedBytesToBase64EncodedString; import org.jclouds.ec2.options.RunInstancesOptions; +import org.jclouds.ec2.xml.BlockDeviceMappingHandler; +import org.jclouds.ec2.xml.BooleanValueHandler; +import org.jclouds.ec2.xml.DescribeInstancesResponseHandler; +import org.jclouds.ec2.xml.GetConsoleOutputResponseHandler; +import org.jclouds.ec2.xml.InstanceInitiatedShutdownBehaviorHandler; +import org.jclouds.ec2.xml.InstanceStateChangeHandler; +import org.jclouds.ec2.xml.InstanceTypeHandler; +import org.jclouds.ec2.xml.RunInstancesResponseHandler; +import org.jclouds.ec2.xml.StringValueHandler; +import org.jclouds.ec2.xml.UnencodeStringValueHandler; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.FormParams; +import org.jclouds.rest.annotations.ParamParser; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.VirtualHost; +import org.jclouds.rest.annotations.XMLResponseParser; /** - * Provides access to EC2 via their REST API. + * Provides access to EC2 Instance Services via their REST API. *

* * @author Adrian Cole */ -public interface InstanceClient { +@RequestFilters(FormSigner.class) +@VirtualHost +public interface InstanceApi { /** * Returns information about instances that you own. @@ -56,8 +91,15 @@ public interface InstanceClient { * @see */ - Set> describeInstancesInRegion(@Nullable String region, - String... instanceIds); + @Named("DescribeInstances") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DescribeInstances") + @XMLResponseParser(DescribeInstancesResponseHandler.class) + @Fallback(EmptySetOnNotFoundOr404.class) + Set> describeInstancesInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds); /** * Launches a specified number of instances of an AMI for which you have @@ -136,9 +178,46 @@ public interface InstanceClient { * /> * @see RunInstancesOptions */ - Reservation runInstancesInRegion(@Nullable String region, - @Nullable String nullableAvailabilityZone, String imageId, - int minCount, int maxCount, RunInstancesOptions... options); + @Named("RunInstances") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "RunInstances") + @XMLResponseParser(RunInstancesResponseHandler.class) + Reservation runInstancesInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @Nullable @BinderParam(IfNotNullBindAvailabilityZoneToFormParam.class) String nullableAvailabilityZone, + @FormParam("ImageId") String imageId, @FormParam("MinCount") int minCount, + @FormParam("MaxCount") int maxCount, RunInstancesOptions... options); + + /** + * Requests a reboot of one or more instances. This operation is + * asynchronous; it only queues a request to reboot the specified + * instance(s). The operation will succeed if the instances are valid and + * belong to you. Requests to reboot terminated instances are ignored.

+ * Note

If a Linux/UNIX instance does not cleanly shut down within four + * minutes, Amazon EC2 will perform a hard reboot. + * + * @param region + * Instances are tied to Availability Zones. However, the instance + * ID is tied to the Region. + * + * @param instanceIds + * Instance ID to reboot. + * + * @see #startInstancesInRegion + * @see #runInstancesInRegion + * @see #describeInstancesInRegion + * @see #terminateInstancesInRegion + * @see + */ + @Named("RebootInstances") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "RebootInstances") + void rebootInstancesInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds); /** * Shuts down one or more instances. This operation is idempotent; if you @@ -156,8 +235,15 @@ public interface InstanceClient { * @see */ - Set terminateInstancesInRegion(@Nullable String region, - String... instanceIds); + @Named("TerminateInstances") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "TerminateInstances") + @XMLResponseParser(InstanceStateChangeHandler.class) + @Fallback(EmptySetOnNotFoundOr404.class) + Set terminateInstancesInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds); /** * Stops an instance that uses an Amazon EBS volume as its root device. @@ -194,32 +280,15 @@ public interface InstanceClient { * @see */ - Set stopInstancesInRegion(@Nullable String region, - boolean force, String... instanceIds); - - /** - * Requests a reboot of one or more instances. This operation is - * asynchronous; it only queues a request to reboot the specified - * instance(s). The operation will succeed if the instances are valid and - * belong to you. Requests to reboot terminated instances are ignored.

- * Note

If a Linux/UNIX instance does not cleanly shut down within four - * minutes, Amazon EC2 will perform a hard reboot. - * - * @param region - * Instances are tied to Availability Zones. However, the instance - * ID is tied to the Region. - * - * @param instanceIds - * Instance ID to reboot. - * - * @see #startInstancesInRegion - * @see #runInstancesInRegion - * @see #describeInstancesInRegion - * @see #terminateInstancesInRegion - * @see
- */ - void rebootInstancesInRegion(@Nullable String region, String... instanceIds); + @Named("StopInstances") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "StopInstances") + @XMLResponseParser(InstanceStateChangeHandler.class) + Set stopInstancesInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("Force") boolean force, + @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds); /** * Starts an instance that uses an Amazon EBS volume as its root device. @@ -250,8 +319,14 @@ public interface InstanceClient { * @see */ - Set startInstancesInRegion(@Nullable String region, - String... instanceIds); + @Named("StartInstances") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "StartInstances") + @XMLResponseParser(InstanceStateChangeHandler.class) + Set startInstancesInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds); /** * @@ -262,8 +337,14 @@ public interface InstanceClient { * which instance to describe the attribute of * @return unencoded user data */ - String getUserDataForInstanceInRegion(@Nullable String region, - String instanceId); + @Named("DescribeInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "userData" }) + @XMLResponseParser(UnencodeStringValueHandler.class) + String getUserDataForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId); /** * @@ -274,8 +355,14 @@ public interface InstanceClient { * which instance to describe the attribute of * @return The root device name (e.g., /dev/sda1). */ - String getRootDeviceNameForInstanceInRegion(@Nullable String region, - String instanceId); + @Named("DescribeInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "rootDeviceName" }) + @XMLResponseParser(StringValueHandler.class) + String getRootDeviceNameForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId); /** * @@ -286,8 +373,14 @@ public interface InstanceClient { * which instance to describe the attribute of * @return the ID of the RAM disk associated with the AMI. */ - String getRamdiskForInstanceInRegion(@Nullable String region, - String instanceId); + @Named("DescribeInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "ramdisk" }) + @XMLResponseParser(StringValueHandler.class) + String getRamdiskForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId); /** * @@ -298,8 +391,14 @@ public interface InstanceClient { * which instance to describe the attribute of * @return the ID of the kernel associated with the AMI. */ - String getKernelForInstanceInRegion(@Nullable String region, - String instanceId); + @Named("DescribeInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "kernel" }) + @XMLResponseParser(StringValueHandler.class) + String getKernelForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId); /** * @@ -312,8 +411,14 @@ public interface InstanceClient { * You must modify this attribute before you can terminate any * "locked" instances from the APIs. */ - boolean isApiTerminationDisabledForInstanceInRegion(@Nullable String region, - String instanceId); + @Named("DescribeInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "disableApiTermination" }) + @XMLResponseParser(BooleanValueHandler.class) + boolean isApiTerminationDisabledForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId); /** * @@ -324,8 +429,14 @@ public interface InstanceClient { * which instance to describe the attribute of * @return The instance type of the instance. */ - String getInstanceTypeForInstanceInRegion(@Nullable String region, - String instanceId); + @Named("DescribeInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "instanceType" }) + @XMLResponseParser(InstanceTypeHandler.class) + String getInstanceTypeForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId); /** * @@ -337,8 +448,15 @@ public interface InstanceClient { * @return whether the instance's Amazon EBS volumes are stopped or * terminated when the instance is shut down. */ + @Named("DescribeInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", + "instanceInitiatedShutdownBehavior" }) + @XMLResponseParser(InstanceInitiatedShutdownBehaviorHandler.class) InstanceInitiatedShutdownBehavior getInstanceInitiatedShutdownBehaviorForInstanceInRegion( - String region, String instanceId); + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId); /** * @@ -350,8 +468,14 @@ public interface InstanceClient { * @return Describes the mapping that defines native device names to use when * exposing virtual devices. */ + @Named("DescribeInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "blockDeviceMapping" }) + @XMLResponseParser(BlockDeviceMappingHandler.class) Map getBlockDeviceMappingForInstanceInRegion( - @Nullable String region, String instanceId); + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId); /** * Resets an attribute of an instance to its default value. @@ -363,8 +487,13 @@ public interface InstanceClient { * which instance to reset the attribute of * @return the ID of the RAM disk associated with the AMI. */ - String resetRamdiskForInstanceInRegion(@Nullable String region, - String instanceId); + @Named("ResetInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "ResetInstanceAttribute", "ramdisk" }) + void resetRamdiskForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId); /** * Resets an attribute of an instance to its default value. @@ -376,8 +505,13 @@ public interface InstanceClient { * which instance to reset the attribute of * @return the ID of the kernel associated with the AMI. */ - String resetKernelForInstanceInRegion(@Nullable String region, - String instanceId); + @Named("ResetInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "ResetInstanceAttribute", "kernel" }) + void resetKernelForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId); /** * Sets the userData used for starting the instance. @@ -400,8 +534,14 @@ public interface InstanceClient { * @see */ - void setUserDataForInstanceInRegion(@Nullable String region, - String instanceId, byte[] unencodedData); + @Named("ModifyInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "userData" }) + void setUserDataForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId, + @FormParam("Value") @ParamParser(ConvertUnencodedBytesToBase64EncodedString.class) byte[] unencodedData); /** * Sets the ramdisk used for starting the instance. @@ -424,8 +564,13 @@ public interface InstanceClient { * @see */ - void setRamdiskForInstanceInRegion(@Nullable String region, - String instanceId, String ramdisk); + @Named("ModifyInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "ramdisk" }) + void setRamdiskForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId, @FormParam("Value") String ramdisk); /** * Sets the kernelId used for starting the instance. @@ -448,8 +593,13 @@ public interface InstanceClient { * @see */ - void setKernelForInstanceInRegion(@Nullable String region, - String instanceId, String kernel); + @Named("ModifyInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "kernel" }) + void setKernelForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId, @FormParam("Value") String kernel); /** * This command works while the instance is running and controls whether or @@ -465,8 +615,13 @@ public interface InstanceClient { * @see */ - void setApiTerminationDisabledForInstanceInRegion(@Nullable String region, - String instanceId, boolean apiTerminationDisabled); + @Named("ModifyInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "disableApiTermination" }) + void setApiTerminationDisabledForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId, @FormParam("Value") boolean apiTerminationDisabled); /** * Sets the instanceType used for starting the instance. @@ -489,8 +644,13 @@ public interface InstanceClient { * @see */ - void setInstanceTypeForInstanceInRegion(@Nullable String region, - String instanceId, String instanceType); + @Named("ModifyInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "instanceType" }) + void setInstanceTypeForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId, @FormParam("Value") String instanceType); /** * Specifies whether the instance's Amazon EBS volumes are stopped or @@ -515,9 +675,15 @@ public interface InstanceClient { * @see */ + @Named("ModifyInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", + "instanceInitiatedShutdownBehavior" }) void setInstanceInitiatedShutdownBehaviorForInstanceInRegion( - @Nullable String region, String instanceId, - InstanceInitiatedShutdownBehavior instanceInitiatedShutdownBehavior); + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId, + @FormParam("Value") InstanceInitiatedShutdownBehavior instanceInitiatedShutdownBehavior); /** * Sets the blockDeviceMapping used for an instance. @@ -564,8 +730,14 @@ public interface InstanceClient { * @see */ - void setBlockDeviceMappingForInstanceInRegion(@Nullable String region, - String instanceId, Map blockDeviceMapping); + @Named("ModifyInstanceAttribute") + @POST + @Path("/") + @FormParams(keys = { ACTION }, values = { "ModifyInstanceAttribute" }) + void setBlockDeviceMappingForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId, + @BinderParam(BindBlockDeviceMappingToIndexedFormParams.class) Map blockDeviceMapping); /** * Retrieves console output for the specified instance. @@ -582,6 +754,12 @@ public interface InstanceClient { * @see * ApiReference query GetConsoleOutput */ - String getConsoleOutputForInstanceInRegion(@Nullable String region, - String instanceId); + @Named("GetConsoleOutput") + @POST + @Path("/") + @FormParams(keys = { ACTION }, values = { "GetConsoleOutput" }) + @XMLResponseParser(GetConsoleOutputResponseHandler.class) + String getConsoleOutputForInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/KeyPairAsyncClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/features/KeyPairApi.java similarity index 59% rename from apis/ec2/src/main/java/org/jclouds/ec2/services/KeyPairAsyncClient.java rename to apis/ec2/src/main/java/org/jclouds/ec2/features/KeyPairApi.java index 48e0059772..b09406e211 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/KeyPairAsyncClient.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/features/KeyPairApi.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.jclouds.aws.reference.FormParameters.ACTION; @@ -41,8 +41,6 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.VirtualHost; import org.jclouds.rest.annotations.XMLResponseParser; -import com.google.common.util.concurrent.ListenableFuture; - /** * Provides access to EC2 via their REST API. *

@@ -51,22 +49,50 @@ import com.google.common.util.concurrent.ListenableFuture; */ @RequestFilters(FormSigner.class) @VirtualHost -public interface KeyPairAsyncClient { +public interface KeyPairApi { /** - * @see KeyPairClient#createKeyPairInRegion + * Creates a new 2048-bit RSA key pair with the specified name. The public key is stored by + * Amazon EC2 and the private key is displayed on the console. The private key is returned as an + * unencrypted PEM encoded PKCS#8 private key. If a key with the specified name already exists, + * Amazon EC2 returns an error. + * + * @param region + * Key pairs (to connect to instances) are Region-specific. + * @param keyName + * A unique name for the key pair. + * + * @see #runInstances + * @see #describeKeyPairs + * @see #deleteKeyPair + * + * @see */ @Named("CreateKeyPair") @POST @Path("/") @FormParams(keys = ACTION, values = "CreateKeyPair") @XMLResponseParser(KeyPairResponseHandler.class) - ListenableFuture createKeyPairInRegion( + KeyPair createKeyPairInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("KeyName") String keyName); /** - * @see KeyPairClient#describeKeyPairsInRegion + * Returns information about key pairs available to you. If you specify key pairs, information + * about those key pairs is returned. Otherwise, information for all registered key pairs is + * returned. + * + * @param region + * Key pairs (to connect to instances) are Region-specific. + * @param keyPairNames + * Key pairs to describe. + * + * @see #runInstances + * @see #describeAvailabilityZones + * @see */ @Named("DescribeKeyPairs") @POST @@ -74,18 +100,31 @@ public interface KeyPairAsyncClient { @FormParams(keys = ACTION, values = "DescribeKeyPairs") @XMLResponseParser(DescribeKeyPairsResponseHandler.class) @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> describeKeyPairsInRegion( + Set describeKeyPairsInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @BinderParam(BindKeyNamesToIndexedFormParams.class) String... keyPairNames); /** - * @see KeyPairClient#deleteKeyPairInRegion + * Deletes the specified key pair, by removing the public key from Amazon EC2. You must own the + * key pair + * + * @param region + * Key pairs (to connect to instances) are Region-specific. + * @param keyName + * Name of the key pair to delete + * + * @see #describeKeyPairs + * @see #createKeyPair + * + * @see */ @Named("DeleteKeyPair") @POST @Path("/") @FormParams(keys = ACTION, values = "DeleteKeyPair") - ListenableFuture deleteKeyPairInRegion( + void deleteKeyPairInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("KeyName") String keyName); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/SecurityGroupClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/features/SecurityGroupApi.java similarity index 69% rename from apis/ec2/src/main/java/org/jclouds/ec2/services/SecurityGroupClient.java rename to apis/ec2/src/main/java/org/jclouds/ec2/features/SecurityGroupApi.java index 23c8272a16..70cbdac557 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/SecurityGroupClient.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/features/SecurityGroupApi.java @@ -14,13 +14,35 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; + +import static org.jclouds.aws.reference.FormParameters.ACTION; import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; +import org.jclouds.aws.filters.FormSigner; +import org.jclouds.ec2.binders.BindGroupNamesToIndexedFormParams; +import org.jclouds.ec2.binders.BindUserIdGroupPairToSourceSecurityGroupFormParams; import org.jclouds.ec2.domain.SecurityGroup; import org.jclouds.ec2.domain.UserIdGroupPair; +import org.jclouds.ec2.xml.DescribeSecurityGroupsResponseHandler; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; import org.jclouds.net.domain.IpProtocol; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.FormParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.VirtualHost; +import org.jclouds.rest.annotations.XMLResponseParser; /** * Provides access to EC2 via their REST API. @@ -28,7 +50,9 @@ import org.jclouds.net.domain.IpProtocol; * * @author Adrian Cole */ -public interface SecurityGroupClient { +@RequestFilters(FormSigner.class) +@VirtualHost +public interface SecurityGroupApi { /** * Creates a new security group. Group names must be unique per identity. @@ -53,7 +77,13 @@ public interface SecurityGroupClient { * @see */ - void createSecurityGroupInRegion(@Nullable String region, String name, String description); + @Named("CreateSecurityGroup") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "CreateSecurityGroup") + void createSecurityGroupInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("GroupName") String name, @FormParam("GroupDescription") String description); /** * Deletes a security group that you own. @@ -73,7 +103,13 @@ public interface SecurityGroupClient { * @see */ - void deleteSecurityGroupInRegion(@Nullable String region, String name); + @Named("DeleteSecurityGroup") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DeleteSecurityGroup") + @Fallback(VoidOnNotFoundOr404.class) + void deleteSecurityGroupInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupName") String name); /** * Returns information about security groups that you own. @@ -93,8 +129,15 @@ public interface SecurityGroupClient { * @see */ - Set describeSecurityGroupsInRegion(@Nullable String region, - String... securityGroupNames); + @Named("DescribeSecurityGroups") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DescribeSecurityGroups") + @XMLResponseParser(DescribeSecurityGroupsResponseHandler.class) + @Fallback(EmptySetOnNotFoundOr404.class) + Set describeSecurityGroupsInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @BinderParam(BindGroupNamesToIndexedFormParams.class) String... securityGroupNames); /** * @@ -117,8 +160,14 @@ public interface SecurityGroupClient { * @see * - * @see doc - * @see SubnetAsyncApi + * @see doc * @author Adrian Cole * @author Andrew Bayer */ @SinceApiVersion("2011-01-01") +@RequestFilters(FormSigner.class) +@VirtualHost public interface SubnetApi { - /** * Describes all of your subnets for your EC2 resources. * @@ -43,6 +58,12 @@ public interface SubnetApi { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSubnets.html" * >docs */ + @Named("DescribeSubnets") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DescribeSubnets") + @XMLResponseParser(DescribeSubnetsResponseHandler.class) + @Fallback(EmptyFluentIterableOnNotFoundOr404.class) FluentIterable list(); /** @@ -61,6 +82,13 @@ public interface SubnetApi { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSubnets.html" * >docs */ - FluentIterable filter(Multimap filter); + @Named("DescribeSubnets") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DescribeSubnets") + @XMLResponseParser(DescribeSubnetsResponseHandler.class) + @Fallback(EmptyFluentIterableOnNotFoundOr404.class) + FluentIterable filter( + @BinderParam(BindFiltersToIndexedFormParams.class) Multimap filter); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/features/SubnetAsyncApi.java b/apis/ec2/src/main/java/org/jclouds/ec2/features/SubnetAsyncApi.java deleted file mode 100644 index 25454a2b43..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/features/SubnetAsyncApi.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.features; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import javax.inject.Named; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.ec2.binders.BindFiltersToIndexedFormParams; -import org.jclouds.ec2.domain.Subnet; -import org.jclouds.ec2.xml.DescribeSubnetsResponseHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.SinceApiVersion; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.collect.FluentIterable; -import com.google.common.collect.Multimap; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Amazon EC2 via the Query API - *

- * - * @see doc - * @see SubnetApi - * @author Adrian Cole - * @author Andrew Bayer - */ -@SinceApiVersion("2011-01-01") -@RequestFilters(FormSigner.class) -@VirtualHost -public interface SubnetAsyncApi { - /** - * @see SubnetApi#list() - * @see docs - */ - @Named("DescribeSubnets") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DescribeSubnets") - @XMLResponseParser(DescribeSubnetsResponseHandler.class) - @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> list(); - - /** - * @see SubnetApi#filter - * @see docs - */ - @Named("DescribeSubnets") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DescribeSubnets") - @XMLResponseParser(DescribeSubnetsResponseHandler.class) - @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> filter( - @BinderParam(BindFiltersToIndexedFormParams.class) Multimap filter); - -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/features/TagApi.java b/apis/ec2/src/main/java/org/jclouds/ec2/features/TagApi.java index 42ac6326a4..cdc6623c34 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/features/TagApi.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/features/TagApi.java @@ -16,28 +16,45 @@ */ package org.jclouds.ec2.features; +import static org.jclouds.aws.reference.FormParameters.ACTION; + import java.util.Map; + +import javax.inject.Named; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; +import org.jclouds.aws.filters.FormSigner; +import org.jclouds.ec2.binders.BindFiltersToIndexedFormParams; +import org.jclouds.ec2.binders.BindResourceIdsToIndexedFormParams; +import org.jclouds.ec2.binders.BindTagKeysToIndexedFormParams; +import org.jclouds.ec2.binders.BindTagsToIndexedFormParams; import org.jclouds.ec2.domain.Tag; -import org.jclouds.ec2.util.TagFilterBuilder; +import org.jclouds.ec2.xml.DescribeTagsResponseHandler; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.FormParams; +import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SinceApiVersion; +import org.jclouds.rest.annotations.VirtualHost; +import org.jclouds.rest.annotations.XMLResponseParser; import com.google.common.collect.FluentIterable; import com.google.common.collect.Multimap; - /** - * To help you manage your Amazon EC2 instances, images, and other Amazon EC2 - * resources, you can assign your own metadata to each resource in the form of - * tags. + * Provides access to Amazon EC2 via the Query API + *

* * @see doc - * @see TagAsyncApi * @author Adrian Cole */ @SinceApiVersion("2010-08-31") +@RequestFilters(FormSigner.class) +@VirtualHost public interface TagApi { - /** * Adds or overwrites one or more tags for the specified resource or * resources. Each resource can have a maximum of 10 tags. Each tag consists @@ -58,7 +75,12 @@ public interface TagApi { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateTags.html" * >docs */ - void applyToResources(Map tags, Iterable resourceIds); + @Named("CreateTags") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "CreateTags") + void applyToResources(@BinderParam(BindTagsToIndexedFormParams.class) Iterable tags, + @BinderParam(BindResourceIdsToIndexedFormParams.class) Iterable resourceIds); /** * like {@link #applyToResources(Map, Iterable)} except that the tags have no @@ -72,7 +94,12 @@ public interface TagApi { * * @see #applyToResources(Map, Iterable) */ - void applyToResources(Iterable tags, Iterable resourceIds); + @Named("CreateTags") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "CreateTags") + void applyToResources(@BinderParam(BindTagsToIndexedFormParams.class) Map tags, + @BinderParam(BindResourceIdsToIndexedFormParams.class) Iterable resourceIds); /** * Describes all of your tags for your EC2 resources. @@ -82,6 +109,12 @@ public interface TagApi { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeTags.html" * >docs */ + @Named("DescribeTags") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DescribeTags") + @XMLResponseParser(DescribeTagsResponseHandler.class) + @Fallback(EmptyFluentIterableOnNotFoundOr404.class) FluentIterable list(); /** @@ -100,7 +133,14 @@ public interface TagApi { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeTags.html" * >docs */ - FluentIterable filter(Multimap filter); + @Named("DescribeTags") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DescribeTags") + @XMLResponseParser(DescribeTagsResponseHandler.class) + @Fallback(EmptyFluentIterableOnNotFoundOr404.class) + FluentIterable filter( + @BinderParam(BindFiltersToIndexedFormParams.class) Multimap filter); /** * Deletes a specific set of tags from a specific set of resources. This call @@ -124,7 +164,13 @@ public interface TagApi { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeleteTags.html" * >docs */ - void deleteFromResources(Iterable tags, Iterable resourceIds); + @Named("DeleteTags") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DeleteTags") + void deleteFromResources( + @BinderParam(BindTagKeysToIndexedFormParams.class) Iterable tags, + @BinderParam(BindResourceIdsToIndexedFormParams.class) Iterable resourceIds); /** * like {@link #deleteFromResources(Iterable, Iterable)}, except that the @@ -144,6 +190,12 @@ public interface TagApi { * {@code ami-1a2b3c4d} * @see #deleteFromResources(Iterable, Iterable) */ - void conditionallyDeleteFromResources(Map conditionalTagValues, Iterable resourceIds); + @Named("DeleteTags") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DeleteTags") + void conditionallyDeleteFromResources( + @BinderParam(BindTagsToIndexedFormParams.class) Map conditionalTagValues, + @BinderParam(BindResourceIdsToIndexedFormParams.class) Iterable resourceIds); } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/features/TagAsyncApi.java b/apis/ec2/src/main/java/org/jclouds/ec2/features/TagAsyncApi.java deleted file mode 100644 index 013df70bf5..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/features/TagAsyncApi.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.features; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import java.util.Map; - -import javax.inject.Named; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.ec2.binders.BindFiltersToIndexedFormParams; -import org.jclouds.ec2.binders.BindResourceIdsToIndexedFormParams; -import org.jclouds.ec2.binders.BindTagKeysToIndexedFormParams; -import org.jclouds.ec2.binders.BindTagsToIndexedFormParams; -import org.jclouds.ec2.domain.Tag; -import org.jclouds.ec2.xml.DescribeTagsResponseHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.SinceApiVersion; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.collect.FluentIterable; -import com.google.common.collect.Multimap; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to Amazon EC2 via the Query API - *

- * - * @see doc - * @see TagApi - * @author Adrian Cole - */ -@SinceApiVersion("2010-08-31") -@RequestFilters(FormSigner.class) -@VirtualHost -public interface TagAsyncApi { - /** - * @see TagApi#applyToResources(Iterable, Iterable) - * @see docs - */ - @Named("CreateTags") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "CreateTags") - ListenableFuture applyToResources(@BinderParam(BindTagsToIndexedFormParams.class) Iterable tags, - @BinderParam(BindResourceIdsToIndexedFormParams.class) Iterable resourceIds); - - /** - * @see TagApi#applyToResources(Map, Iterable) - * @see docs - */ - @Named("CreateTags") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "CreateTags") - ListenableFuture applyToResources(@BinderParam(BindTagsToIndexedFormParams.class) Map tags, - @BinderParam(BindResourceIdsToIndexedFormParams.class) Iterable resourceIds); - - /** - * @see TagApi#list() - * @see docs - */ - @Named("DescribeTags") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DescribeTags") - @XMLResponseParser(DescribeTagsResponseHandler.class) - @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> list(); - - /** - * @see TagApi#filter - * @see docs - */ - @Named("DescribeTags") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DescribeTags") - @XMLResponseParser(DescribeTagsResponseHandler.class) - @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> filter( - @BinderParam(BindFiltersToIndexedFormParams.class) Multimap filter); - - /** - * @see TagApi#deleteFromResources - * @see docs - */ - @Named("DeleteTags") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DeleteTags") - ListenableFuture deleteFromResources( - @BinderParam(BindTagKeysToIndexedFormParams.class) Iterable tags, - @BinderParam(BindResourceIdsToIndexedFormParams.class) Iterable resourceIds); - - /** - * @see TagApi#conditionallyDeleteFromResources - * @see docs - */ - @Named("DeleteTags") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DeleteTags") - ListenableFuture conditionallyDeleteFromResources( - @BinderParam(BindTagsToIndexedFormParams.class) Map conditionalTagValues, - @BinderParam(BindResourceIdsToIndexedFormParams.class) Iterable resourceIds); - -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/features/WindowsApi.java b/apis/ec2/src/main/java/org/jclouds/ec2/features/WindowsApi.java index c74fc20264..b895d0bdae 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/features/WindowsApi.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/features/WindowsApi.java @@ -16,23 +16,165 @@ */ package org.jclouds.ec2.features; -import org.jclouds.ec2.domain.PasswordData; -import org.jclouds.rest.annotations.SinceApiVersion; +import static org.jclouds.aws.reference.FormParameters.ACTION; -import com.google.common.annotations.Beta; +import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.aws.filters.FormSigner; +import org.jclouds.ec2.binders.BindBundleIdsToIndexedFormParams; +import org.jclouds.ec2.binders.BindS3UploadPolicyAndSignature; +import org.jclouds.ec2.domain.BundleTask; +import org.jclouds.ec2.domain.PasswordData; +import org.jclouds.ec2.options.BundleInstanceS3StorageOptions; +import org.jclouds.ec2.xml.BundleTaskHandler; +import org.jclouds.ec2.xml.DescribeBundleTasksResponseHandler; +import org.jclouds.ec2.xml.GetPasswordDataResponseHandler; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.FormParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SinceApiVersion; +import org.jclouds.rest.annotations.VirtualHost; +import org.jclouds.rest.annotations.XMLResponseParser; /** * Provides access to EC2 Windows Features via the Query API *

* * @see doc - * @see WindowsAsyncApi * @author Adrian Cole */ -@Beta +@RequestFilters(FormSigner.class) +@VirtualHost @SinceApiVersion("2008-08-08") public interface WindowsApi { + /** + * Bundles the Windows instance. This procedure is not applicable for Linux + * and UNIX instances. For more information, go to the Amazon Elastic Compute + * Cloud Developer Guide or Amazon Elastic Compute Cloud Getting Started + * Guide. + * + * @param region + * Bundles are tied to the Region where its files are located + * within Amazon S3. + * + * @param instanceId + * The ID of the instance to bundle. + * @param prefix + * Specifies the beginning of the file name of the AMI. + * @param bucket + * The bucket in which to store the AMI. You can specify a bucket + * that you already own or a new bucket that Amazon EC2 creates on + * your behalf. If you specify a bucket that belongs to someone + * else, Amazon EC2 returns an error. + * @param uploadPolicy + * An Amazon S3 upload policy that gives Amazon EC2 permission to + * upload items into Amazon S3 on the user's behalf. + *

+ * ex. + * + *

+    * {"expiration": "2008-08-30T08:49:09Z","conditions": ["bucket": "my-bucket"},["starts-with", "$key", "my-new-image"]]}
+    * 
+ * + * @param options + * if the bucket isn't owned by you, use this to set the bucket's + * accesskeyid + * @return status of the work + * + * @see #cancelBundleTaskInRegion + * @see #describeBundleTasksInRegion + * + * @see + */ + @Named("BundleInstance") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "BundleInstance") + @XMLResponseParser(BundleTaskHandler.class) + BundleTask bundleInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId, @FormParam("Storage.S3.Prefix") String prefix, + @FormParam("Storage.S3.Bucket") String bucket, + @BinderParam(BindS3UploadPolicyAndSignature.class) String uploadPolicy, + BundleInstanceS3StorageOptions... options); + + /** + * Cancels an Amazon EC2 bundling operation. + * + * @param region + * The bundleTask ID is tied to the Region. + * @param bundleId + * The ID of the bundle task to cancel. + * @return task for the cancel. + * + * @see #bundleInstanceInRegion + * @see #describeBundleTasksInRegion + * + * @see + */ + @Named("CancelBundleTask") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "CancelBundleTask") + @XMLResponseParser(BundleTaskHandler.class) + BundleTask cancelBundleTaskInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("BundleId") String bundleId); + + /** + * + * Describes current bundling tasks. + * + * @param region + * The bundleTask ID is tied to the Region. + * + * @see #cancelBundleTaskInRegion + * @see #bundleInstanceInRegion + * @see + */ + @Named("DescribeBundleTasks") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DescribeBundleTasks") + @XMLResponseParser(DescribeBundleTasksResponseHandler.class) + @Fallback(EmptySetOnNotFoundOr404.class) + Set describeBundleTasksInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @BinderParam(BindBundleIdsToIndexedFormParams.class) String... bundleTaskIds); + + /** + * + * Retrieves the encrypted administrator password for the instances running Windows. + * + * @param region The region where the instance is based + * @param instanceId The ID of the instance to query + * @see + */ + @Named("GetPasswordData") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "GetPasswordData") + @XMLResponseParser(GetPasswordDataResponseHandler.class) + PasswordData getPasswordDataInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("InstanceId") String instanceId); + + /** * * Retrieves the encrypted administrator password for the instances running Windows.

Note

@@ -49,5 +191,12 @@ public interface WindowsApi { * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-GetPasswordData.html" * /> */ - PasswordData getPasswordDataForInstance(String instanceId); + @Named("GetPasswordData") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "GetPasswordData") + @XMLResponseParser(GetPasswordDataResponseHandler.class) + @Fallback(NullOnNotFoundOr404.class) + PasswordData getPasswordDataForInstance(@FormParam("InstanceId") String instanceId); + } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/features/WindowsAsyncApi.java b/apis/ec2/src/main/java/org/jclouds/ec2/features/WindowsAsyncApi.java deleted file mode 100644 index 3f8f02d786..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/features/WindowsAsyncApi.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.features; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.ec2.domain.PasswordData; -import org.jclouds.ec2.xml.GetPasswordDataResponseHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.SinceApiVersion; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.annotations.Beta; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to EC2 Windows Features via the Query API - *

- * - * @see doc - * @see WindowsAsyncApi - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -@Beta -@SinceApiVersion("2008-08-08") -public interface WindowsAsyncApi { - - /** - * @see WindowsApi#getPasswordDataForInstance - */ - @Named("GetPasswordData") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "GetPasswordData") - @XMLResponseParser(GetPasswordDataResponseHandler.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getPasswordDataForInstance(@FormParam("InstanceId") String instanceId); - -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java index 91e66183d5..ec655ae5ea 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java @@ -39,7 +39,7 @@ import com.google.inject.Inject; * * import static org.jclouds.ec2.options.BundleInstanceS3StorageOptions.Builder.* *

- * EC2Client connection = // get connection + * EC2Api connection = // get connection * String imageId = connection.getWindowsServices().bundleInstanceInRegion(...bucketOwnedBy(anotherAccessKey)); * * diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java index e6665cca6f..8c604d5143 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java @@ -29,8 +29,8 @@ import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; * * import static org.jclouds.ec2.options.CreateImageOptions.Builder.* *

- * EC2Client connection = // get connection - * Future> images = connection.getAMIServices().createImage(withDescription("123125").noReboot()); + * EC2Api connection = // get connection + * Future> images = connection.getAMIApi().get().createImage(withDescription("123125").noReboot()); * * * @author Adrian Cole diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java index 83dcd19b7d..2c05a27783 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java @@ -29,8 +29,8 @@ import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; * * import static org.jclouds.ec2.options.CreateSnapshotOptions.Builder.* *

- * EC2Client connection = // get connection - * Snapshot snapshot = connection.getElasticBlockStoreServices().createSnapshotInRegion(volumeId, withDescription("123125")); + * EC2Api connection = // get connection + * Snapshot snapshot = connection.getElasticBlockStoreApi().get().createSnapshotInRegion(volumeId, withDescription("123125")); * * * @author Adrian Cole diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java index c18e5e4747..5b3f6936c9 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java @@ -30,8 +30,8 @@ import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; * * import static org.jclouds.ec2.options.DescribeAvailabilityZonesOptions.Builder.* *

- * EC2Client connection = // get connection - * Future> images = connection.getAvailabilityZoneAndRegionServices().describeAvailabilityZones(zones("us-east-1a", "us-east-1b")); + * EC2Api connection = // get connection + * Future> images = connection.getAvailabilityZoneAndRegionApi().get().describeAvailabilityZones(zones("us-east-1a", "us-east-1b")); * * * @author Adrian Cole diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java index ffcf3e60f5..d81ba887d0 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java @@ -31,8 +31,8 @@ import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; * * import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.* *

- * EC2Client connection = // get connection - * Future> images = connection.getAMIServices().describeImages(executableBy("123125").imageIds(1000, 1004)); + * EC2Api connection = // get connection + * Future> images = connection.getAMIApi().get().describeImages(executableBy("123125").imageIds(1000, 1004)); * * * @author Adrian Cole diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java index d589e9d43e..594194d628 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java @@ -30,7 +30,7 @@ import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; * * import static org.jclouds.ec2.options.DescribeRegionsOptions.Builder.* *

- * EC2Client connection = // get connection + * EC2Api connection = // get connection * Future> images = connection.getRegionsAndRegionsServices().describeRegions(regions("us-east-1a", "us-east-1b")); * * diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java index d64e01ed7f..8dfe3cb7e0 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java @@ -29,8 +29,8 @@ import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; * * import static org.jclouds.ec2.options.DescribeSnapshotsOptions.Builder.* *

- * EC2Client connection = // get connection - * Set snapshots = connection.getElasticBlockStoreServices().describeSnapshots(restorableBy("123125").snapshotIds(1000, 1004)); + * EC2Api connection = // get connection + * Set snapshots = connection.getElasticBlockStoreApi().get().describeSnapshots(restorableBy("123125").snapshotIds(1000, 1004)); * * * @author Adrian Cole diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java index 8d957920ae..0b9fc89e02 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java @@ -29,8 +29,8 @@ import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; * * import static org.jclouds.ec2.options.DetachVolumeOptions.Builder.* *

- * EC2Client client = // get connection - * client.getElasticBlockStoreServices().detachVolumeInRegion(null, id, fromDevice("123125").force()); + * EC2Api client = // get connection + * client.getElasticBlockStoreApi().get().detachVolumeInRegion(null, id, fromDevice("123125").force()); * * * @author Adrian Cole diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java index 51e3024314..1da21c0ede 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java @@ -31,7 +31,7 @@ import org.jclouds.javax.annotation.Nullable; * * import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.* *

- * EC2Client connection = // get connection + * EC2Api connection = // get connection * String imageId = connection.getImageServices().registerImageBackedByEbs(...addEphemeralBlockDeviceFromSnapshot("/dev/sda2","virtual-1","snapshot-id")); * * diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java index da4c0eb9d3..76c2a01f85 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java @@ -30,7 +30,7 @@ import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; * * import static org.jclouds.ec2.options.RegisterImageOptions.Builder.* *

- * EC2Client connection = // get connection + * EC2Api connection = // get connection * String imageId = connection.getImageServices().registerImageFromManifest(...withArchitecture(Architecture.I386).withDescription("description")); * * diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java index 87d26861eb..25d4e7be9b 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java @@ -35,7 +35,7 @@ import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; * * import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.* *

- * EC2Client connection = // get connection + * EC2Api connection = // get connection * Future instances = connection.runInstances(executableBy("123125").imageIds(1000, 1004)); * * diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceHasIpAddress.java b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceHasIpAddress.java index 4908b3cc15..57d576d962 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceHasIpAddress.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceHasIpAddress.java @@ -20,7 +20,7 @@ import javax.annotation.Resource; import javax.inject.Singleton; import org.jclouds.aws.AWSResponseException; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.logging.Logger; @@ -37,13 +37,13 @@ import com.google.inject.Inject; @Singleton public class InstanceHasIpAddress implements Predicate { - private final EC2Client client; + private final EC2Api client; @Resource protected Logger logger = Logger.NULL; @Inject - public InstanceHasIpAddress(EC2Client client) { + public InstanceHasIpAddress(EC2Api client) { this.client = client; } @@ -60,7 +60,7 @@ public class InstanceHasIpAddress implements Predicate { } private RunningInstance refresh(RunningInstance instance) { - return Iterables.getOnlyElement(Iterables.getOnlyElement(client.getInstanceServices() + return Iterables.getOnlyElement(Iterables.getOnlyElement(client.getInstanceApi().get() .describeInstancesInRegion(instance.getRegion(), instance.getId()))); } } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java index 7239a3991e..893e6898f5 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java @@ -19,7 +19,7 @@ package org.jclouds.ec2.predicates; import javax.annotation.Resource; import javax.inject.Singleton; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.logging.Logger; @@ -38,13 +38,13 @@ import com.google.inject.Inject; @Singleton public class InstanceStateRunning implements Predicate { - private final EC2Client client; + private final EC2Api client; @Resource protected Logger logger = Logger.NULL; @Inject - public InstanceStateRunning(EC2Client client) { + public InstanceStateRunning(EC2Api client) { this.client = client; } @@ -63,7 +63,7 @@ public class InstanceStateRunning implements Predicate { private RunningInstance refresh(RunningInstance instance) { return Iterables.getOnlyElement(Iterables.getOnlyElement(client - .getInstanceServices().describeInstancesInRegion( + .getInstanceApi().get().describeInstancesInRegion( instance.getRegion(), instance.getId()))); } } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java index 9619c785c3..644d858124 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java @@ -21,7 +21,7 @@ import javax.inject.Singleton; import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.ec2.services.InstanceClient; +import org.jclouds.ec2.features.InstanceApi; import org.jclouds.logging.Logger; import com.google.common.base.Predicate; @@ -37,13 +37,13 @@ import com.google.inject.Inject; @Singleton public class InstanceStateStopped implements Predicate { - private final InstanceClient client; + private final InstanceApi client; @Resource protected Logger logger = Logger.NULL; @Inject - public InstanceStateStopped(InstanceClient client) { + public InstanceStateStopped(InstanceApi client) { this.client = client; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java index 7796e24e1c..8c9a3fdb10 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java @@ -21,7 +21,7 @@ import java.util.NoSuchElementException; import javax.annotation.Resource; import javax.inject.Singleton; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.logging.Logger; @@ -39,13 +39,13 @@ import com.google.inject.Inject; @Singleton public class InstanceStateTerminated implements Predicate { - private final EC2Client client; + private final EC2Api client; @Resource protected Logger logger = Logger.NULL; @Inject - public InstanceStateTerminated(EC2Client client) { + public InstanceStateTerminated(EC2Api client) { this.client = client; } @@ -62,7 +62,7 @@ public class InstanceStateTerminated implements Predicate { } private RunningInstance refresh(RunningInstance instance) { - return Iterables.getOnlyElement(Iterables.getOnlyElement(client.getInstanceServices() + return Iterables.getOnlyElement(Iterables.getOnlyElement(client.getInstanceApi().get() .describeInstancesInRegion(instance.getRegion(), instance.getId()))); } } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java index 658b144d25..ef5281a888 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java @@ -22,7 +22,7 @@ import javax.annotation.Resource; import javax.inject.Singleton; import org.jclouds.ec2.domain.Snapshot; -import org.jclouds.ec2.services.ElasticBlockStoreClient; +import org.jclouds.ec2.features.ElasticBlockStoreApi; import org.jclouds.logging.Logger; import com.google.common.base.Predicate; @@ -38,12 +38,12 @@ import com.google.inject.Inject; @Singleton public class SnapshotCompleted implements Predicate { - private final ElasticBlockStoreClient client; + private final ElasticBlockStoreApi client; @Resource protected Logger logger = Logger.NULL; @Inject - public SnapshotCompleted(ElasticBlockStoreClient client) { + public SnapshotCompleted(ElasticBlockStoreApi client) { this.client = client; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java index 2ce17e63a5..f3ebfaf2b2 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java @@ -21,7 +21,7 @@ import javax.inject.Singleton; import org.jclouds.ec2.domain.Attachment; import org.jclouds.ec2.domain.Volume; -import org.jclouds.ec2.services.ElasticBlockStoreClient; +import org.jclouds.ec2.features.ElasticBlockStoreApi; import org.jclouds.logging.Logger; import com.google.common.base.Predicate; @@ -38,12 +38,12 @@ import com.google.inject.Inject; @Singleton public class VolumeAttached implements Predicate { - private final ElasticBlockStoreClient client; + private final ElasticBlockStoreApi client; @Resource protected Logger logger = Logger.NULL; @Inject - public VolumeAttached(ElasticBlockStoreClient client) { + public VolumeAttached(ElasticBlockStoreApi client) { this.client = client; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java index ae394dcbb0..9688add7b3 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java @@ -20,7 +20,7 @@ import javax.annotation.Resource; import javax.inject.Singleton; import org.jclouds.ec2.domain.Volume; -import org.jclouds.ec2.services.ElasticBlockStoreClient; +import org.jclouds.ec2.features.ElasticBlockStoreApi; import org.jclouds.logging.Logger; import com.google.common.base.Predicate; @@ -36,12 +36,12 @@ import com.google.inject.Inject; @Singleton public class VolumeAvailable implements Predicate { - private final ElasticBlockStoreClient client; + private final ElasticBlockStoreApi client; @Resource protected Logger logger = Logger.NULL; @Inject - public VolumeAvailable(ElasticBlockStoreClient client) { + public VolumeAvailable(ElasticBlockStoreApi client) { this.client = client; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java index 6415eb0f76..accabe8284 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java @@ -22,7 +22,7 @@ import javax.annotation.Resource; import org.jclouds.ec2.domain.Attachment; import org.jclouds.ec2.domain.Volume; -import org.jclouds.ec2.services.ElasticBlockStoreClient; +import org.jclouds.ec2.features.ElasticBlockStoreApi; import org.jclouds.logging.Logger; import com.google.common.base.Predicate; @@ -38,12 +38,12 @@ import com.google.inject.Singleton; @Singleton public class VolumeDetached implements Predicate { - private final ElasticBlockStoreClient client; + private final ElasticBlockStoreApi client; @Resource protected Logger logger = Logger.NULL; @Inject - public VolumeDetached(ElasticBlockStoreClient client) { + public VolumeDetached(ElasticBlockStoreApi client) { this.client = client; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/AMIAsyncClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/services/AMIAsyncClient.java deleted file mode 100644 index cf079f0ac3..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/AMIAsyncClient.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import java.util.Map; -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.ec2.binders.BindUserGroupsToIndexedFormParams; -import org.jclouds.ec2.binders.BindUserIdsToIndexedFormParams; -import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.domain.Image.EbsBlockDevice; -import org.jclouds.ec2.domain.Permission; -import org.jclouds.ec2.options.CreateImageOptions; -import org.jclouds.ec2.options.DescribeImagesOptions; -import org.jclouds.ec2.options.RegisterImageBackedByEbsOptions; -import org.jclouds.ec2.options.RegisterImageOptions; -import org.jclouds.ec2.xml.BlockDeviceMappingHandler; -import org.jclouds.ec2.xml.DescribeImagesResponseHandler; -import org.jclouds.ec2.xml.ImageIdHandler; -import org.jclouds.ec2.xml.PermissionHandler; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.Fallback; -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 com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to AMI Services. - *

- * - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface AMIAsyncClient { - - /** - * @see AMIClient#describeImagesInRegion - */ - @Named("DescribeImages") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DescribeImages") - @XMLResponseParser(DescribeImagesResponseHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> describeImagesInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - DescribeImagesOptions... options); - - /** - * @see AMIClient#createImageInRegion - */ - @Named("CreateImage") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "CreateImage") - @XMLResponseParser(ImageIdHandler.class) - ListenableFuture createImageInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("Name") String name, @FormParam("InstanceId") String instanceId, CreateImageOptions... options); - - /** - * @see AMIClient#deregisterImageInRegion - */ - @Named("DeregisterImage") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DeregisterImage") - ListenableFuture deregisterImageInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("ImageId") String imageId); - - /** - * @see AMIClient#registerImageFromManifestInRegion - */ - @Named("RegisterImage") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "RegisterImage") - @XMLResponseParser(ImageIdHandler.class) - ListenableFuture registerImageFromManifestInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("Name") String imageName, @FormParam("ImageLocation") String pathToManifest, - RegisterImageOptions... options); - - /** - * @see AMIClient#registerUnixImageBackedByEbsInRegion - */ - @Named("RegisterImage") - @POST - @Path("/") - @FormParams(keys = { ACTION, "RootDeviceName", "BlockDeviceMapping.0.DeviceName" }, values = { "RegisterImage", - "/dev/sda1", "/dev/sda1" }) - @XMLResponseParser(ImageIdHandler.class) - ListenableFuture registerUnixImageBackedByEbsInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("Name") String imageName, - @FormParam("BlockDeviceMapping.0.Ebs.SnapshotId") String ebsSnapshotId, - RegisterImageBackedByEbsOptions... options); - - /** - * @see AMIClient#resetLaunchPermissionsOnImageInRegion - */ - @Named("ResetImageAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "ResetImageAttribute", "launchPermission" }) - ListenableFuture resetLaunchPermissionsOnImageInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("ImageId") String imageId); - - /** - * @see AMIClient#addLaunchPermissionsToImageInRegion - */ - @Named("ModifyImageAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute", "add", - "launchPermission" }) - ListenableFuture addLaunchPermissionsToImageInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @BinderParam(BindUserIdsToIndexedFormParams.class) Iterable userIds, - @BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable userGroups, - @FormParam("ImageId") String imageId); - - /** - * @see AMIClient#removeLaunchPermissionsToImageInRegion - */ - @Named("ModifyImageAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute", "remove", - "launchPermission" }) - ListenableFuture removeLaunchPermissionsFromImageInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @BinderParam(BindUserIdsToIndexedFormParams.class) Iterable userIds, - @BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable userGroups, - @FormParam("ImageId") String imageId); - - /** - * @see AMIClient#getLaunchPermissionForImageInRegion - */ - @Named("DescribeImageAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute", "launchPermission" }) - @XMLResponseParser(PermissionHandler.class) - ListenableFuture getLaunchPermissionForImageInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("ImageId") String imageId); - - /** - * @see AMIClient#getBlockDeviceMappingsForImageInRegion - */ - @Named("DescribeImageAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute", "blockDeviceMapping" }) - @XMLResponseParser(BlockDeviceMappingHandler.class) - ListenableFuture> getBlockDeviceMappingsForImageInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("ImageId") String imageId); -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClient.java deleted file mode 100644 index 0eef9706d1..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClient.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import java.net.URI; -import java.util.Map; -import java.util.Set; -import org.jclouds.ec2.domain.AvailabilityZoneInfo; -import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions; -import org.jclouds.ec2.options.DescribeRegionsOptions; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides EC2 Availability Zones and Regions services for EC2. - *

- * - * @author Adrian Cole - */ -public interface AvailabilityZoneAndRegionClient { - - /** - * Displays Availability Zones that are currently available to the identity and their states. - * - * @see InstanceClient#runInstances - * @see #describeRegions - * - * @see - */ - Set describeAvailabilityZonesInRegion(@Nullable String region, - DescribeAvailabilityZonesOptions... options); - - /** - * Describes Regions that are currently available to the identity. - * - * @see InstanceClient#runInstances - * @see #describeAvailabilityZones - * - * @see - */ - Map describeRegions(DescribeRegionsOptions... options); -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClient.java deleted file mode 100644 index 3b0ccd2d1d..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClient.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.ec2.EC2Fallbacks.VoidOnVolumeAvailable; -import org.jclouds.ec2.binders.BindUserGroupsToIndexedFormParams; -import org.jclouds.ec2.binders.BindUserIdsToIndexedFormParams; -import org.jclouds.ec2.binders.BindVolumeIdsToIndexedFormParams; -import org.jclouds.ec2.domain.Attachment; -import org.jclouds.ec2.domain.Permission; -import org.jclouds.ec2.domain.Snapshot; -import org.jclouds.ec2.domain.Volume; -import org.jclouds.ec2.options.CreateSnapshotOptions; -import org.jclouds.ec2.options.DescribeSnapshotsOptions; -import org.jclouds.ec2.options.DetachVolumeOptions; -import org.jclouds.ec2.xml.AttachmentHandler; -import org.jclouds.ec2.xml.CreateVolumeResponseHandler; -import org.jclouds.ec2.xml.DescribeSnapshotsResponseHandler; -import org.jclouds.ec2.xml.DescribeVolumesResponseHandler; -import org.jclouds.ec2.xml.PermissionHandler; -import org.jclouds.ec2.xml.SnapshotHandler; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; -import org.jclouds.location.functions.ZoneToEndpoint; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.Fallback; -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 com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to EC2 Elastic Block Store services via their REST API. - *

- * - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface ElasticBlockStoreAsyncClient { - - /** - * @see ElasticBlockStoreClient#createVolumeFromSnapshotInAvailabilityZone - */ - @Named("CreateVolume") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "CreateVolume") - @XMLResponseParser(CreateVolumeResponseHandler.class) - ListenableFuture createVolumeFromSnapshotInAvailabilityZone( - @EndpointParam(parser = ZoneToEndpoint.class) @FormParam("AvailabilityZone") String availabilityZone, - @FormParam("SnapshotId") String snapshotId); - - /** - * @see ElasticBlockStoreClient#createVolumeFromSnapshotInAvailabilityZone - */ - @Named("CreateVolume") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "CreateVolume") - @XMLResponseParser(CreateVolumeResponseHandler.class) - ListenableFuture createVolumeFromSnapshotInAvailabilityZone( - @EndpointParam(parser = ZoneToEndpoint.class) @FormParam("AvailabilityZone") String availabilityZone, - @FormParam("Size") int size, @FormParam("SnapshotId") String snapshotId); - - /** - * @see ElasticBlockStoreClient#createVolumeInAvailabilityZone - */ - @Named("CreateVolume") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "CreateVolume") - @XMLResponseParser(CreateVolumeResponseHandler.class) - ListenableFuture createVolumeInAvailabilityZone( - @EndpointParam(parser = ZoneToEndpoint.class) @FormParam("AvailabilityZone") String availabilityZone, - @FormParam("Size") int size); - - /** - * @see ElasticBlockStoreClient#describeVolumesInRegion - */ - @POST - @Named("DescribeVolumes") - @Path("/") - @FormParams(keys = ACTION, values = "DescribeVolumes") - @XMLResponseParser(DescribeVolumesResponseHandler.class) - ListenableFuture> describeVolumesInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @BinderParam(BindVolumeIdsToIndexedFormParams.class) String... volumeIds); - - /** - * @see ElasticBlockStoreClient#deleteVolumeInRegion - */ - @Named("DeleteVolume") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DeleteVolume") - ListenableFuture deleteVolumeInRegion(@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("VolumeId") String volumeId); - - /** - * @see ElasticBlockStoreClient#detachVolumeInRegion - */ - @Named("DetachVolume") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DetachVolume") - @Fallback(VoidOnVolumeAvailable.class) - ListenableFuture detachVolumeInRegion(@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("VolumeId") String volumeId, @FormParam("Force") boolean force, DetachVolumeOptions... options); - - /** - * @see ElasticBlockStoreClient#attachVolumeInRegion - */ - @Named("AttachVolume") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "AttachVolume") - @XMLResponseParser(AttachmentHandler.class) - ListenableFuture attachVolumeInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("VolumeId") String volumeId, @FormParam("InstanceId") String instanceId, - @FormParam("Device") String device); - - /** - * @see ElasticBlockStoreClient#createSnapshotInRegion - */ - @Named("CreateSnapshot") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "CreateSnapshot") - @XMLResponseParser(SnapshotHandler.class) - ListenableFuture createSnapshotInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("VolumeId") String volumeId, CreateSnapshotOptions... options); - - /** - * @see ElasticBlockStoreClient#describeSnapshotsInRegion - */ - @Named("DescribeSnapshots") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DescribeSnapshots") - @XMLResponseParser(DescribeSnapshotsResponseHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> describeSnapshotsInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - DescribeSnapshotsOptions... options); - - /** - * @see ElasticBlockStoreClient#deleteSnapshotInRegion - */ - @Named("DeleteSnapshot") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DeleteSnapshot") - ListenableFuture deleteSnapshotInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("SnapshotId") String snapshotId); - - /** - * @see ElasticBlockStoreClient#addCreateVolumePermissionsToSnapshotInRegion - */ - @Named("ModifySnapshotAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifySnapshotAttribute", "add", - "createVolumePermission" }) - ListenableFuture addCreateVolumePermissionsToSnapshotInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @BinderParam(BindUserIdsToIndexedFormParams.class) Iterable userIds, - @BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable userGroups, - @FormParam("SnapshotId") String snapshotId); - - /** - * @see ElasticBlockStoreClient#removeCreateVolumePermissionsFromSnapshotInRegion - */ - @Named("ModifySnapshotAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifySnapshotAttribute", "remove", - "createVolumePermission" }) - ListenableFuture removeCreateVolumePermissionsFromSnapshotInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @BinderParam(BindUserIdsToIndexedFormParams.class) Iterable userIds, - @BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable userGroups, - @FormParam("SnapshotId") String snapshotId); - - /** - * @see ElasticBlockStoreClient#getCreateVolumePermissionForSnapshotInRegion - */ - @Named("DescribeSnapshotAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeSnapshotAttribute", "createVolumePermission" }) - @XMLResponseParser(PermissionHandler.class) - ListenableFuture getCreateVolumePermissionForSnapshotInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("SnapshotId") String snapshotId); - - /** - * @see ElasticBlockStoreClient#resetCreateVolumePermissionsOnSnapshotInRegion - */ - @Named("ResetSnapshotAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "ResetSnapshotAttribute", "createVolumePermission" }) - ListenableFuture resetCreateVolumePermissionsOnSnapshotInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("SnapshotId") String snapshotId); - -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClient.java deleted file mode 100644 index 8369fa43d7..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClient.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.ec2.binders.BindPublicIpsToIndexedFormParams; -import org.jclouds.ec2.domain.PublicIpInstanceIdPair; -import org.jclouds.ec2.xml.AllocateAddressResponseHandler; -import org.jclouds.ec2.xml.DescribeAddressesResponseHandler; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.Fallback; -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 com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to EC2 Elastic IP Addresses via REST API. - *

- * - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface ElasticIPAddressAsyncClient { - - /** - * @see BaseEC2Client#allocateAddressInRegion - */ - @Named("AllocateAddress") - @POST - @Path("/") - @XMLResponseParser(AllocateAddressResponseHandler.class) - @FormParams(keys = ACTION, values = "AllocateAddress") - ListenableFuture allocateAddressInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); - - /** - * @see BaseEC2Client#associateAddressInRegion - */ - @Named("AssociateAddress") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "AssociateAddress") - ListenableFuture associateAddressInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("PublicIp") String publicIp, @FormParam("InstanceId") String instanceId); - - /** - * @see BaseEC2Client#disassociateAddressInRegion - */ - @Named("DisassociateAddress") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DisassociateAddress") - ListenableFuture disassociateAddressInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("PublicIp") String publicIp); - - /** - * @see BaseEC2Client#releaseAddressInRegion - */ - @Named("ReleaseAddress") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "ReleaseAddress") - ListenableFuture releaseAddressInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("PublicIp") String publicIp); - - /** - * @see BaseEC2Client#describeAddressesInRegion - */ - @Named("DescribeAddresses") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DescribeAddresses") - @XMLResponseParser(DescribeAddressesResponseHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> describeAddressesInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @BinderParam(BindPublicIpsToIndexedFormParams.class) String... publicIps); - -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/InstanceAsyncClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/services/InstanceAsyncClient.java deleted file mode 100644 index 0a1968d845..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/InstanceAsyncClient.java +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import java.util.Map; -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.ec2.binders.BindBlockDeviceMappingToIndexedFormParams; -import org.jclouds.ec2.binders.BindInstanceIdsToIndexedFormParams; -import org.jclouds.ec2.binders.IfNotNullBindAvailabilityZoneToFormParam; -import org.jclouds.ec2.domain.BlockDevice; -import org.jclouds.ec2.domain.InstanceStateChange; -import org.jclouds.ec2.domain.Reservation; -import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.ec2.domain.Volume.InstanceInitiatedShutdownBehavior; -import org.jclouds.ec2.functions.ConvertUnencodedBytesToBase64EncodedString; -import org.jclouds.ec2.options.RunInstancesOptions; -import org.jclouds.ec2.xml.BlockDeviceMappingHandler; -import org.jclouds.ec2.xml.BooleanValueHandler; -import org.jclouds.ec2.xml.DescribeInstancesResponseHandler; -import org.jclouds.ec2.xml.GetConsoleOutputResponseHandler; -import org.jclouds.ec2.xml.InstanceInitiatedShutdownBehaviorHandler; -import org.jclouds.ec2.xml.InstanceStateChangeHandler; -import org.jclouds.ec2.xml.InstanceTypeHandler; -import org.jclouds.ec2.xml.RunInstancesResponseHandler; -import org.jclouds.ec2.xml.StringValueHandler; -import org.jclouds.ec2.xml.UnencodeStringValueHandler; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.ParamParser; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to EC2 Instance Services via their REST API. - *

- * - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface InstanceAsyncClient { - - /** - * @see InstanceClient#describeInstancesInRegion - */ - @Named("DescribeInstances") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DescribeInstances") - @XMLResponseParser(DescribeInstancesResponseHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture>> describeInstancesInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds); - - /** - * @see InstanceClient#runInstancesInRegion - */ - @Named("RunInstances") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "RunInstances") - @XMLResponseParser(RunInstancesResponseHandler.class) - ListenableFuture> runInstancesInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @Nullable @BinderParam(IfNotNullBindAvailabilityZoneToFormParam.class) String nullableAvailabilityZone, - @FormParam("ImageId") String imageId, @FormParam("MinCount") int minCount, - @FormParam("MaxCount") int maxCount, RunInstancesOptions... options); - - /** - * @see InstanceClient#rebootInstancesInRegion - */ - @Named("RebootInstances") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "RebootInstances") - ListenableFuture rebootInstancesInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds); - - /** - * @see InstanceClient#terminateInstancesInRegion - */ - @Named("TerminateInstances") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "TerminateInstances") - @XMLResponseParser(InstanceStateChangeHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> terminateInstancesInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds); - - /** - * @see InstanceClient#stopInstancesInRegion - */ - @Named("StopInstances") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "StopInstances") - @XMLResponseParser(InstanceStateChangeHandler.class) - ListenableFuture> stopInstancesInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("Force") boolean force, - @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds); - - /** - * @see InstanceClient#startInstancesInRegion - */ - @Named("StartInstances") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "StartInstances") - @XMLResponseParser(InstanceStateChangeHandler.class) - ListenableFuture> startInstancesInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds); - - /** - * @see AMIClient#getUserDataForInstanceInRegion - */ - @Named("DescribeInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "userData" }) - @XMLResponseParser(UnencodeStringValueHandler.class) - ListenableFuture getUserDataForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId); - - /** - * @see AMIClient#getRootDeviceNameForInstanceInRegion - */ - @Named("DescribeInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "rootDeviceName" }) - @XMLResponseParser(StringValueHandler.class) - ListenableFuture getRootDeviceNameForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId); - - /** - * @see AMIClient#getRamdiskForInstanceInRegion - */ - @Named("DescribeInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "ramdisk" }) - @XMLResponseParser(StringValueHandler.class) - ListenableFuture getRamdiskForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId); - - /** - * @see AMIClient#getKernelForInstanceInRegion - */ - @Named("DescribeInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "kernel" }) - @XMLResponseParser(StringValueHandler.class) - ListenableFuture getKernelForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId); - - /** - * @see AMIClient#isApiTerminationDisabledForInstanceInRegion - */ - @Named("DescribeInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "disableApiTermination" }) - @XMLResponseParser(BooleanValueHandler.class) - ListenableFuture isApiTerminationDisabledForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId); - - /** - * @see AMIClient#getInstanceTypeForInstanceInRegion - */ - @Named("DescribeInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "instanceType" }) - @XMLResponseParser(InstanceTypeHandler.class) - ListenableFuture getInstanceTypeForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId); - - /** - * @see AMIClient#getInstanceInitiatedShutdownBehaviorForInstanceInRegion - */ - @Named("DescribeInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", - "instanceInitiatedShutdownBehavior" }) - @XMLResponseParser(InstanceInitiatedShutdownBehaviorHandler.class) - ListenableFuture getInstanceInitiatedShutdownBehaviorForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId); - - /** - * @see InstanceClient#getBlockDeviceMappingForInstanceInRegion - */ - @Named("DescribeInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeInstanceAttribute", "blockDeviceMapping" }) - @XMLResponseParser(BlockDeviceMappingHandler.class) - ListenableFuture> getBlockDeviceMappingForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId); - - /** - * @see AMIClient#resetRamdiskForInstanceInRegion - */ - @Named("ResetInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "ResetInstanceAttribute", "ramdisk" }) - ListenableFuture resetRamdiskForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId); - - /** - * @see AMIClient#resetKernelForInstanceInRegion - */ - @Named("ResetInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "ResetInstanceAttribute", "kernel" }) - ListenableFuture resetKernelForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId); - - /** - * @see AMIClient#setUserDataForInstanceInRegion - */ - @Named("ModifyInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "userData" }) - ListenableFuture setUserDataForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId, - @FormParam("Value") @ParamParser(ConvertUnencodedBytesToBase64EncodedString.class) byte[] unencodedData); - - /** - * @see AMIClient#setRamdiskForInstanceInRegion - */ - @Named("ModifyInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "ramdisk" }) - ListenableFuture setRamdiskForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId, @FormParam("Value") String ramdisk); - - /** - * @see AMIClient#setKernelForInstanceInRegion - */ - @Named("ModifyInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "kernel" }) - ListenableFuture setKernelForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId, @FormParam("Value") String kernel); - - /** - * @see AMIClient#setApiTerminationDisabledForInstanceInRegion - */ - @Named("ModifyInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "disableApiTermination" }) - ListenableFuture setApiTerminationDisabledForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId, @FormParam("Value") boolean apiTerminationDisabled); - - /** - * @see AMIClient#setInstanceTypeForInstanceInRegion - */ - @Named("ModifyInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", "instanceType" }) - ListenableFuture setInstanceTypeForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId, @FormParam("Value") String instanceType); - - /** - * @see AMIClient#setInstanceInitiatedShutdownBehaviorForInstanceInRegion - */ - @Named("ModifyInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION, "Attribute" }, values = { "ModifyInstanceAttribute", - "instanceInitiatedShutdownBehavior" }) - ListenableFuture setInstanceInitiatedShutdownBehaviorForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId, - @FormParam("Value") InstanceInitiatedShutdownBehavior instanceInitiatedShutdownBehavior); - - /** - * @see InstanceClient#setBlockDeviceMappingForInstanceInRegion - */ - @Named("ModifyInstanceAttribute") - @POST - @Path("/") - @FormParams(keys = { ACTION }, values = { "ModifyInstanceAttribute" }) - ListenableFuture setBlockDeviceMappingForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId, - @BinderParam(BindBlockDeviceMappingToIndexedFormParams.class) Map blockDeviceMapping); - - /** - * @see InstanceClient#getConsoleOutputForInstanceInRegion(String, String) - */ - @Named("GetConsoleOutput") - @POST - @Path("/") - @FormParams(keys = { ACTION }, values = { "GetConsoleOutput" }) - @XMLResponseParser(GetConsoleOutputResponseHandler.class) - ListenableFuture getConsoleOutputForInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId); -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/KeyPairClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/services/KeyPairClient.java deleted file mode 100644 index 0210f9d7b2..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/KeyPairClient.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import java.util.Set; -import org.jclouds.ec2.domain.KeyPair; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides access to EC2 via their REST API. - *

- * - * @author Adrian Cole - */ -public interface KeyPairClient { - - /** - * Creates a new 2048-bit RSA key pair with the specified name. The public key is stored by - * Amazon EC2 and the private key is displayed on the console. The private key is returned as an - * unencrypted PEM encoded PKCS#8 private key. If a key with the specified name already exists, - * Amazon EC2 returns an error. - * - * @param region - * Key pairs (to connect to instances) are Region-specific. - * @param keyName - * A unique name for the key pair. - * - * @see #runInstances - * @see #describeKeyPairs - * @see #deleteKeyPair - * - * @see - */ - KeyPair createKeyPairInRegion(@Nullable String region, String keyName); - - /** - * Returns information about key pairs available to you. If you specify key pairs, information - * about those key pairs is returned. Otherwise, information for all registered key pairs is - * returned. - * - * @param region - * Key pairs (to connect to instances) are Region-specific. - * @param keyPairNames - * Key pairs to describe. - * - * @see #runInstances - * @see #describeAvailabilityZones - * @see - */ - Set describeKeyPairsInRegion(@Nullable String region, String... keyPairNames); - - /** - * Deletes the specified key pair, by removing the public key from Amazon EC2. You must own the - * key pair - * - * @param region - * Key pairs (to connect to instances) are Region-specific. - * @param keyName - * Name of the key pair to delete - * - * @see #describeKeyPairs - * @see #createKeyPair - * - * @see - */ - void deleteKeyPairInRegion(@Nullable String region, String keyName); - -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/SecurityGroupAsyncClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/services/SecurityGroupAsyncClient.java deleted file mode 100644 index 0de10f9d31..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/SecurityGroupAsyncClient.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.ec2.binders.BindGroupNamesToIndexedFormParams; -import org.jclouds.ec2.binders.BindUserIdGroupPairToSourceSecurityGroupFormParams; -import org.jclouds.ec2.domain.SecurityGroup; -import org.jclouds.ec2.domain.UserIdGroupPair; -import org.jclouds.ec2.xml.DescribeSecurityGroupsResponseHandler; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; -import org.jclouds.net.domain.IpProtocol; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.Fallback; -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 com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to EC2 via their REST API. - *

- * - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface SecurityGroupAsyncClient { - - /** - * @see SecurityGroupClient#createSecurityGroupInRegion - */ - @Named("CreateSecurityGroup") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "CreateSecurityGroup") - ListenableFuture createSecurityGroupInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("GroupName") String name, @FormParam("GroupDescription") String description); - - /** - * @see SecurityGroupClient#deleteSecurityGroupInRegion - */ - @Named("DeleteSecurityGroup") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DeleteSecurityGroup") - @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture deleteSecurityGroupInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupName") String name); - - /** - * @see SecurityGroupClient#describeSecurityGroupsInRegion - */ - @Named("DescribeSecurityGroups") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DescribeSecurityGroups") - @XMLResponseParser(DescribeSecurityGroupsResponseHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> describeSecurityGroupsInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @BinderParam(BindGroupNamesToIndexedFormParams.class) String... securityGroupNames); - - /** - * @see SecurityGroupClient#authorizeSecurityGroupIngressInRegion(@ org.jclouds.javax.annotation.Nullable Region, - * String,UserIdGroupPair) - */ - @Named("AuthorizeSecurityGroupIngress") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress") - ListenableFuture authorizeSecurityGroupIngressInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("GroupName") String groupName, - @BinderParam(BindUserIdGroupPairToSourceSecurityGroupFormParams.class) UserIdGroupPair sourceSecurityGroup); - - /** - * @see SecurityGroupClient#authorizeSecurityGroupIngressInRegion(@ org.jclouds.javax.annotation.Nullable Region, - * String,IpProtocol,int,int,String) - */ - @Named("AuthorizeSecurityGroupIngress") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress") - ListenableFuture authorizeSecurityGroupIngressInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("GroupName") String groupName, @FormParam("IpProtocol") IpProtocol ipProtocol, - @FormParam("FromPort") int fromPort, @FormParam("ToPort") int toPort, @FormParam("CidrIp") String cidrIp); - - /** - * @see SecurityGroupClient#revokeSecurityGroupIngressInRegion(@Nullable Region, - * String,UserIdGroupPair) - */ - @Named("RevokeSecurityGroupIngress") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress") - ListenableFuture revokeSecurityGroupIngressInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("GroupName") String groupName, - @BinderParam(BindUserIdGroupPairToSourceSecurityGroupFormParams.class) UserIdGroupPair sourceSecurityGroup); - - /** - * @see SecurityGroupClient#revokeSecurityGroupIngressInRegion(@ org.jclouds.javax.annotation.Nullable Region, - * String,IpProtocol,int,int,String) - */ - @Named("RevokeSecurityGroupIngress") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress") - ListenableFuture revokeSecurityGroupIngressInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("GroupName") String groupName, @FormParam("IpProtocol") IpProtocol ipProtocol, - @FormParam("FromPort") int fromPort, @FormParam("ToPort") int toPort, @FormParam("CidrIp") String cidrIp); -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/WindowsAsyncClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/services/WindowsAsyncClient.java deleted file mode 100644 index 70d2cc8ec1..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/WindowsAsyncClient.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.ec2.binders.BindBundleIdsToIndexedFormParams; -import org.jclouds.ec2.binders.BindS3UploadPolicyAndSignature; -import org.jclouds.ec2.domain.BundleTask; -import org.jclouds.ec2.domain.PasswordData; -import org.jclouds.ec2.options.BundleInstanceS3StorageOptions; -import org.jclouds.ec2.xml.BundleTaskHandler; -import org.jclouds.ec2.xml.DescribeBundleTasksResponseHandler; -import org.jclouds.ec2.xml.GetPasswordDataResponseHandler; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.Fallback; -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 com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to EC2 Windows via their REST API. - *

- * - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface WindowsAsyncClient { - - /** - * @see WindowsClient#bundleInstanceInRegion - */ - @Named("BundleInstance") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "BundleInstance") - @XMLResponseParser(BundleTaskHandler.class) - ListenableFuture bundleInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId, @FormParam("Storage.S3.Prefix") String prefix, - @FormParam("Storage.S3.Bucket") String bucket, - @BinderParam(BindS3UploadPolicyAndSignature.class) String uploadPolicy, - BundleInstanceS3StorageOptions... options); - - /** - * @see WindowsClient#cancelBundleTaskInRegion - */ - @Named("CancelBundleTask") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "CancelBundleTask") - @XMLResponseParser(BundleTaskHandler.class) - ListenableFuture cancelBundleTaskInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("BundleId") String bundleId); - - /** - * @see BundleTaskClient#describeBundleTasksInRegion - */ - @Named("DescribeBundleTasks") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DescribeBundleTasks") - @XMLResponseParser(DescribeBundleTasksResponseHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> describeBundleTasksInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @BinderParam(BindBundleIdsToIndexedFormParams.class) String... bundleTaskIds); - - /** - * @see WindowsClient#getPasswordDataInRegion - */ - @Named("GetPasswordData") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "GetPasswordData") - @XMLResponseParser(GetPasswordDataResponseHandler.class) - ListenableFuture getPasswordDataInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("InstanceId") String instanceId); - -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/services/WindowsClient.java b/apis/ec2/src/main/java/org/jclouds/ec2/services/WindowsClient.java deleted file mode 100644 index e03320a8d7..0000000000 --- a/apis/ec2/src/main/java/org/jclouds/ec2/services/WindowsClient.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import java.util.Set; -import org.jclouds.ec2.domain.BundleTask; -import org.jclouds.ec2.domain.PasswordData; -import org.jclouds.ec2.options.BundleInstanceS3StorageOptions; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides windows services for EC2. For more information, refer to the Amazon - * EC2 Developer Guide. - *

- * - * @author Adrian Cole - */ -public interface WindowsClient { - /** - * Bundles the Windows instance. This procedure is not applicable for Linux - * and UNIX instances. For more information, go to the Amazon Elastic Compute - * Cloud Developer Guide or Amazon Elastic Compute Cloud Getting Started - * Guide. - * - * @param region - * Bundles are tied to the Region where its files are located - * within Amazon S3. - * - * @param instanceId - * The ID of the instance to bundle. - * @param prefix - * Specifies the beginning of the file name of the AMI. - * @param bucket - * The bucket in which to store the AMI. You can specify a bucket - * that you already own or a new bucket that Amazon EC2 creates on - * your behalf. If you specify a bucket that belongs to someone - * else, Amazon EC2 returns an error. - * @param uploadPolicy - * An Amazon S3 upload policy that gives Amazon EC2 permission to - * upload items into Amazon S3 on the user's behalf. - *

- * ex. - * - *

-    * {"expiration": "2008-08-30T08:49:09Z","conditions": ["bucket": "my-bucket"},["starts-with", "$key", "my-new-image"]]}
-    * 
- * - * @param options - * if the bucket isn't owned by you, use this to set the bucket's - * accesskeyid - * @return status of the work - * - * @see #cancelBundleTaskInRegion - * @see #describeBundleTasksInRegion - * - * @see - */ - BundleTask bundleInstanceInRegion(@Nullable String region, String instanceId, String prefix, String bucket, - String uploadPolicy, BundleInstanceS3StorageOptions... options); - - /** - * Cancels an Amazon EC2 bundling operation. - * - * @param region - * The bundleTask ID is tied to the Region. - * @param bundleId - * The ID of the bundle task to cancel. - * @return task for the cancel. - * - * @see #bundleInstanceInRegion - * @see #describeBundleTasksInRegion - * - * @see - */ - BundleTask cancelBundleTaskInRegion(@Nullable String region, String bundleId); - - /** - * - * Describes current bundling tasks. - * - * @param region - * The bundleTask ID is tied to the Region. - * - * @see #cancelBundleTaskInRegion - * @see #bundleInstanceInRegion - * @see - */ - Set describeBundleTasksInRegion(@Nullable String region, String... bundleTaskIds); - - /** - * - * Retrieves the encrypted administrator password for the instances running Windows. - * - * @param region The region where the instance is based - * @param instanceId The ID of the instance to query - * @see - */ - PasswordData getPasswordDataInRegion(@Nullable String region, String instanceId); -} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegion.java b/apis/ec2/src/main/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegion.java index cd7767c371..f97e962f95 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegion.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegion.java @@ -23,9 +23,9 @@ import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.domain.AvailabilityZoneInfo; -import org.jclouds.ec2.services.AvailabilityZoneAndRegionClient; +import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi; import org.jclouds.http.HttpResponseException; import org.jclouds.location.Region; import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; @@ -45,12 +45,12 @@ public class DescribeAvailabilityZonesInRegion implements RegionIdToZoneIdsSuppl @Resource protected Logger logger = Logger.NULL; - private final AvailabilityZoneAndRegionClient client; + private final AvailabilityZoneAndRegionApi client; private final Supplier> regions; @Inject - public DescribeAvailabilityZonesInRegion(EC2Client client, @Region Supplier> regions) { - this.client = client.getAvailabilityZoneAndRegionServices(); + public DescribeAvailabilityZonesInRegion(EC2Api client, @Region Supplier> regions) { + this.client = client.getAvailabilityZoneAndRegionApi().get(); this.regions = regions; } diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/suppliers/DescribeRegionsForRegionURIs.java b/apis/ec2/src/main/java/org/jclouds/ec2/suppliers/DescribeRegionsForRegionURIs.java index 0cbaee8120..d8d7a51dd9 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/suppliers/DescribeRegionsForRegionURIs.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/suppliers/DescribeRegionsForRegionURIs.java @@ -22,8 +22,8 @@ import java.util.Map; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.services.AvailabilityZoneAndRegionClient; +import org.jclouds.ec2.EC2Api; +import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi; import org.jclouds.location.Region; import org.jclouds.location.suppliers.RegionIdToURISupplier; import org.jclouds.util.Suppliers2; @@ -33,11 +33,11 @@ import com.google.common.collect.Maps; @Singleton public class DescribeRegionsForRegionURIs implements RegionIdToURISupplier { - private final AvailabilityZoneAndRegionClient client; + private final AvailabilityZoneAndRegionApi client; @Inject - public DescribeRegionsForRegionURIs(EC2Client client) { - this.client = client.getAvailabilityZoneAndRegionServices(); + public DescribeRegionsForRegionURIs(EC2Api client) { + this.client = client.getAvailabilityZoneAndRegionApi().get(); } @Singleton diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ApiLiveTest.java similarity index 78% rename from apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ApiLiveTest.java index 1fc8de931e..2a999dab45 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ApiLiveTest.java @@ -74,13 +74,13 @@ import com.google.inject.Injector; * * @author Adrian Cole */ -@Test(groups = "live", enabled = false, singleThreaded = true, testName = "CloudApplicationArchitecturesEC2ClientLiveTest") -public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeServiceContextLiveTest { - public CloudApplicationArchitecturesEC2ClientLiveTest() { +@Test(groups = "live", enabled = false, singleThreaded = true, testName = "CloudApplicationArchitecturesEC2ApiLiveTest") +public class CloudApplicationArchitecturesEC2ApiLiveTest extends BaseComputeServiceContextLiveTest { + public CloudApplicationArchitecturesEC2ApiLiveTest() { provider = "ec2"; } - private EC2Client client; + private EC2Api client; protected SshClient.Factory sshFactory; private String instancePrefix = System.getProperty("user.name") + ".ec2"; private KeyPair keyPair; @@ -96,7 +96,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS public void setupContext() { super.setupContext(); Injector injector = view.utils().injector(); - client = injector.getInstance(EC2Client.class); + client = injector.getInstance(EC2Api.class); sshFactory = injector.getInstance(SshClient.Factory.class); runningTester = retry(new InstanceStateRunning(client), 180, 5,SECONDS); hasIpTester = retry(new InstanceHasIpAddress(client), 180, 5, SECONDS); @@ -109,13 +109,13 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS securityGroupName = instancePrefix + "ingress"; try { - client.getSecurityGroupServices().deleteSecurityGroupInRegion(null, securityGroupName); + client.getSecurityGroupApi().get().deleteSecurityGroupInRegion(null, securityGroupName); } catch (Exception e) { } - client.getSecurityGroupServices().createSecurityGroupInRegion(null, securityGroupName, securityGroupName); + client.getSecurityGroupApi().get().createSecurityGroupInRegion(null, securityGroupName, securityGroupName); for (int port : new int[] { 80, 443, 22 }) { - client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(null, securityGroupName, + client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(null, securityGroupName, IpProtocol.TCP, port, port, "0.0.0.0/0"); } } @@ -124,13 +124,13 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS void testCreateKeyPair() throws InterruptedException, ExecutionException, TimeoutException { String keyName = instancePrefix + "1"; try { - client.getKeyPairServices().deleteKeyPairInRegion(null, keyName); + client.getKeyPairApi().get().deleteKeyPairInRegion(null, keyName); } catch (Exception e) { } - client.getKeyPairServices().deleteKeyPairInRegion(null, keyName); + client.getKeyPairApi().get().deleteKeyPairInRegion(null, keyName); - keyPair = client.getKeyPairServices().createKeyPairInRegion(null, keyName); + keyPair = client.getKeyPairApi().get().createKeyPairInRegion(null, keyName); assertNotNull(keyPair); assertNotNull(keyPair.getKeyMaterial()); assertNotNull(keyPair.getSha1OfPrivateKey()); @@ -149,7 +149,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS try { System.out.printf("%d: running instance%n", System.currentTimeMillis()); - Reservation reservation = client.getInstanceServices().runInstancesInRegion( + Reservation reservation = client.getInstanceApi().get().runInstancesInRegion( null, null, // allow // ec2 // to @@ -192,31 +192,31 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS } private void verifyInstanceProperties(String script) { - assertEquals(script, client.getInstanceServices().getUserDataForInstanceInRegion(null, instanceId)); + assertEquals(script, client.getInstanceApi().get().getUserDataForInstanceInRegion(null, instanceId)); - assertEquals(null, client.getInstanceServices().getRootDeviceNameForInstanceInRegion(null, instanceId)); + assertEquals(null, client.getInstanceApi().get().getRootDeviceNameForInstanceInRegion(null, instanceId)); - assert client.getInstanceServices().getRamdiskForInstanceInRegion(null, instanceId).startsWith("ari-"); + assert client.getInstanceApi().get().getRamdiskForInstanceInRegion(null, instanceId).startsWith("ari-"); - assertEquals(false, client.getInstanceServices().isApiTerminationDisabledForInstanceInRegion(null, instanceId)); + assertEquals(false, client.getInstanceApi().get().isApiTerminationDisabledForInstanceInRegion(null, instanceId)); - assert client.getInstanceServices().getKernelForInstanceInRegion(null, instanceId).startsWith("aki-"); + assert client.getInstanceApi().get().getKernelForInstanceInRegion(null, instanceId).startsWith("aki-"); assertEquals(InstanceType.M1_SMALL, - client.getInstanceServices().getInstanceTypeForInstanceInRegion(null, instanceId)); + client.getInstanceApi().get().getInstanceTypeForInstanceInRegion(null, instanceId)); - assertEquals(InstanceInitiatedShutdownBehavior.TERMINATE, client.getInstanceServices() + assertEquals(InstanceInitiatedShutdownBehavior.TERMINATE, client.getInstanceApi().get() .getInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, instanceId)); - assertEquals(ImmutableMap. of(), client.getInstanceServices() + assertEquals(ImmutableMap. of(), client.getInstanceApi().get() .getBlockDeviceMappingForInstanceInRegion(null, instanceId)); } private void setApiTerminationDisabledForInstanceInRegion() { - client.getInstanceServices().setApiTerminationDisabledForInstanceInRegion(null, instanceId, true); - assertEquals(true, client.getInstanceServices().isApiTerminationDisabledForInstanceInRegion(null, instanceId)); - client.getInstanceServices().setApiTerminationDisabledForInstanceInRegion(null, instanceId, false); - assertEquals(false, client.getInstanceServices().isApiTerminationDisabledForInstanceInRegion(null, instanceId)); + client.getInstanceApi().get().setApiTerminationDisabledForInstanceInRegion(null, instanceId, true); + assertEquals(true, client.getInstanceApi().get().isApiTerminationDisabledForInstanceInRegion(null, instanceId)); + client.getInstanceApi().get().setApiTerminationDisabledForInstanceInRegion(null, instanceId, false); + assertEquals(false, client.getInstanceApi().get().isApiTerminationDisabledForInstanceInRegion(null, instanceId)); } private void tryToChangeStuff() { @@ -231,7 +231,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS private void setUserDataForInstanceInRegion() { try { - client.getInstanceServices().setUserDataForInstanceInRegion(null, instanceId, "test".getBytes()); + client.getInstanceApi().get().setUserDataForInstanceInRegion(null, instanceId, "test".getBytes()); fail("shouldn't be allowed, as instance needs to be stopped"); } catch (AWSResponseException e) { assertEquals("IncorrectInstanceState", e.getError().getCode()); @@ -240,8 +240,8 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS private void setRamdiskForInstanceInRegion() { try { - String ramdisk = client.getInstanceServices().getRamdiskForInstanceInRegion(null, instanceId); - client.getInstanceServices().setRamdiskForInstanceInRegion(null, instanceId, ramdisk); + String ramdisk = client.getInstanceApi().get().getRamdiskForInstanceInRegion(null, instanceId); + client.getInstanceApi().get().setRamdiskForInstanceInRegion(null, instanceId, ramdisk); fail("shouldn't be allowed, as instance needs to be stopped"); } catch (AWSResponseException e) { assertEquals("IncorrectInstanceState", e.getError().getCode()); @@ -250,8 +250,8 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS private void setKernelForInstanceInRegion() { try { - String oldKernel = client.getInstanceServices().getKernelForInstanceInRegion(null, instanceId); - client.getInstanceServices().setKernelForInstanceInRegion(null, instanceId, oldKernel); + String oldKernel = client.getInstanceApi().get().getKernelForInstanceInRegion(null, instanceId); + client.getInstanceApi().get().setKernelForInstanceInRegion(null, instanceId, oldKernel); fail("shouldn't be allowed, as instance needs to be stopped"); } catch (AWSResponseException e) { assertEquals("IncorrectInstanceState", e.getError().getCode()); @@ -260,7 +260,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS private void setInstanceTypeForInstanceInRegion() { try { - client.getInstanceServices().setInstanceTypeForInstanceInRegion(null, instanceId, InstanceType.C1_MEDIUM); + client.getInstanceApi().get().setInstanceTypeForInstanceInRegion(null, instanceId, InstanceType.C1_MEDIUM); fail("shouldn't be allowed, as instance needs to be stopped"); } catch (AWSResponseException e) { assertEquals("IncorrectInstanceState", e.getError().getCode()); @@ -270,7 +270,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS private void setBlockDeviceMappingForInstanceInRegion() { Map mapping = Maps.newLinkedHashMap(); try { - client.getInstanceServices().setBlockDeviceMappingForInstanceInRegion(null, instanceId, mapping); + client.getInstanceApi().get().setBlockDeviceMappingForInstanceInRegion(null, instanceId, mapping); fail("shouldn't be allowed, as instance needs to be ebs based-ami"); } catch (AWSResponseException e) { assertEquals("InvalidParameterCombination", e.getError().getCode()); @@ -279,7 +279,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS private void setInstanceInitiatedShutdownBehaviorForInstanceInRegion() { try { - client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, instanceId, + client.getInstanceApi().get().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, instanceId, InstanceInitiatedShutdownBehavior.STOP); fail("shouldn't be allowed, as instance needs to be ebs based-ami"); } catch (AWSResponseException e) { @@ -291,7 +291,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS void testReboot() throws InterruptedException, ExecutionException, TimeoutException, IOException { RunningInstance instance = getInstance(instanceId); System.out.printf("%d: %s rebooting instance %n", System.currentTimeMillis(), instanceId); - client.getInstanceServices().rebootInstancesInRegion(null, instanceId); + client.getInstanceApi().get().rebootInstancesInRegion(null, instanceId); Thread.sleep(1000); instance = getInstance(instanceId); blockUntilWeCanSshIntoInstance(instance); @@ -309,23 +309,23 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS @Test(enabled = false, dependsOnMethods = "testReboot") void testElasticIpAddress() throws InterruptedException, ExecutionException, TimeoutException, IOException { - address = client.getElasticIPAddressServices().allocateAddressInRegion(null); + address = client.getElasticIPAddressApi().get().allocateAddressInRegion(null); assertNotNull(address); - PublicIpInstanceIdPair compare = Iterables.getLast(client.getElasticIPAddressServices() + PublicIpInstanceIdPair compare = Iterables.getLast(client.getElasticIPAddressApi().get() .describeAddressesInRegion(null, address)); assertEquals(compare.getPublicIp(), address); assert compare.getInstanceId() == null; - client.getElasticIPAddressServices().associateAddressInRegion(null, address, instanceId); + client.getElasticIPAddressApi().get().associateAddressInRegion(null, address, instanceId); - compare = Iterables.getLast(client.getElasticIPAddressServices().describeAddressesInRegion(null, address)); + compare = Iterables.getLast(client.getElasticIPAddressApi().get().describeAddressesInRegion(null, address)); assertEquals(compare.getPublicIp(), address); assertEquals(compare.getInstanceId(), instanceId); - Reservation reservation = Iterables.getOnlyElement(client.getInstanceServices() + Reservation reservation = Iterables.getOnlyElement(client.getInstanceApi().get() .describeInstancesInRegion(null, instanceId)); assertNotNull(Iterables.getOnlyElement(reservation).getIpAddress()); @@ -333,14 +333,14 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS doCheckKey(address); - client.getElasticIPAddressServices().disassociateAddressInRegion(null, address); + client.getElasticIPAddressApi().get().disassociateAddressInRegion(null, address); - compare = Iterables.getLast(client.getElasticIPAddressServices().describeAddressesInRegion(null, address)); + compare = Iterables.getLast(client.getElasticIPAddressApi().get().describeAddressesInRegion(null, address)); assertEquals(compare.getPublicIp(), address); assert compare.getInstanceId() == null; - reservation = Iterables.getOnlyElement(client.getInstanceServices().describeInstancesInRegion(null, instanceId)); + reservation = Iterables.getOnlyElement(client.getInstanceApi().get().describeInstancesInRegion(null, instanceId)); // assert reservation.getRunningInstances().last().getIpAddress() == null; // TODO } @@ -370,7 +370,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS private RunningInstance getInstance(String instanceId) { // search my identity for the instance I just created - Set> reservations = client.getInstanceServices() + Set> reservations = client.getInstanceApi().get() .describeInstancesInRegion(null, instanceId); // last parameter // (ids) narrows the // search @@ -415,13 +415,13 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS @AfterTest void cleanup() throws InterruptedException, ExecutionException, TimeoutException { if (address != null) - client.getElasticIPAddressServices().releaseAddressInRegion(null, address); + client.getElasticIPAddressApi().get().releaseAddressInRegion(null, address); if (instanceId != null) - client.getInstanceServices().terminateInstancesInRegion(null, instanceId); + client.getInstanceApi().get().terminateInstancesInRegion(null, instanceId); if (keyPair != null) - client.getKeyPairServices().deleteKeyPairInRegion(null, keyPair.getKeyName()); + client.getKeyPairApi().get().deleteKeyPairInRegion(null, keyPair.getKeyName()); if (securityGroupName != null) - client.getSecurityGroupServices().deleteSecurityGroupInRegion(null, securityGroupName); + client.getSecurityGroupApi().get().deleteSecurityGroupInRegion(null, securityGroupName); } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ApiLiveTest.java similarity index 82% rename from apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ApiLiveTest.java index 3b8bd758f2..3cff3f282a 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ApiLiveTest.java @@ -85,9 +85,9 @@ import com.google.inject.Injector; * * @author Adrian Cole */ -@Test(groups = "live", enabled = false, singleThreaded = true, testName = "EBSBootEC2ClientLiveTest") -public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest { - public EBSBootEC2ClientLiveTest() { +@Test(groups = "live", enabled = false, singleThreaded = true, testName = "EBSBootEC2ApiLiveTest") +public class EBSBootEC2ApiLiveTest extends BaseComputeServiceContextLiveTest { + public EBSBootEC2ApiLiveTest() { provider = "ec2"; } @@ -99,7 +99,7 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest private static final String SCRIPT_END = "----COMPLETE----"; private static final String INSTANCE_PREFIX = System.getProperty("user.name") + ".ec2ebs"; - private EC2Client client; + private EC2Api client; private SshClient.Factory sshFactory; private KeyPair keyPair; @@ -125,7 +125,7 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest public void setupContext() { super.setupContext(); Injector injector = view.utils().injector(); - client = injector.getInstance(EC2Client.class); + client = injector.getInstance(EC2Api.class); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); socketTester = retry(socketOpen, 120, 1, SECONDS); @@ -155,16 +155,16 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest securityGroupName = INSTANCE_PREFIX + "ingress"; try { - client.getSecurityGroupServices().deleteSecurityGroupInRegion(null, securityGroupName); + client.getSecurityGroupApi().get().deleteSecurityGroupInRegion(null, securityGroupName); } catch (Exception e) { } - client.getSecurityGroupServices().createSecurityGroupInRegion(null, securityGroupName, securityGroupName); - client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(null, securityGroupName, IpProtocol.TCP, + client.getSecurityGroupApi().get().createSecurityGroupInRegion(null, securityGroupName, securityGroupName); + client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(null, securityGroupName, IpProtocol.TCP, 80, 80, "0.0.0.0/0"); - client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(null, securityGroupName, IpProtocol.TCP, + client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(null, securityGroupName, IpProtocol.TCP, 443, 443, "0.0.0.0/0"); - client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(null, securityGroupName, IpProtocol.TCP, + client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(null, securityGroupName, IpProtocol.TCP, 22, 22, "0.0.0.0/0"); } @@ -172,12 +172,12 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest void testCreateKeyPair() { String keyName = INSTANCE_PREFIX + "1"; try { - client.getKeyPairServices().deleteKeyPairInRegion(null, keyName); + client.getKeyPairApi().get().deleteKeyPairInRegion(null, keyName); } catch (Exception e) { } - keyPair = client.getKeyPairServices().createKeyPairInRegion(null, keyName); + keyPair = client.getKeyPairApi().get().createKeyPairInRegion(null, keyName); assertNotNull(keyPair); assertNotNull(keyPair.getKeyMaterial()); assertNotNull(keyPair.getSha1OfPrivateKey()); @@ -194,7 +194,7 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest while (instance == null) { try { System.out.printf("%d: running instance%n", System.currentTimeMillis()); - Reservation reservation = client.getInstanceServices().runInstancesInRegion( + Reservation reservation = client.getInstanceApi().get().runInstancesInRegion( null, null, // allow // ec2 // to @@ -225,13 +225,13 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest @Test(enabled = false, dependsOnMethods = "testCreateRunningInstance") void testCreateAndAttachVolume() { - volume = client.getElasticBlockStoreServices().createVolumeInAvailabilityZone(instance.getAvailabilityZone(), + volume = client.getElasticBlockStoreApi().get().createVolumeInAvailabilityZone(instance.getAvailabilityZone(), VOLUME_SIZE); System.out.printf("%d: %s awaiting volume to become available%n", System.currentTimeMillis(), volume.getId()); assert volumeTester.apply(volume); - Attachment attachment = client.getElasticBlockStoreServices().attachVolumeInRegion(instance.getRegion(), + Attachment attachment = client.getElasticBlockStoreApi().get().attachVolumeInRegion(instance.getRegion(), volume.getId(), instance.getId(), "/dev/sdh"); System.out.printf("%d: %s awaiting attachment to complete%n", System.currentTimeMillis(), attachment.getId()); @@ -334,42 +334,42 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest @Test(enabled = false, dependsOnMethods = "testBundleInstance") void testAMIFromBundle() { - volume = Iterables.getOnlyElement(client.getElasticBlockStoreServices().describeVolumesInRegion( + volume = Iterables.getOnlyElement(client.getElasticBlockStoreApi().get().describeVolumesInRegion( volume.getRegion(), volume.getId())); if (volume.getAttachments().size() > 0) { // should be cleanly unmounted, so force is not necessary. - client.getElasticBlockStoreServices().detachVolumeInRegion(instance.getRegion(), volume.getId(), false); + client.getElasticBlockStoreApi().get().detachVolumeInRegion(instance.getRegion(), volume.getId(), false); System.out.printf("%d: %s awaiting detachment to complete%n", System.currentTimeMillis(), volume.getId()); assert volumeTester.apply(volume); } else { attachment = null; // protect test closer so that it doesn't try to // detach } - snapshot = client.getElasticBlockStoreServices().createSnapshotInRegion(volume.getRegion(), volume.getId(), + snapshot = client.getElasticBlockStoreApi().get().createSnapshotInRegion(volume.getRegion(), volume.getId(), withDescription("EBS Ubuntu Hardy")); System.out.printf("%d: %s awaiting snapshot to complete%n", System.currentTimeMillis(), snapshot.getId()); assert snapshotTester.apply(snapshot); - Image image = Iterables.getOnlyElement(client.getAMIServices().describeImagesInRegion(snapshot.getRegion(), + Image image = Iterables.getOnlyElement(client.getAMIApi().get().describeImagesInRegion(snapshot.getRegion(), imageIds(IMAGE_ID))); String description = image.getDescription() == null ? "jclouds" : image.getDescription(); System.out.printf("%d: %s creating ami from snapshot%n", System.currentTimeMillis(), snapshot.getId()); - String amiId = client.getAMIServices().registerUnixImageBackedByEbsInRegion( + String amiId = client.getAMIApi().get().registerUnixImageBackedByEbsInRegion( snapshot.getRegion(), "ebsboot-" + image.getId(), snapshot.getId(), withKernelId(image.getKernelId()).withRamdisk(image.getRamdiskId()).withDescription(description) .asArchitecture(Architecture.I386)); try { - ebsImage = Iterables.getOnlyElement(client.getAMIServices().describeImagesInRegion(snapshot.getRegion(), + ebsImage = Iterables.getOnlyElement(client.getAMIApi().get().describeImagesInRegion(snapshot.getRegion(), imageIds(amiId))); } catch (AWSResponseException e) { // TODO add a retry handler for this HTTP code 400 and the below error if (e.getError().getClass().equals("InvalidAMIID.NotFound")) - ebsImage = Iterables.getOnlyElement(client.getAMIServices().describeImagesInRegion(snapshot.getRegion(), + ebsImage = Iterables.getOnlyElement(client.getAMIApi().get().describeImagesInRegion(snapshot.getRegion(), imageIds(amiId))); else throw e; @@ -383,13 +383,13 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest ebsInstance = createInstance(ebsImage.getId()); - client.getInstanceServices().stopInstancesInRegion(ebsInstance.getRegion(), true, ebsInstance.getId()); + client.getInstanceApi().get().stopInstancesInRegion(ebsInstance.getRegion(), true, ebsInstance.getId()); System.out.printf("%d: %s awaiting instance to stop %n", System.currentTimeMillis(), ebsInstance.getId()); stoppedTester.apply(ebsInstance); tryToChangeStuff(); System.out.printf("%d: %s awaiting instance to start %n", System.currentTimeMillis(), ebsInstance.getId()); - client.getInstanceServices().startInstancesInRegion(ebsInstance.getRegion(), ebsInstance.getId()); + client.getInstanceApi().get().startInstancesInRegion(ebsInstance.getRegion(), ebsInstance.getId()); ebsInstance = blockUntilWeCanSshIntoInstance(ebsInstance); } @@ -411,30 +411,30 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest } private void setUserDataForInstanceInRegion() { - client.getInstanceServices().setUserDataForInstanceInRegion(null, ebsInstance.getId(), "test".getBytes()); - assertEquals("test", client.getInstanceServices().getUserDataForInstanceInRegion(null, ebsInstance.getId())); + client.getInstanceApi().get().setUserDataForInstanceInRegion(null, ebsInstance.getId(), "test".getBytes()); + assertEquals("test", client.getInstanceApi().get().getUserDataForInstanceInRegion(null, ebsInstance.getId())); } private void setRamdiskForInstanceInRegion() { - String ramdisk = client.getInstanceServices().getRamdiskForInstanceInRegion(null, ebsInstance.getId()); - client.getInstanceServices().setRamdiskForInstanceInRegion(null, ebsInstance.getId(), ramdisk); - assertEquals(ramdisk, client.getInstanceServices().getRamdiskForInstanceInRegion(null, ebsInstance.getId())); + String ramdisk = client.getInstanceApi().get().getRamdiskForInstanceInRegion(null, ebsInstance.getId()); + client.getInstanceApi().get().setRamdiskForInstanceInRegion(null, ebsInstance.getId(), ramdisk); + assertEquals(ramdisk, client.getInstanceApi().get().getRamdiskForInstanceInRegion(null, ebsInstance.getId())); } private void setKernelForInstanceInRegion() { - String oldKernel = client.getInstanceServices().getKernelForInstanceInRegion(null, ebsInstance.getId()); - client.getInstanceServices().setKernelForInstanceInRegion(null, ebsInstance.getId(), oldKernel); - assertEquals(oldKernel, client.getInstanceServices().getKernelForInstanceInRegion(null, ebsInstance.getId())); + String oldKernel = client.getInstanceApi().get().getKernelForInstanceInRegion(null, ebsInstance.getId()); + client.getInstanceApi().get().setKernelForInstanceInRegion(null, ebsInstance.getId(), oldKernel); + assertEquals(oldKernel, client.getInstanceApi().get().getKernelForInstanceInRegion(null, ebsInstance.getId())); } private void setInstanceTypeForInstanceInRegion() { - client.getInstanceServices() + client.getInstanceApi().get() .setInstanceTypeForInstanceInRegion(null, ebsInstance.getId(), InstanceType.C1_MEDIUM); assertEquals(InstanceType.C1_MEDIUM, - client.getInstanceServices().getInstanceTypeForInstanceInRegion(null, ebsInstance.getId())); - client.getInstanceServices().setInstanceTypeForInstanceInRegion(null, ebsInstance.getId(), InstanceType.M1_SMALL); + client.getInstanceApi().get().getInstanceTypeForInstanceInRegion(null, ebsInstance.getId())); + client.getInstanceApi().get().setInstanceTypeForInstanceInRegion(null, ebsInstance.getId(), InstanceType.M1_SMALL); assertEquals(InstanceType.M1_SMALL, - client.getInstanceServices().getInstanceTypeForInstanceInRegion(null, ebsInstance.getId())); + client.getInstanceApi().get().getInstanceTypeForInstanceInRegion(null, ebsInstance.getId())); } private void setBlockDeviceMappingForInstanceInRegion() { @@ -443,9 +443,9 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest Map mapping = Maps.newLinkedHashMap(); mapping.put("/dev/sda1", new BlockDevice(volumeId, false)); try { - client.getInstanceServices().setBlockDeviceMappingForInstanceInRegion(null, ebsInstance.getId(), mapping); + client.getInstanceApi().get().setBlockDeviceMappingForInstanceInRegion(null, ebsInstance.getId(), mapping); - Map devices = client.getInstanceServices().getBlockDeviceMappingForInstanceInRegion(null, + Map devices = client.getInstanceApi().get().getBlockDeviceMappingForInstanceInRegion(null, ebsInstance.getId()); assertEquals(devices.size(), 1); String deviceName = Iterables.getOnlyElement(devices.keySet()); @@ -466,15 +466,15 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest private void setInstanceInitiatedShutdownBehaviorForInstanceInRegion() { try { - client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, + client.getInstanceApi().get().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, ebsInstance.getId(), InstanceInitiatedShutdownBehavior.STOP); - assertEquals(InstanceInitiatedShutdownBehavior.STOP, client.getInstanceServices() + assertEquals(InstanceInitiatedShutdownBehavior.STOP, client.getInstanceApi().get() .getInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, ebsInstance.getId())); - client.getInstanceServices().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, + client.getInstanceApi().get().setInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, ebsInstance.getId(), InstanceInitiatedShutdownBehavior.TERMINATE); - assertEquals(InstanceInitiatedShutdownBehavior.TERMINATE, client.getInstanceServices() + assertEquals(InstanceInitiatedShutdownBehavior.TERMINATE, client.getInstanceApi().get() .getInstanceInitiatedShutdownBehaviorForInstanceInRegion(null, ebsInstance.getId())); System.out.println("OK: setInstanceInitiatedShutdownBehaviorForInstanceInRegion"); } catch (Exception e) { @@ -522,7 +522,7 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest assert runningTester.apply(instance); // search my identity for the instance I just created - Set> reservations = client.getInstanceServices() + Set> reservations = client.getInstanceApi().get() .describeInstancesInRegion(instance.getRegion(), instance.getId()); // last // parameter // (ids) @@ -544,7 +544,7 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest void cleanup() { if (ebsInstance != null) { try { - client.getInstanceServices().terminateInstancesInRegion(ebsInstance.getRegion(), ebsInstance.getId()); + client.getInstanceApi().get().terminateInstancesInRegion(ebsInstance.getRegion(), ebsInstance.getId()); terminatedTester.apply(ebsInstance); } catch (Exception e) { e.printStackTrace(); @@ -552,7 +552,7 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest } if (ebsImage != null) { try { - client.getAMIServices().deregisterImageInRegion(ebsImage.getRegion(), ebsImage.getId()); + client.getAMIApi().get().deregisterImageInRegion(ebsImage.getRegion(), ebsImage.getId()); } catch (Exception e) { e.printStackTrace(); } @@ -560,14 +560,14 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest if (snapshot != null) { try { - client.getElasticBlockStoreServices().deleteSnapshotInRegion(snapshot.getRegion(), snapshot.getId()); + client.getElasticBlockStoreApi().get().deleteSnapshotInRegion(snapshot.getRegion(), snapshot.getId()); } catch (Exception e) { e.printStackTrace(); } } if (attachment != null) { try { - client.getElasticBlockStoreServices().detachVolumeInRegion(volume.getRegion(), volume.getId(), true); + client.getElasticBlockStoreApi().get().detachVolumeInRegion(volume.getRegion(), volume.getId(), true); assert volumeTester.apply(volume); } catch (Exception e) { e.printStackTrace(); @@ -575,7 +575,7 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest } if (instance != null) { try { - client.getInstanceServices().terminateInstancesInRegion(instance.getRegion(), instance.getId()); + client.getInstanceApi().get().terminateInstancesInRegion(instance.getRegion(), instance.getId()); terminatedTester.apply(instance); } catch (Exception e) { e.printStackTrace(); @@ -583,21 +583,21 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest } if (volume != null) { try { - client.getElasticBlockStoreServices().deleteVolumeInRegion(volume.getRegion(), volume.getId()); + client.getElasticBlockStoreApi().get().deleteVolumeInRegion(volume.getRegion(), volume.getId()); } catch (Exception e) { e.printStackTrace(); } } if (keyPair != null) { try { - client.getKeyPairServices().deleteKeyPairInRegion(keyPair.getRegion(), keyPair.getKeyName()); + client.getKeyPairApi().get().deleteKeyPairInRegion(keyPair.getRegion(), keyPair.getKeyName()); } catch (Exception e) { e.printStackTrace(); } } if (securityGroupName != null) { try { - client.getSecurityGroupServices().deleteSecurityGroupInRegion(null, securityGroupName); + client.getSecurityGroupApi().get().deleteSecurityGroupInRegion(null, securityGroupName); } catch (Exception e) { e.printStackTrace(); } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/EC2AsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/EC2AsyncClientTest.java deleted file mode 100644 index 17299b7023..0000000000 --- a/apis/ec2/src/test/java/org/jclouds/ec2/EC2AsyncClientTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import org.jclouds.ec2.services.BaseEC2AsyncClientTest; -import org.jclouds.http.HttpRequest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code EC2AsyncClient} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "EC2AsyncClientTest") -public class EC2AsyncClientTest extends BaseEC2AsyncClientTest { - - private EC2AsyncClient asyncClient; - private EC2Client syncClient; - - public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException { - assert syncClient.getAMIServices() != null; - assert syncClient.getAvailabilityZoneAndRegionServices() != null; - assert syncClient.getElasticBlockStoreServices() != null; - assert syncClient.getElasticIPAddressServices() != null; - assert syncClient.getInstanceServices() != null; - assert syncClient.getKeyPairServices() != null; - assert syncClient.getSecurityGroupServices() != null; - assert syncClient.getWindowsServices() != null; - - } - - public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException { - assert asyncClient.getAMIServices() != null; - assert asyncClient.getAvailabilityZoneAndRegionServices() != null; - assert asyncClient.getElasticBlockStoreServices() != null; - assert asyncClient.getElasticIPAddressServices() != null; - assert asyncClient.getInstanceServices() != null; - assert asyncClient.getKeyPairServices() != null; - assert asyncClient.getSecurityGroupServices() != null; - assert asyncClient.getWindowsServices() != null; - } - - @BeforeClass - @Override - protected void setupFactory() throws IOException { - super.setupFactory(); - asyncClient = injector.getInstance(EC2AsyncClient.class); - syncClient = injector.getInstance(EC2Client.class); - } - - @Override - protected void checkFilters(HttpRequest request) { - - } - -} diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignatureTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignatureTest.java index e4290f6aa0..5c92aecd3e 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignatureTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignatureTest.java @@ -20,8 +20,8 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; -import org.jclouds.ec2.services.BaseEC2AsyncClientTest; -import org.jclouds.ec2.services.InstanceAsyncClient; +import org.jclouds.ec2.features.BaseEC2ApiTest; +import org.jclouds.ec2.features.InstanceApi; import org.jclouds.http.HttpRequest; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -33,7 +33,7 @@ import org.testng.annotations.Test; */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "BindS3UploadPolicyAndSignatureTest") -public class BindS3UploadPolicyAndSignatureTest extends BaseEC2AsyncClientTest { +public class BindS3UploadPolicyAndSignatureTest extends BaseEC2ApiTest { private BindS3UploadPolicyAndSignature binder; @BeforeClass diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java index 6334c9a9b0..c2753d7260 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java @@ -36,7 +36,7 @@ import org.jclouds.domain.Location; import org.jclouds.domain.LocationScope; import org.jclouds.domain.LoginCredentials; import org.jclouds.ec2.EC2ApiMetadata; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.options.EC2TemplateOptions; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.KeyPair; @@ -46,10 +46,10 @@ import org.jclouds.ec2.domain.SecurityGroup; import org.jclouds.ec2.domain.Snapshot; import org.jclouds.ec2.domain.Volume; import org.jclouds.ec2.reference.EC2Constants; -import org.jclouds.ec2.services.ElasticBlockStoreClient; -import org.jclouds.ec2.services.InstanceClient; -import org.jclouds.ec2.services.KeyPairClient; -import org.jclouds.ec2.services.SecurityGroupClient; +import org.jclouds.ec2.features.ElasticBlockStoreApi; +import org.jclouds.ec2.features.InstanceApi; +import org.jclouds.ec2.features.KeyPairApi; +import org.jclouds.ec2.features.SecurityGroupApi; import org.jclouds.net.domain.IpProtocol; import org.jclouds.scriptbuilder.domain.Statements; import org.jclouds.sshj.config.SshjSshClientModule; @@ -85,7 +85,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { @Override protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap userMetadata) { - if (view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getTagApi().isPresent()) { + if (view.unwrapApi(EC2Api.class).getTagApi().isPresent()) { super.checkUserMetadataContains(node, userMetadata); } else { assertTrue(node.getUserMetadata().isEmpty(), "not expecting metadata when tag extension isn't present" + node); @@ -103,14 +103,14 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { @Test(enabled = true, dependsOnMethods = "testCompareSizes") public void testExtendedOptionsAndLogin() throws Exception { - SecurityGroupClient securityGroupClient = EC2Client.class.cast(view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) - .getSecurityGroupServices(); + SecurityGroupApi securityGroupClient = view.unwrapApi(EC2Api.class) + .getSecurityGroupApi().get(); - KeyPairClient keyPairClient = EC2Client.class.cast(view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) - .getKeyPairServices(); + KeyPairApi keyPairClient = view.unwrapApi(EC2Api.class) + .getKeyPairApi().get(); - InstanceClient instanceClient = EC2Client.class.cast(view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) - .getInstanceServices(); + InstanceApi instanceClient = view.unwrapApi(EC2Api.class) + .getInstanceApi().get(); String group = this.group + "o"; @@ -203,9 +203,9 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { assertTrue(socketTester.apply(socket), String.format("failed to open socket %s on node %s", socket, node)); // check that there is an elastic ip correlating to it - EC2Client ec2 = EC2Client.class.cast(context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()); + EC2Api ec2 = context.unwrapApi(EC2Api.class); Set ipidpairs = - ec2.getElasticIPAddressServices().describeAddressesInRegion(region, publicIps.toArray(new String[0])); + ec2.getElasticIPAddressApi().get().describeAddressesInRegion(region, publicIps.toArray(new String[0])); assertEquals(ipidpairs.size(), 1, String.format("there should only be one address pair (%s)", Iterables.toString(ipidpairs))); @@ -218,7 +218,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { // check that the ip is deallocated Set ipidcheck = - ec2.getElasticIPAddressServices().describeAddressesInRegion(region, ipidpair.getPublicIp()); + ec2.getElasticIPAddressApi().get().describeAddressesInRegion(region, ipidpair.getPublicIp()); assertTrue(Iterables.isEmpty(ipidcheck), String.format("there should be no address pairs (%s)", Iterables.toString(ipidcheck))); } finally { @@ -246,11 +246,11 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { throw new SkipException("Test cannot run without the parameter test." + provider + ".ebs-template; this property should be in the format defined in TemplateBuilderSpec"); } - InstanceClient instanceClient = EC2Client.class.cast(view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) - .getInstanceServices(); + InstanceApi instanceClient = view.unwrapApi(EC2Api.class) + .getInstanceApi().get(); - ElasticBlockStoreClient ebsClient = EC2Client.class.cast(view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) - .getElasticBlockStoreServices(); + ElasticBlockStoreApi ebsClient = view.unwrapApi(EC2Api.class) + .getElasticBlockStoreApi().get(); String group = this.group + "e"; int volumeSize = 8; @@ -317,14 +317,14 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { * * @throws NoSuchElementException If no instance with that id exists, or the instance is in a different region */ - public static RunningInstance getInstance(InstanceClient instanceClient, String id) { + public static RunningInstance getInstance(InstanceApi instanceClient, String id) { RunningInstance instance = Iterables.getOnlyElement(Iterables.getOnlyElement(instanceClient .describeInstancesInRegion(null, id))); return instance; } - protected static void cleanupExtendedStuffInRegion(String region, SecurityGroupClient securityGroupClient, - KeyPairClient keyPairClient, String group) throws InterruptedException { + protected static void cleanupExtendedStuffInRegion(String region, SecurityGroupApi securityGroupClient, + KeyPairApi keyPairClient, String group) throws InterruptedException { try { for (SecurityGroup secgroup : securityGroupClient.describeSecurityGroupsInRegion(region)) if (secgroup.getName().startsWith("jclouds#" + group) || secgroup.getName().equals(group)) { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java index 8062033a9f..349da8e20c 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java @@ -31,8 +31,8 @@ import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions; import org.jclouds.ec2.options.DescribeImagesOptions; import org.jclouds.ec2.options.DescribeRegionsOptions; -import org.jclouds.ec2.services.AMIAsyncClient; -import org.jclouds.ec2.services.AvailabilityZoneAndRegionAsyncClient; +import org.jclouds.ec2.features.AMIApi; +import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi; import org.jclouds.http.HttpCommand; import org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService; import org.jclouds.logging.log4j.config.Log4JLoggingModule; @@ -67,8 +67,8 @@ public abstract class EC2TemplateBuilderLiveTest extends BaseTemplateBuilderLive Collection filteredCommandsInvoked = Collections2.filter(commandsInvoked, new Predicate() { private final Collection ignored = ImmutableSet.of( - AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", DescribeRegionsOptions[].class), - AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion", String.class, DescribeAvailabilityZonesOptions[].class)); + AvailabilityZoneAndRegionApi.class.getMethod("describeRegions", DescribeRegionsOptions[].class), + AvailabilityZoneAndRegionApi.class.getMethod("describeAvailabilityZonesInRegion", String.class, DescribeAvailabilityZonesOptions[].class)); @Override public boolean apply(HttpCommand input) { return !ignored.contains(getInvokerOfRequest(input)); @@ -76,7 +76,7 @@ public abstract class EC2TemplateBuilderLiveTest extends BaseTemplateBuilderLive }); assert filteredCommandsInvoked.size() == 1 : commandsInvoked; - assertEquals(getInvokerOfRequestAtIndex(filteredCommandsInvoked, 0), AMIAsyncClient.class + assertEquals(getInvokerOfRequestAtIndex(filteredCommandsInvoked, 0), AMIApi.class .getMethod("describeImagesInRegion", String.class, DescribeImagesOptions[].class)); assertDescribeImagesOptionsEquals((DescribeImagesOptions[])getArgsForRequestAtIndex(filteredCommandsInvoked, 0).get(1), defaultImageProviderId); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPairTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPairTest.java index 789f8bc88c..ddee5e1715 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPairTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPairTest.java @@ -25,11 +25,12 @@ import static org.testng.Assert.assertEquals; import java.net.UnknownHostException; import org.jclouds.ec2.EC2ApiMetadata; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.domain.KeyPair; -import org.jclouds.ec2.services.KeyPairClient; +import org.jclouds.ec2.features.KeyPairApi; import org.testng.annotations.Test; +import com.google.common.base.Optional; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.google.inject.AbstractModule; @@ -45,11 +46,11 @@ public class CreateUniqueKeyPairTest { @Test public void testApply() throws UnknownHostException { - final EC2Client client = createMock(EC2Client.class); - KeyPairClient keyClient = createMock(KeyPairClient.class); + final EC2Api client = createMock(EC2Api.class); + KeyPairApi keyClient = createMock(KeyPairApi.class); KeyPair pair = createMock(KeyPair.class); - expect(client.getKeyPairServices()).andReturn(keyClient).atLeastOnce(); + expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyClient)).atLeastOnce(); expect(keyClient.createKeyPairInRegion("region", "jclouds#group#1")).andReturn(pair); @@ -63,7 +64,7 @@ public class CreateUniqueKeyPairTest { Names.bindProperties(binder(),new EC2ApiMetadata().getDefaultProperties()); bind(new TypeLiteral>() { }).toInstance(Suppliers.ofInstance("1")); - bind(EC2Client.class).toInstance(client); + bind(EC2Api.class).toInstance(client); } }).getInstance(CreateUniqueKeyPair.class); @@ -77,13 +78,13 @@ public class CreateUniqueKeyPairTest { @SuppressWarnings( { "unchecked" }) @Test public void testApplyWithIllegalStateException() throws UnknownHostException { - final EC2Client client = createMock(EC2Client.class); - KeyPairClient keyClient = createMock(KeyPairClient.class); + final EC2Api client = createMock(EC2Api.class); + KeyPairApi keyClient = createMock(KeyPairApi.class); final Supplier uniqueIdSupplier = createMock(Supplier.class); KeyPair pair = createMock(KeyPair.class); - expect(client.getKeyPairServices()).andReturn(keyClient).atLeastOnce(); + expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyClient)).atLeastOnce(); expect(uniqueIdSupplier.get()).andReturn("1"); expect(keyClient.createKeyPairInRegion("region", "jclouds#group#1")).andThrow(new IllegalStateException()); @@ -101,7 +102,7 @@ public class CreateUniqueKeyPairTest { Names.bindProperties(binder(),new EC2ApiMetadata().getDefaultProperties()); bind(new TypeLiteral>() { }).toInstance(uniqueIdSupplier); - bind(EC2Client.class).toInstance(client); + bind(EC2Api.class).toInstance(client); } }).getInstance(CreateUniqueKeyPair.class); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/PresentInstancesTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/PresentInstancesTest.java index cf5be2500e..d27b4e9f1c 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/PresentInstancesTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/functions/PresentInstancesTest.java @@ -24,13 +24,14 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.ec2.services.InstanceClient; +import org.jclouds.ec2.features.InstanceApi; import org.testng.annotations.Test; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; /** @@ -45,10 +46,10 @@ public class PresentInstancesTest { @Test public void testWhenInstancesPresentSingleCall() { - EC2Client client = createMock(EC2Client.class); - InstanceClient instanceClient = createMock(InstanceClient.class); + EC2Api client = createMock(EC2Api.class); + InstanceApi instanceClient = createMock(InstanceApi.class); - expect(client.getInstanceServices()).andReturn(instanceClient); + expect(client.getInstanceApi()).andReturn((Optional) Optional.of(instanceClient)); // avoid imatcher fail. if you change this, be sure to check multiple jres expect(instanceClient.describeInstancesInRegion("us-east-1", "i-aaaa", "i-bbbb")).andReturn( diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceContextExpectTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceContextExpectTest.java index 9cd6b45f2c..cc9790bee7 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceContextExpectTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceContextExpectTest.java @@ -19,14 +19,14 @@ package org.jclouds.ec2.compute.internal; import java.util.Properties; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.ec2.internal.BaseEC2ClientExpectTest; +import org.jclouds.ec2.internal.BaseEC2ApiExpectTest; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import com.google.common.base.Function; import com.google.inject.Module; -public abstract class BaseEC2ComputeServiceContextExpectTest extends BaseEC2ClientExpectTest implements +public abstract class BaseEC2ComputeServiceContextExpectTest extends BaseEC2ApiExpectTest implements Function { @Override diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeededTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeededTest.java index 9597e1a313..1a2b9b3a51 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeededTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeededTest.java @@ -31,7 +31,7 @@ import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules; import org.jclouds.ec2.domain.SecurityGroup; import org.jclouds.ec2.domain.UserIdGroupPair; -import org.jclouds.ec2.services.SecurityGroupClient; +import org.jclouds.ec2.features.SecurityGroupApi; import org.jclouds.net.domain.IpProtocol; import org.testng.annotations.Test; @@ -49,7 +49,7 @@ public class CreateSecurityGroupIfNeededTest { @Test public void testWhenPort22AndToItselfAuthorizesIngressTwice() throws ExecutionException { - SecurityGroupClient client = createMock(SecurityGroupClient.class); + SecurityGroupApi client = createMock(SecurityGroupApi.class); Predicate tester = Predicates.alwaysTrue(); SecurityGroup group = createNiceMock(SecurityGroup.class); @@ -76,7 +76,7 @@ public class CreateSecurityGroupIfNeededTest { @Test public void testIllegalStateExceptionCreatingGroupJustReturns() throws ExecutionException { - SecurityGroupClient client = createMock(SecurityGroupClient.class); + SecurityGroupApi client = createMock(SecurityGroupApi.class); Predicate tester = Predicates.alwaysTrue(); client.createSecurityGroupInRegion("region", "group", "group"); @@ -95,7 +95,7 @@ public class CreateSecurityGroupIfNeededTest { @Test(expectedExceptions = RuntimeException.class) public void testWhenEventualConsistencyExpiresIllegalStateException() throws ExecutionException { - SecurityGroupClient client = createMock(SecurityGroupClient.class); + SecurityGroupApi client = createMock(SecurityGroupApi.class); Predicate tester = Predicates.alwaysFalse(); client.createSecurityGroupInRegion("region", "group", "group"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNullTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNullTest.java index 5389e86b6d..9d3feff5e3 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNullTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNullTest.java @@ -22,12 +22,13 @@ import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; import static org.testng.Assert.assertEquals; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.domain.PublicIpInstanceIdPair; -import org.jclouds.ec2.services.ElasticIPAddressClient; +import org.jclouds.ec2.features.ElasticIPAddressApi; import org.testng.annotations.Test; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; /** @@ -38,10 +39,10 @@ public class LoadPublicIpForInstanceOrNullTest { @Test public void testReturnsPublicIpOnMatch() throws Exception { - EC2Client client = createMock(EC2Client.class); - ElasticIPAddressClient ipClient = createMock(ElasticIPAddressClient.class); + EC2Api client = createMock(EC2Api.class); + ElasticIPAddressApi ipClient = createMock(ElasticIPAddressApi.class); - expect(client.getElasticIPAddressServices()).andReturn(ipClient).atLeastOnce(); + expect(client.getElasticIPAddressApi()).andReturn((Optional) Optional.of(ipClient)).atLeastOnce(); expect(ipClient.describeAddressesInRegion("region")).andReturn( ImmutableSet. of(new PublicIpInstanceIdPair("region", "1.1.1.1", "i-blah"))) .atLeastOnce(); @@ -59,10 +60,10 @@ public class LoadPublicIpForInstanceOrNullTest { @Test public void testReturnsNullWhenNotFound() throws Exception { - EC2Client client = createMock(EC2Client.class); - ElasticIPAddressClient ipClient = createMock(ElasticIPAddressClient.class); + EC2Api client = createMock(EC2Api.class); + ElasticIPAddressApi ipClient = createMock(ElasticIPAddressApi.class); - expect(client.getElasticIPAddressServices()).andReturn(ipClient).atLeastOnce(); + expect(client.getElasticIPAddressApi()).andReturn((Optional) Optional.of(ipClient)).atLeastOnce(); expect(ipClient.describeAddressesInRegion("region")).andReturn(ImmutableSet. of()) .atLeastOnce(); @@ -81,10 +82,10 @@ public class LoadPublicIpForInstanceOrNullTest { @Test public void testReturnsNullWhenNotAssigned() throws Exception { - EC2Client client = createMock(EC2Client.class); - ElasticIPAddressClient ipClient = createMock(ElasticIPAddressClient.class); + EC2Api client = createMock(EC2Api.class); + ElasticIPAddressApi ipClient = createMock(ElasticIPAddressApi.class); - expect(client.getElasticIPAddressServices()).andReturn(ipClient).atLeastOnce(); + expect(client.getElasticIPAddressApi()).andReturn((Optional) Optional.of(ipClient)).atLeastOnce(); expect(ipClient.describeAddressesInRegion("region")).andReturn( ImmutableSet. of(new PublicIpInstanceIdPair("region", "1.1.1.1", null))) diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImageTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImageTest.java index 64a76e9cc2..5c1c2aae7d 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImageTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImageTest.java @@ -29,13 +29,14 @@ import java.util.Set; import java.util.concurrent.ExecutionException; import org.jclouds.compute.domain.Image; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.functions.EC2ImageParser; -import org.jclouds.ec2.services.AMIClient; +import org.jclouds.ec2.features.AMIApi; import org.jclouds.rest.ResourceNotFoundException; import org.testng.annotations.Test; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; /** @@ -49,14 +50,14 @@ public class RegionAndIdToImageTest { public void testApply() throws ExecutionException { EC2ImageParser parser = createMock(EC2ImageParser.class); - EC2Client caller = createMock(EC2Client.class); - AMIClient client = createMock(AMIClient.class); + EC2Api caller = createMock(EC2Api.class); + AMIApi client = createMock(AMIApi.class); org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class); Image image = createNiceMock(Image.class); Set images = ImmutableSet. of(ec2Image); - expect(caller.getAMIServices()).andReturn(client).atLeastOnce(); + expect(caller.getAMIApi()).andReturn((Optional) Optional.of(client)).atLeastOnce(); expect(client.describeImagesInRegion("region", imageIds("ami"))).andReturn(Set.class.cast(images)); expect(parser.apply(ec2Image)).andReturn(image); @@ -81,14 +82,14 @@ public class RegionAndIdToImageTest { public void testApplyNotFoundMakesExecutionException() throws ExecutionException { EC2ImageParser parser = createMock(EC2ImageParser.class); - EC2Client caller = createMock(EC2Client.class); - AMIClient client = createMock(AMIClient.class); + EC2Api caller = createMock(EC2Api.class); + AMIApi client = createMock(AMIApi.class); org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class); Image image = createNiceMock(Image.class); Set images = ImmutableSet. of(ec2Image); - expect(caller.getAMIServices()).andReturn(client).atLeastOnce(); + expect(caller.getAMIApi()).andReturn((Optional) Optional.of(client)).atLeastOnce(); expect(client.describeImagesInRegion("region", imageIds("ami"))).andReturn(Set.class.cast(images)); expect(parser.apply(ec2Image)).andThrow(new ResourceNotFoundException()); @@ -113,14 +114,14 @@ public class RegionAndIdToImageTest { public void testApplyNoSuchElementExceptionMakesExecutionException() throws ExecutionException { EC2ImageParser parser = createMock(EC2ImageParser.class); - EC2Client caller = createMock(EC2Client.class); - AMIClient client = createMock(AMIClient.class); + EC2Api caller = createMock(EC2Api.class); + AMIApi client = createMock(AMIApi.class); org.jclouds.ec2.domain.Image ec2Image = createMock(org.jclouds.ec2.domain.Image.class); Image image = createNiceMock(Image.class); Set images = ImmutableSet. of(ec2Image); - expect(caller.getAMIServices()).andReturn(client).atLeastOnce(); + expect(caller.getAMIApi()).andReturn((Optional) Optional.of(client)).atLeastOnce(); expect(client.describeImagesInRegion("region", imageIds("ami"))).andReturn(Set.class.cast(images)); expect(parser.apply(ec2Image)).andThrow(new NoSuchElementException()); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java index 2a8bb45ca6..b2ec12d65e 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java @@ -42,7 +42,7 @@ import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; import org.jclouds.domain.LoginCredentials; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.functions.PresentInstances; import org.jclouds.ec2.compute.functions.RunningInstanceToNodeMetadata; @@ -50,8 +50,8 @@ import org.jclouds.ec2.compute.options.EC2TemplateOptions; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.ec2.options.RunInstancesOptions; -import org.jclouds.ec2.services.ElasticIPAddressClient; -import org.jclouds.ec2.services.InstanceClient; +import org.jclouds.ec2.features.ElasticIPAddressApi; +import org.jclouds.ec2.features.InstanceApi; import org.testng.Assert; import org.testng.annotations.Test; @@ -80,8 +80,8 @@ public class EC2CreateNodesInGroupThenAddToSetTest { // setup mocks EC2CreateNodesInGroupThenAddToSet strategy = setupStrategy(nodeMetadata); InputParams input = new InputParams(location); - InstanceClient instanceClient = createMock(InstanceClient.class); - ElasticIPAddressClient ipClient = createMock(ElasticIPAddressClient.class); + InstanceApi instanceClient = createMock(InstanceApi.class); + ElasticIPAddressApi ipClient = createMock(ElasticIPAddressApi.class); RunInstancesOptions ec2Options = createMock(RunInstancesOptions.class); RunningInstance instance = createMock(RunningInstance.class); Reservation reservation = new Reservation(region, @@ -93,11 +93,11 @@ public class EC2CreateNodesInGroupThenAddToSetTest { // setup expectations expect(input.template.clone()).andReturn(input.template); - expect(strategy.client.getInstanceServices()).andReturn(instanceClient).atLeastOnce(); + expect(strategy.client.getInstanceApi()).andReturn((Optional) Optional.of(instanceClient)).atLeastOnce(); expect( strategy.createKeyPairAndSecurityGroupsAsNeededAndReturncustomize .execute(region, input.tag, input.template)).andReturn(ec2Options); - expect(strategy.client.getElasticIPAddressServices()).andReturn(ipClient).atLeastOnce(); + expect(strategy.client.getElasticIPAddressApi()).andReturn((Optional) Optional.of(ipClient)).atLeastOnce(); expect(input.template.getLocation()).andReturn(input.location).atLeastOnce(); expect(input.template.getImage()).andReturn(input.image).atLeastOnce(); @@ -191,7 +191,7 @@ public class EC2CreateNodesInGroupThenAddToSetTest { // setup mocks EC2CreateNodesInGroupThenAddToSet strategy = setupStrategy(nodeMetadata); InputParams input = new InputParams(location); - InstanceClient instanceClient = createMock(InstanceClient.class); + InstanceApi instanceClient = createMock(InstanceApi.class); RunInstancesOptions ec2Options = createMock(RunInstancesOptions.class); RunningInstance instance = createMock(RunningInstance.class); Reservation reservation = new Reservation(region, @@ -200,7 +200,7 @@ public class EC2CreateNodesInGroupThenAddToSetTest { // setup expectations expect(input.template.clone()).andReturn(input.template); - expect(strategy.client.getInstanceServices()).andReturn(instanceClient).atLeastOnce(); + expect(strategy.client.getInstanceApi()).andReturn((Optional) Optional.of(instanceClient)).atLeastOnce(); expect( strategy.createKeyPairAndSecurityGroupsAsNeededAndReturncustomize .execute(region, input.tag, input.template)).andReturn(ec2Options); @@ -307,7 +307,7 @@ public class EC2CreateNodesInGroupThenAddToSetTest { @SuppressWarnings("unchecked") private EC2CreateNodesInGroupThenAddToSet setupStrategy(final NodeMetadata node) { - EC2Client client = createMock(EC2Client.class); + EC2Api client = createMock(EC2Api.class); CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions createKeyPairAndSecurityGroupsAsNeededAndReturncustomize = createMock(CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.class); PresentInstances presentInstances = createMock(PresentInstances.class); RunningInstanceToNodeMetadata runningInstanceToNodeMetadata = createMock(RunningInstanceToNodeMetadata.class); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategyTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategyTest.java index 8e892f2ba6..6bc929c559 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategyTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategyTest.java @@ -26,12 +26,13 @@ import java.util.concurrent.ExecutionException; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; -import org.jclouds.ec2.services.ElasticIPAddressClient; -import org.jclouds.ec2.services.InstanceClient; +import org.jclouds.ec2.features.ElasticIPAddressApi; +import org.jclouds.ec2.features.InstanceApi; import org.testng.annotations.Test; +import com.google.common.base.Optional; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -44,14 +45,14 @@ public class EC2DestroyNodeStrategyTest { @SuppressWarnings("unchecked") @Test public void testDestroyNodeTerminatesInstanceAndReturnsRefreshedNode() throws Exception { - EC2Client client = createMock(EC2Client.class); - InstanceClient instanceClient = createMock(InstanceClient.class); + EC2Api client = createMock(EC2Api.class); + InstanceApi instanceClient = createMock(InstanceApi.class); GetNodeMetadataStrategy getNode = createMock(GetNodeMetadataStrategy.class); LoadingCache elasticIpCache = createMock(LoadingCache.class); NodeMetadata node = createMock(NodeMetadata.class); - expect(client.getInstanceServices()).andReturn(instanceClient).atLeastOnce(); + expect(client.getInstanceApi()).andReturn((Optional) Optional.of(instanceClient)).atLeastOnce(); expect(instanceClient.terminateInstancesInRegion("region", "i-blah")).andReturn(null); expect(getNode.getNode("region/i-blah")).andReturn(node); @@ -74,23 +75,23 @@ public class EC2DestroyNodeStrategyTest { @Test public void testDestroyNodeDisassociatesAndReleasesIpThenTerminatesInstanceAndReturnsRefreshedNode() throws Exception { - EC2Client client = createMock(EC2Client.class); + EC2Api client = createMock(EC2Api.class); GetNodeMetadataStrategy getNode = createMock(GetNodeMetadataStrategy.class); LoadingCache elasticIpCache = createMock(LoadingCache.class); - ElasticIPAddressClient ipClient = createMock(ElasticIPAddressClient.class); - InstanceClient instanceClient = createMock(InstanceClient.class); + ElasticIPAddressApi ipClient = createMock(ElasticIPAddressApi.class); + InstanceApi instanceClient = createMock(InstanceApi.class); NodeMetadata node = createMock(NodeMetadata.class); expect(elasticIpCache.get(new RegionAndName("region", "i-blah"))).andReturn("1.1.1.1"); - expect(client.getElasticIPAddressServices()).andReturn(ipClient).atLeastOnce(); + expect(client.getElasticIPAddressApi()).andReturn((Optional) Optional.of(ipClient)).atLeastOnce(); ipClient.disassociateAddressInRegion("region", "1.1.1.1"); ipClient.releaseAddressInRegion("region", "1.1.1.1"); elasticIpCache.invalidate(new RegionAndName("region", "i-blah")); - expect(client.getInstanceServices()).andReturn(instanceClient).atLeastOnce(); + expect(client.getInstanceApi()).andReturn((Optional) Optional.of(instanceClient)).atLeastOnce(); expect(instanceClient.terminateInstancesInRegion("region", "i-blah")).andReturn(null); expect(getNode.getNode("region/i-blah")).andReturn(node); @@ -117,17 +118,17 @@ public class EC2DestroyNodeStrategyTest { @Test public void testDestroyNodeSafeOnCacheMissThenTerminatesInstanceAndReturnsRefreshedNode() throws Exception { - EC2Client client = createMock(EC2Client.class); + EC2Api client = createMock(EC2Api.class); GetNodeMetadataStrategy getNode = createMock(GetNodeMetadataStrategy.class); LoadingCache elasticIpCache = createMock(LoadingCache.class); - ElasticIPAddressClient ipClient = createMock(ElasticIPAddressClient.class); - InstanceClient instanceClient = createMock(InstanceClient.class); + ElasticIPAddressApi ipClient = createMock(ElasticIPAddressApi.class); + InstanceApi instanceClient = createMock(InstanceApi.class); NodeMetadata node = createMock(NodeMetadata.class); expect(elasticIpCache.get(new RegionAndName("region", "i-blah"))).andThrow(new CacheLoader.InvalidCacheLoadException(null)); - expect(client.getInstanceServices()).andReturn(instanceClient).atLeastOnce(); + expect(client.getInstanceApi()).andReturn((Optional) Optional.of(instanceClient)).atLeastOnce(); expect(instanceClient.terminateInstancesInRegion("region", "i-blah")).andReturn(null); expect(getNode.getNode("region/i-blah")).andReturn(node); @@ -154,17 +155,17 @@ public class EC2DestroyNodeStrategyTest { @Test public void testDestroyNodeSafeOnCacheExecutionExceptionThenTerminatesInstanceAndReturnsRefreshedNode() throws Exception { - EC2Client client = createMock(EC2Client.class); + EC2Api client = createMock(EC2Api.class); GetNodeMetadataStrategy getNode = createMock(GetNodeMetadataStrategy.class); LoadingCache elasticIpCache = createMock(LoadingCache.class); - ElasticIPAddressClient ipClient = createMock(ElasticIPAddressClient.class); - InstanceClient instanceClient = createMock(InstanceClient.class); + ElasticIPAddressApi ipClient = createMock(ElasticIPAddressApi.class); + InstanceApi instanceClient = createMock(InstanceApi.class); NodeMetadata node = createMock(NodeMetadata.class); expect(elasticIpCache.get(new RegionAndName("region", "i-blah"))).andThrow(new ExecutionException(null)); - expect(client.getInstanceServices()).andReturn(instanceClient).atLeastOnce(); + expect(client.getInstanceApi()).andReturn((Optional) Optional.of(instanceClient)).atLeastOnce(); expect(instanceClient.terminateInstancesInRegion("region", "i-blah")).andReturn(null); expect(getNode.getNode("region/i-blah")).andReturn(node); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/config/EC2RestClientModuleExpectTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/config/EC2HttpApiModuleExpectTest.java similarity index 97% rename from apis/ec2/src/test/java/org/jclouds/ec2/config/EC2RestClientModuleExpectTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/config/EC2HttpApiModuleExpectTest.java index a0c197597f..0785228775 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/config/EC2RestClientModuleExpectTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/config/EC2HttpApiModuleExpectTest.java @@ -23,7 +23,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; -import org.jclouds.ec2.internal.BaseEC2ClientExpectTest; +import org.jclouds.ec2.internal.BaseEC2ApiExpectTest; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.location.Region; @@ -46,8 +46,8 @@ import com.google.inject.TypeLiteral; /** * @author Adrian Cole */ -@Test(groups = "unit", testName = "EC2RestClientModuleExpectTest") -public class EC2RestClientModuleExpectTest extends BaseEC2ClientExpectTest { +@Test(groups = "unit", testName = "EC2HttpApiModuleExpectTest") +public class EC2HttpApiModuleExpectTest extends BaseEC2ApiExpectTest { private Injector injector; @BeforeClass diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/AMIClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/AMIApiLiveTest.java similarity index 87% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/AMIClientLiveTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/AMIApiLiveTest.java index 5babe82552..3eee397637 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/AMIClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/AMIApiLiveTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.Iterables.concat; @@ -36,8 +36,8 @@ import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilderSpec; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.EC2ApiMetadata; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.Image; import org.jclouds.ec2.domain.Image.ImageType; @@ -53,15 +53,15 @@ import com.google.common.base.Predicate; import com.google.common.collect.ImmutableMap; /** - * Tests behavior of {@code AMIClient} + * Tests behavior of {@code AMIApi} * * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { +public class AMIApiLiveTest extends BaseComputeServiceContextLiveTest { private TemplateBuilderSpec ebsTemplate; - public AMIClientLiveTest() { + public AMIApiLiveTest() { provider = "ec2"; } @@ -74,8 +74,8 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { return overrides; } - protected EC2Client ec2Client; - protected AMIClient client; + protected EC2Api ec2Api; + protected AMIApi client; protected Predicate runningTester; @@ -90,10 +90,10 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi(); - runningTester = retry(new InstanceStateRunning(ec2Client), 600, 5, SECONDS); + ec2Api = view.unwrapApi(EC2Api.class); + runningTester = retry(new InstanceStateRunning(ec2Api), 600, 5, SECONDS); - client = ec2Client.getAMIServices(); + client = ec2Api.getAMIApi().get(); if (ebsTemplate != null) { Template template = view.getComputeService().templateBuilder().from(ebsTemplate).build(); regionId = template.getLocation().getId(); @@ -115,7 +115,7 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { } public void testDescribeImages() { - for (String region : ec2Client.getConfiguredRegions()) { + for (String region : ec2Api.getConfiguredRegions()) { Set allResults = client.describeImagesInRegion(region); assertNotNull(allResults); assert allResults.size() >= 2 : allResults.size(); @@ -164,23 +164,23 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { String instanceId = null; try { - RunningInstance instance = getOnlyElement(concat(ec2Client.getInstanceServices().runInstancesInRegion( + RunningInstance instance = getOnlyElement(concat(ec2Api.getInstanceApi().get().runInstancesInRegion( regionId, null, imageId, 1, 1))); instanceId = instance.getId(); assertTrue(runningTester.apply(instance), instanceId + "didn't achieve the state running!"); - instance = getOnlyElement(concat(ec2Client.getInstanceServices().describeInstancesInRegion(regionId, + instance = getOnlyElement(concat(ec2Api.getInstanceApi().get().describeInstancesInRegion(regionId, instanceId))); BlockDevice device = instance.getEbsBlockDevices().get("/dev/sda1"); assertNotNull(device, "device: /dev/sda1 not present on: " + instance); - Snapshot snapshot = ec2Client.getElasticBlockStoreServices().createSnapshotInRegion(regionId, + Snapshot snapshot = ec2Api.getElasticBlockStoreApi().get().createSnapshotInRegion(regionId, device.getVolumeId()); snapshotsToDelete.add(snapshot.getId()); return snapshot; } finally { if (instanceId != null) - ec2Client.getInstanceServices().terminateInstancesInRegion(regionId, instanceId); + ec2Api.getInstanceApi().get().terminateInstancesInRegion(regionId, instanceId); } } @@ -195,7 +195,7 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { for (String imageId : imagesToDeregister) client.deregisterImageInRegion(regionId, imageId); for (String snapshotId : snapshotsToDelete) - ec2Client.getElasticBlockStoreServices().deleteSnapshotInRegion(regionId, snapshotId); + ec2Api.getElasticBlockStoreApi().get().deleteSnapshotInRegion(regionId, snapshotId); super.tearDownContext(); } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/AMIAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/AMIApiTest.java similarity index 94% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/AMIAsyncClientTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/AMIApiTest.java index 8f53b2eb0a..c3907ab44a 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/AMIAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/AMIApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.executableBy; import static org.jclouds.reflect.Reflection2.method; @@ -40,13 +40,13 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.reflect.Invokable; /** - * Tests behavior of {@code AMIAsyncClient} + * Tests behavior of {@code AMIApi} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "AMIAsyncClientTest") -public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { +@Test(groups = "unit", testName = "AMIApiTest") +public class AMIApiTest extends BaseEC2ApiTest { HttpRequest createImage = HttpRequest.builder().method("POST") .endpoint("https://ec2.us-east-1.amazonaws.com/") @@ -62,7 +62,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testCreateImage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AMIAsyncClient.class, "createImageInRegion", String.class, String.class, String.class, + Invokable method = method(AMIApi.class, "createImageInRegion", String.class, String.class, String.class, CreateImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId")); @@ -95,7 +95,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testCreateImageOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AMIAsyncClient.class, "createImageInRegion", String.class, String.class, String.class, + Invokable method = method(AMIApi.class, "createImageInRegion", String.class, String.class, String.class, CreateImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId", new CreateImageOptions() .withDescription("description").noReboot())); @@ -126,7 +126,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testDescribeImages() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AMIAsyncClient.class, "describeImagesInRegion", String.class, + Invokable method = method(AMIApi.class, "describeImagesInRegion", String.class, DescribeImagesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); @@ -161,7 +161,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testDescribeImagesOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AMIAsyncClient.class, "describeImagesInRegion", String.class, + Invokable method = method(AMIApi.class, "describeImagesInRegion", String.class, DescribeImagesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, executableBy("me").ownedBy("fred", "nancy").imageIds( "1", "2"))); @@ -193,7 +193,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testDeregisterImage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AMIAsyncClient.class, "deregisterImageInRegion", String.class, String.class); + Invokable method = method(AMIApi.class, "deregisterImageInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -224,7 +224,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testRegisterImageFromManifest() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AMIAsyncClient.class, "registerImageFromManifestInRegion", String.class, String.class, + Invokable method = method(AMIApi.class, "registerImageFromManifestInRegion", String.class, String.class, String.class, RegisterImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest")); @@ -256,7 +256,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testRegisterImageFromManifestOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AMIAsyncClient.class, "registerImageFromManifestInRegion", String.class, String.class, + Invokable method = method(AMIApi.class, "registerImageFromManifestInRegion", String.class, String.class, String.class, RegisterImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest", new RegisterImageOptions() .withDescription("description"))); @@ -291,7 +291,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testRegisterImageBackedByEBS() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AMIAsyncClient.class, "registerUnixImageBackedByEbsInRegion", String.class, + Invokable method = method(AMIApi.class, "registerUnixImageBackedByEbsInRegion", String.class, String.class, String.class, RegisterImageBackedByEbsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId")); @@ -332,7 +332,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testRegisterImageBackedByEBSOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AMIAsyncClient.class, "registerUnixImageBackedByEbsInRegion", String.class, + Invokable method = method(AMIApi.class, "registerUnixImageBackedByEbsInRegion", String.class, String.class, String.class, RegisterImageBackedByEbsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId", new RegisterImageBackedByEbsOptions().withDescription("description").addBlockDeviceFromSnapshot( @@ -366,7 +366,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testGetBlockDeviceMappingsForImage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AMIAsyncClient.class, "getBlockDeviceMappingsForImageInRegion", String.class, + Invokable method = method(AMIApi.class, "getBlockDeviceMappingsForImageInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); @@ -398,7 +398,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testGetLaunchPermissionForImage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AMIAsyncClient.class, "getLaunchPermissionForImageInRegion", String.class, String.class); + Invokable method = method(AMIApi.class, "getLaunchPermissionForImageInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -433,7 +433,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testAddLaunchPermissionsToImage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AMIAsyncClient.class, "addLaunchPermissionsToImageInRegion", String.class, + Invokable method = method(AMIApi.class, "addLaunchPermissionsToImageInRegion", String.class, Iterable.class, Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "imageId")); @@ -470,7 +470,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testRemoveLaunchPermissionsFromImage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AMIAsyncClient.class, "removeLaunchPermissionsFromImageInRegion", String.class, + Invokable method = method(AMIApi.class, "removeLaunchPermissionsFromImageInRegion", String.class, Iterable.class, Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "imageId")); @@ -502,7 +502,7 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest { .addFormParam("AWSAccessKeyId", "identity").build(); public void testResetLaunchPermissionsOnImage() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AMIAsyncClient.class, "resetLaunchPermissionsOnImageInRegion", String.class, + Invokable method = method(AMIApi.class, "resetLaunchPermissionsOnImageInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiLiveTest.java similarity index 83% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiLiveTest.java index 4caec98edc..2867e69d22 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiLiveTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.jclouds.ec2.options.DescribeAvailabilityZonesOptions.Builder.availabilityZones; import static org.jclouds.ec2.options.DescribeRegionsOptions.Builder.regions; @@ -28,8 +28,8 @@ import java.util.Set; import java.util.SortedMap; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.EC2ApiMetadata; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.domain.AvailabilityZoneInfo; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -37,29 +37,29 @@ import org.testng.annotations.Test; import com.google.common.collect.Maps; /** - * Tests behavior of {@code AvailabilityZoneAndRegionClient} + * Tests behavior of {@code AvailabilityZoneAndRegionApi} * * @author Adrian Cole */ -@Test(groups = "live", singleThreaded = true, testName = "AvailabilityZoneAndRegionClientLiveTest") -public class AvailabilityZoneAndRegionClientLiveTest extends BaseComputeServiceContextLiveTest { - public AvailabilityZoneAndRegionClientLiveTest() { +@Test(groups = "live", singleThreaded = true, testName = "AvailabilityZoneAndRegionApiLiveTest") +public class AvailabilityZoneAndRegionApiLiveTest extends BaseComputeServiceContextLiveTest { + public AvailabilityZoneAndRegionApiLiveTest() { provider = "ec2"; } - private EC2Client ec2Client; - private AvailabilityZoneAndRegionClient client; + private EC2Api ec2Api; + private AvailabilityZoneAndRegionApi client; @Override @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi(); - client = ec2Client.getAvailabilityZoneAndRegionServices(); + ec2Api = view.unwrapApi(EC2Api.class); + client = ec2Api.getAvailabilityZoneAndRegionApi().get(); } public void testDescribeAvailabilityZones() { - for (String region : ec2Client.getConfiguredRegions()) { + for (String region : ec2Api.getConfiguredRegions()) { Set allResults = client.describeAvailabilityZonesInRegion(region); assertNotNull(allResults); assert allResults.size() >= 1 : allResults.size(); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiTest.java similarity index 91% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiTest.java index 13293fe2e8..ae22fe80c7 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.jclouds.ec2.options.DescribeAvailabilityZonesOptions.Builder.availabilityZones; import static org.jclouds.ec2.options.DescribeRegionsOptions.Builder.regions; @@ -35,17 +35,17 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.reflect.Invokable; /** - * Tests behavior of {@code AvailabilityZoneAndRegionAsyncClient} + * Tests behavior of {@code AvailabilityZoneAndRegionApi} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "AvailabilityZoneAndRegionAsyncClientTest") -public class AvailabilityZoneAndRegionAsyncClientTest extends - BaseEC2AsyncClientTest { +@Test(groups = "unit", testName = "AvailabilityZoneAndRegionApiTest") +public class AvailabilityZoneAndRegionApiTest extends + BaseEC2ApiTest { public void testDescribeAvailabilityZones() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AvailabilityZoneAndRegionAsyncClient.class, "describeAvailabilityZonesInRegion", + Invokable method = method(AvailabilityZoneAndRegionApi.class, "describeAvailabilityZonesInRegion", String.class, DescribeAvailabilityZonesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(Region.US_WEST_1)); @@ -62,7 +62,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends } public void testDescribeAvailabilityZonesOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AvailabilityZoneAndRegionAsyncClient.class, "describeAvailabilityZonesInRegion", + Invokable method = method(AvailabilityZoneAndRegionApi.class, "describeAvailabilityZonesInRegion", String.class, DescribeAvailabilityZonesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("us-east-1", availabilityZones("us-east-1a", "us-east-1b"))); @@ -80,7 +80,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends } public void testDescribeRegions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AvailabilityZoneAndRegionAsyncClient.class, "describeRegions", + Invokable method = method(AvailabilityZoneAndRegionApi.class, "describeRegions", DescribeRegionsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); @@ -97,7 +97,7 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends } public void testDescribeRegionsOptions() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AvailabilityZoneAndRegionAsyncClient.class, "describeRegions", + Invokable method = method(AvailabilityZoneAndRegionApi.class, "describeRegions", DescribeRegionsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of(regions(Region.US_EAST_1, Region.US_WEST_1))); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/BaseEC2ApiTest.java similarity index 89% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/BaseEC2ApiTest.java index af7b3df4a3..190806c6c3 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/BaseEC2AsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/BaseEC2ApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static com.google.common.collect.Maps.transformValues; import static org.testng.Assert.assertEquals; @@ -32,16 +32,15 @@ import org.jclouds.aws.filters.FormSigner; import org.jclouds.compute.domain.Image; import org.jclouds.date.DateService; import org.jclouds.ec2.EC2ApiMetadata; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; -import org.jclouds.ec2.config.EC2RestClientModule; +import org.jclouds.ec2.config.BaseEC2HttpApiModule; import org.jclouds.http.HttpRequest; import org.jclouds.location.config.LocationModule; import org.jclouds.location.suppliers.RegionIdToURISupplier; import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.ConfiguresHttpApi; +import org.jclouds.rest.internal.BaseAsyncApiTest; import org.jclouds.util.Suppliers2; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -59,9 +58,13 @@ import com.google.inject.Provides; * @author Adrian Cole */ @Test(groups = "unit") -public abstract class BaseEC2AsyncClientTest extends BaseAsyncClientTest { - @ConfiguresRestClient - protected static class StubEC2RestClientModule extends EC2RestClientModule { +public abstract class BaseEC2ApiTest extends BaseAsyncApiTest { + @ConfiguresHttpApi + protected static class StubEC2HttpApiModule extends BaseEC2HttpApiModule { + + protected StubEC2HttpApiModule() { + super(EC2Api.class); + } @Provides @Singleton @@ -132,7 +135,7 @@ public abstract class BaseEC2AsyncClientTest extends BaseAsyncClientTest { @Override protected Module createModule() { - return new StubEC2RestClientModule(); + return new StubEC2HttpApiModule(); } @Override diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/EC2ElasticBlockStoreClientExpectTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/EC2ElasticBlockStoreApiExpectTest.java similarity index 88% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/EC2ElasticBlockStoreClientExpectTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/EC2ElasticBlockStoreApiExpectTest.java index b0332c3a91..a72486f606 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/EC2ElasticBlockStoreClientExpectTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/EC2ElasticBlockStoreApiExpectTest.java @@ -14,13 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.testng.Assert.assertEquals; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.domain.Volume; -import org.jclouds.ec2.internal.BaseEC2ClientExpectTest; +import org.jclouds.ec2.internal.BaseEC2ApiExpectTest; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.testng.annotations.Test; @@ -31,8 +31,8 @@ import com.google.common.collect.ImmutableMap.Builder; /** * @author Adrian Cole */ -@Test(groups = "unit", testName = "EC2ElasticBlockStoreClientExpectTest") -public class EC2ElasticBlockStoreClientExpectTest extends BaseEC2ClientExpectTest { +@Test(groups = "unit", testName = "EC2ElasticBlockStoreApiExpectTest") +public class EC2ElasticBlockStoreApiExpectTest extends BaseEC2ApiExpectTest { Volume creating = Volume.builder() .id("vol-2a21e543") .status(Volume.Status.CREATING) @@ -57,7 +57,7 @@ public class EC2ElasticBlockStoreClientExpectTest extends BaseEC2ClientExpectTes .statusCode(200) .payload(payloadFromResource("/created_volume.xml")).build()); - ElasticBlockStoreClient client = requestsSendResponses(builder.build()).getElasticBlockStoreServices(); + ElasticBlockStoreApi client = requestsSendResponses(builder.build()).getElasticBlockStoreApi().get(); assertEquals(client.createVolumeInAvailabilityZone("us-east-1a", 4), creating); } @@ -81,7 +81,7 @@ public class EC2ElasticBlockStoreClientExpectTest extends BaseEC2ClientExpectTes .statusCode(200) .payload(payloadFromResource("/created_volume.xml")).build()); - ElasticBlockStoreClient client = requestsSendResponses(builder.build()).getElasticBlockStoreServices(); + ElasticBlockStoreApi client = requestsSendResponses(builder.build()).getElasticBlockStoreApi().get(); assertEquals(client.createVolumeFromSnapshotInAvailabilityZone(region + "a", 1, "snap-8b7ffbdd"), creating.toBuilder().region(region).build()); } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiLiveTest.java similarity index 91% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiLiveTest.java index 7faeefb5ca..380e35e204 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiLiveTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static com.google.common.base.Preconditions.checkNotNull; import static java.util.concurrent.TimeUnit.SECONDS; import static org.jclouds.ec2.options.DescribeSnapshotsOptions.Builder.snapshotIds; @@ -26,8 +26,8 @@ import java.util.Set; import java.util.SortedSet; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.EC2ApiMetadata; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.domain.AvailabilityZoneInfo; import org.jclouds.ec2.domain.Snapshot; import org.jclouds.ec2.domain.Volume; @@ -42,18 +42,18 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Sets; /** - * Tests behavior of {@code ElasticBlockStoreClient} + * Tests behavior of {@code ElasticBlockStoreApi} * * @author Adrian Cole */ -@Test(groups = "live", singleThreaded = true, testName = "ElasticBlockStoreClientLiveTest") -public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLiveTest { - public ElasticBlockStoreClientLiveTest() { +@Test(groups = "live", singleThreaded = true, testName = "ElasticBlockStoreApiLiveTest") +public class ElasticBlockStoreApiLiveTest extends BaseComputeServiceContextLiveTest { + public ElasticBlockStoreApiLiveTest() { provider = "ec2"; } - private EC2Client ec2Client; - private ElasticBlockStoreClient client; + private EC2Api ec2Api; + private ElasticBlockStoreApi client; private String defaultRegion; private String defaultZone; @@ -65,9 +65,9 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi(); - client = ec2Client.getElasticBlockStoreServices(); - AvailabilityZoneInfo info = Iterables.get(ec2Client.getAvailabilityZoneAndRegionServices() + ec2Api = view.unwrapApi(EC2Api.class); + client = ec2Api.getElasticBlockStoreApi().get(); + AvailabilityZoneInfo info = Iterables.get(ec2Api.getAvailabilityZoneAndRegionApi().get() .describeAvailabilityZonesInRegion(defaultRegion), 0); defaultRegion = checkNotNull(Strings.emptyToNull(info.getRegion()), "region of " + info); defaultZone = checkNotNull(Strings.emptyToNull(info.getZone()), "zone of " + info); @@ -75,7 +75,7 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi @Test void testDescribeVolumes() { - for (String region : ec2Client.getConfiguredRegions()) { + for (String region : ec2Api.getConfiguredRegions()) { SortedSet allResults = Sets.newTreeSet(client.describeVolumesInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { @@ -163,7 +163,7 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi @Test void testDescribeSnapshots() { - for (String region : ec2Client.getConfiguredRegions()) { + for (String region : ec2Api.getConfiguredRegions()) { SortedSet allResults = Sets.newTreeSet(client.describeSnapshotsInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiTest.java similarity index 92% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiTest.java index 58588891c5..b0b4fbadc8 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.jclouds.ec2.options.DescribeSnapshotsOptions.Builder.ownedBy; import static org.jclouds.ec2.options.DetachVolumeOptions.Builder.fromInstance; @@ -42,16 +42,16 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.reflect.Invokable; /** - * Tests behavior of {@code ElasticBlockStoreAsyncClient} + * Tests behavior of {@code ElasticBlockStoreApi} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ElasticBlockStoreAsyncClientTest") -public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest { +@Test(groups = "unit", testName = "ElasticBlockStoreApiTest") +public class ElasticBlockStoreApiTest extends BaseEC2ApiTest { public void testDeleteVolume() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ElasticBlockStoreAsyncClient.class, "deleteVolumeInRegion", String.class, String.class); + Invokable method = method(ElasticBlockStoreApi.class, "deleteVolumeInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -78,7 +78,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticBlockStoreAsyncClient.class, "describeVolumesInRegion", String.class, + Invokable method = method(ElasticBlockStoreApi.class, "describeVolumesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); @@ -97,7 +97,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticBlockStoreAsyncClient.class, "describeVolumesInRegion", String.class, + Invokable method = method(ElasticBlockStoreApi.class, "describeVolumesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); @@ -128,7 +128,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticBlockStoreAsyncClient.class, "attachVolumeInRegion", String.class, String.class, + Invokable method = method(ElasticBlockStoreApi.class, "attachVolumeInRegion", String.class, String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id", "instanceId", "/device")); @@ -160,7 +160,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticBlockStoreAsyncClient.class, "detachVolumeInRegion", String.class, String.class, + Invokable method = method(ElasticBlockStoreApi.class, "detachVolumeInRegion", String.class, String.class, boolean.class, DetachVolumeOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id", false)); @@ -194,7 +194,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticBlockStoreAsyncClient.class, "detachVolumeInRegion", String.class, String.class, + Invokable method = method(ElasticBlockStoreApi.class, "detachVolumeInRegion", String.class, String.class, boolean.class, DetachVolumeOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id", true, fromInstance("instanceId").fromDevice( "/device"))); @@ -214,7 +214,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticBlockStoreAsyncClient.class, "createSnapshotInRegion", String.class, + Invokable method = method(ElasticBlockStoreApi.class, "createSnapshotInRegion", String.class, String.class, CreateSnapshotOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "volumeId")); @@ -231,7 +231,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticBlockStoreAsyncClient.class, "createSnapshotInRegion", String.class, + Invokable method = method(ElasticBlockStoreApi.class, "createSnapshotInRegion", String.class, String.class, CreateSnapshotOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "volumeId", CreateSnapshotOptions.Builder .withDescription("description"))); @@ -250,7 +250,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticBlockStoreAsyncClient.class, "describeSnapshotsInRegion", String.class, + Invokable method = method(ElasticBlockStoreApi.class, "describeSnapshotsInRegion", String.class, DescribeSnapshotsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); @@ -267,7 +267,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticBlockStoreAsyncClient.class, "describeSnapshotsInRegion", String.class, + Invokable method = method(ElasticBlockStoreApi.class, "describeSnapshotsInRegion", String.class, DescribeSnapshotsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ownedBy("o1", "o2").restorableBy("r1", "r2") .snapshotIds("s1", "s2"))); @@ -287,7 +287,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticBlockStoreAsyncClient.class, "getCreateVolumePermissionForSnapshotInRegion", + Invokable method = method(ElasticBlockStoreApi.class, "getCreateVolumePermissionForSnapshotInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "snapshotId")); @@ -323,7 +323,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticBlockStoreAsyncClient.class, "addCreateVolumePermissionsToSnapshotInRegion", + Invokable method = method(ElasticBlockStoreApi.class, "addCreateVolumePermissionsToSnapshotInRegion", String.class, Iterable.class, Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "snapshotId")); @@ -361,7 +361,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticBlockStoreAsyncClient.class, "removeCreateVolumePermissionsFromSnapshotInRegion", + Invokable method = method(ElasticBlockStoreApi.class, "removeCreateVolumePermissionsFromSnapshotInRegion", String.class, Iterable.class, Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "snapshotId")); @@ -382,7 +382,7 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticBlockStoreAsyncClient.class, "resetCreateVolumePermissionsOnSnapshotInRegion", + Invokable method = method(ElasticBlockStoreApi.class, "resetCreateVolumePermissionsOnSnapshotInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "snapshotId")); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiLiveTest.java similarity index 79% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiLiveTest.java index b225e05b26..119c2def00 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiLiveTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -22,8 +22,9 @@ import static org.testng.Assert.assertNotNull; import java.util.SortedSet; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.EC2ApiMetadata; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.ec2.domain.PublicIpInstanceIdPair; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -31,30 +32,30 @@ import org.testng.annotations.Test; import com.google.common.collect.Sets; /** - * Tests behavior of {@code ElasticIPAddressClient} + * Tests behavior of {@code ElasticIPAddressApi} * * @author Adrian Cole */ -@Test(groups = "live", singleThreaded = true, testName = "ElasticIPAddressClientLiveTest") -public class ElasticIPAddressClientLiveTest extends BaseComputeServiceContextLiveTest { - public ElasticIPAddressClientLiveTest() { +@Test(groups = "live", singleThreaded = true, testName = "ElasticIPAddressApiLiveTest") +public class ElasticIPAddressApiLiveTest extends BaseComputeServiceContextLiveTest { + public ElasticIPAddressApiLiveTest() { provider = "ec2"; } - private EC2Client ec2Client; - private ElasticIPAddressClient client; + private EC2Api ec2Api; + private ElasticIPAddressApi client; @Override @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi(); - client = ec2Client.getElasticIPAddressServices(); + ec2Api = view.unwrapApi(EC2Api.class); + client = ec2Api.getElasticIPAddressApi().get(); } @Test void testDescribeAddresses() { - for (String region : ec2Client.getConfiguredRegions()) { + for (String region : ec2Api.getConfiguredRegions()) { SortedSet allResults = Sets.newTreeSet(client.describeAddressesInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiTest.java similarity index 88% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClientTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiTest.java index 4ac89c2eca..d230ca409c 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.jclouds.reflect.Reflection2.method; @@ -32,16 +32,16 @@ import org.testng.annotations.Test; import com.google.common.collect.Lists; import com.google.common.reflect.Invokable; /** - * Tests behavior of {@code ElasticIPAddressAsyncClient} + * Tests behavior of {@code ElasticIPAddressApi} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ElasticIPAddressAsyncClientTest") -public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest { +@Test(groups = "unit", testName = "ElasticIPAddressApiTest") +public class ElasticIPAddressApiTest extends BaseEC2ApiTest { public void testDisassociateAddress() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(ElasticIPAddressAsyncClient.class, "disassociateAddressInRegion", String.class, + Invokable method = method(ElasticIPAddressApi.class, "disassociateAddressInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1")); @@ -71,7 +71,7 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticIPAddressAsyncClient.class, "associateAddressInRegion", String.class, + Invokable method = method(ElasticIPAddressApi.class, "associateAddressInRegion", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1", "me")); @@ -90,7 +90,7 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticIPAddressAsyncClient.class, "releaseAddressInRegion", String.class, String.class); + Invokable method = method(ElasticIPAddressApi.class, "releaseAddressInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -106,7 +106,7 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticIPAddressAsyncClient.class, "describeAddressesInRegion", String.class, + Invokable method = method(ElasticIPAddressApi.class, "describeAddressesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "127.0.0.1")); @@ -123,7 +123,7 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest method = method(ElasticIPAddressAsyncClient.class, "allocateAddressInRegion", String.class); + Invokable method = method(ElasticIPAddressApi.class, "allocateAddressInRegion", String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/InstanceApiLiveTest.java similarity index 77% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceClientLiveTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/InstanceApiLiveTest.java index 2ca4b85eb4..57f9441195 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/InstanceApiLiveTest.java @@ -14,45 +14,45 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.testng.Assert.assertNotNull; import java.util.Set; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.EC2ApiMetadata; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** - * Tests behavior of {@code EC2Client} + * Tests behavior of {@code EC2Api} * * @author Adrian Cole */ -@Test(groups = "live", singleThreaded = true, testName = "InstanceClientLiveTest") -public class InstanceClientLiveTest extends BaseComputeServiceContextLiveTest { - public InstanceClientLiveTest() { +@Test(groups = "live", singleThreaded = true, testName = "InstanceApiLiveTest") +public class InstanceApiLiveTest extends BaseComputeServiceContextLiveTest { + public InstanceApiLiveTest() { provider = "ec2"; } - private EC2Client ec2Client; - private InstanceClient client; + private EC2Api ec2Api; + private InstanceApi client; @Override @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi(); - client = ec2Client.getInstanceServices(); + ec2Api = view.unwrapApi(EC2Api.class); + client = ec2Api.getInstanceApi().get(); } @Test void testDescribeInstances() { - for (String region : ec2Client.getConfiguredRegions()) { + for (String region : ec2Api.getConfiguredRegions()) { Set> allResults = client.describeInstancesInRegion(region); assertNotNull(allResults); assert allResults.size() >= 0 : allResults.size(); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/InstanceApiTest.java similarity index 91% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/InstanceApiTest.java index 5e6da902f5..2f177351bb 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/InstanceApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.jclouds.reflect.Reflection2.method; @@ -47,15 +47,15 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.reflect.Invokable; /** - * Tests behavior of {@code InstanceAsyncClient} + * Tests behavior of {@code InstanceApi} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "InstanceAsyncClientTest") -public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest { +@Test(groups = "unit", testName = "InstanceApiTest") +public class InstanceApiTest extends BaseEC2ApiTest { public void testDescribeInstances() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(InstanceAsyncClient.class, "describeInstancesInRegion", String.class, String[].class); + Invokable method = method(InstanceApi.class, "describeInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -71,7 +71,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "describeInstancesInRegion", String.class, String[].class); + Invokable method = method(InstanceApi.class, "describeInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -87,7 +87,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "terminateInstancesInRegion", String.class, + Invokable method = method(InstanceApi.class, "terminateInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); @@ -104,7 +104,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "runInstancesInRegion", String.class, String.class, + Invokable method = method(InstanceApi.class, "runInstancesInRegion", String.class, String.class, String.class, int.class, int.class, RunInstancesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, null, "ami-voo", 1, 1)); @@ -126,7 +126,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "runInstancesInRegion", String.class, String.class, + Invokable method = method(InstanceApi.class, "runInstancesInRegion", String.class, String.class, String.class, int.class, int.class, RunInstancesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, ImmutableList. of("eu-west-1", "eu-west-1a", "ami-voo", 1, 5, new RunInstancesOptions().withKernelId("kernelId").withSecurityGroups("group1", "group2"))); @@ -153,7 +153,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "stopInstancesInRegion", String.class, boolean.class, + Invokable method = method(InstanceApi.class, "stopInstancesInRegion", String.class, boolean.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, true, "1", "2")); @@ -170,7 +170,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "rebootInstancesInRegion", String.class, String[].class); + Invokable method = method(InstanceApi.class, "rebootInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -186,7 +186,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "startInstancesInRegion", String.class, String[].class); + Invokable method = method(InstanceApi.class, "startInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -202,7 +202,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "getUserDataForInstanceInRegion", String.class, String.class); + Invokable method = method(InstanceApi.class, "getUserDataForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -219,7 +219,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "getRootDeviceNameForInstanceInRegion", String.class, + Invokable method = method(InstanceApi.class, "getRootDeviceNameForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); @@ -237,7 +237,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "getRamdiskForInstanceInRegion", String.class, String.class); + Invokable method = method(InstanceApi.class, "getRamdiskForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -255,7 +255,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "isApiTerminationDisabledForInstanceInRegion", String.class, + Invokable method = method(InstanceApi.class, "isApiTerminationDisabledForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); @@ -273,7 +273,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "getKernelForInstanceInRegion", String.class, String.class); + Invokable method = method(InstanceApi.class, "getKernelForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -289,7 +289,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "getInstanceTypeForInstanceInRegion", String.class, + Invokable method = method(InstanceApi.class, "getInstanceTypeForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); @@ -308,7 +308,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "getInstanceInitiatedShutdownBehaviorForInstanceInRegion", + Invokable method = method(InstanceApi.class, "getInstanceInitiatedShutdownBehaviorForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); @@ -328,7 +328,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "getBlockDeviceMappingForInstanceInRegion", String.class, + Invokable method = method(InstanceApi.class, "getBlockDeviceMappingForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); @@ -360,7 +360,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "setUserDataForInstanceInRegion", String.class, String.class, + Invokable method = method(InstanceApi.class, "setUserDataForInstanceInRegion", String.class, String.class, byte[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test".getBytes())); @@ -393,7 +393,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "setRamdiskForInstanceInRegion", String.class, String.class, + Invokable method = method(InstanceApi.class, "setRamdiskForInstanceInRegion", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); @@ -426,7 +426,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "setKernelForInstanceInRegion", String.class, String.class, + Invokable method = method(InstanceApi.class, "setKernelForInstanceInRegion", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); @@ -460,7 +460,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "setApiTerminationDisabledForInstanceInRegion", String.class, + Invokable method = method(InstanceApi.class, "setApiTerminationDisabledForInstanceInRegion", String.class, String.class, boolean.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", true)); @@ -493,7 +493,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "setInstanceTypeForInstanceInRegion", String.class, + Invokable method = method(InstanceApi.class, "setInstanceTypeForInstanceInRegion", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceType.C1_MEDIUM)); @@ -527,7 +527,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "setInstanceInitiatedShutdownBehaviorForInstanceInRegion", + Invokable method = method(InstanceApi.class, "setInstanceInitiatedShutdownBehaviorForInstanceInRegion", String.class, String.class, InstanceInitiatedShutdownBehavior.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceInitiatedShutdownBehavior.TERMINATE)); @@ -556,7 +556,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "setBlockDeviceMappingForInstanceInRegion", String.class, + Invokable method = method(InstanceApi.class, "setBlockDeviceMappingForInstanceInRegion", String.class, String.class, Map.class); Map mapping = Maps.newLinkedHashMap(); @@ -575,7 +575,7 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest method = method(InstanceAsyncClient.class, "getConsoleOutputForInstanceInRegion", String.class, String.class); + Invokable method = method(InstanceApi.class, "getConsoleOutputForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/KeyPairApiLiveTest.java similarity index 85% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairClientLiveTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/KeyPairApiLiveTest.java index 06201fcf28..c8bbff0799 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/KeyPairApiLiveTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -23,8 +23,8 @@ import java.util.Set; import java.util.SortedSet; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.EC2ApiMetadata; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.domain.KeyPair; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -32,30 +32,30 @@ import org.testng.annotations.Test; import com.google.common.collect.Sets; /** - * Tests behavior of {@code KeyPairClient} + * Tests behavior of {@code KeyPairApi} * * @author Adrian Cole */ -@Test(groups = "live", singleThreaded = true, testName = "KeyPairClientLiveTest") -public class KeyPairClientLiveTest extends BaseComputeServiceContextLiveTest { - public KeyPairClientLiveTest() { +@Test(groups = "live", singleThreaded = true, testName = "KeyPairApiLiveTest") +public class KeyPairApiLiveTest extends BaseComputeServiceContextLiveTest { + public KeyPairApiLiveTest() { provider = "ec2"; } - private EC2Client ec2Client; - private KeyPairClient client; + private EC2Api ec2Api; + private KeyPairApi client; @Override @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi(); - client = ec2Client.getKeyPairServices(); + ec2Api = view.unwrapApi(EC2Api.class); + client = ec2Api.getKeyPairApi().get(); } @Test void testDescribeKeyPairs() { - for (String region : ec2Client.getConfiguredRegions()) { + for (String region : ec2Api.getConfiguredRegions()) { SortedSet allResults = Sets.newTreeSet(client.describeKeyPairsInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/KeyPairApiTest.java similarity index 86% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairAsyncClientTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/KeyPairApiTest.java index ebc3b5efbf..1d4207654a 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/KeyPairApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.jclouds.reflect.Reflection2.method; @@ -30,16 +30,16 @@ import org.testng.annotations.Test; import com.google.common.collect.Lists; import com.google.common.reflect.Invokable; /** - * Tests behavior of {@code KeyPairAsyncClient} + * Tests behavior of {@code KeyPairApi} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "KeyPairAsyncClientTest") -public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest { +@Test(groups = "unit", testName = "KeyPairApiTest") +public class KeyPairApiTest extends BaseEC2ApiTest { public void testDeleteKeyPair() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(KeyPairAsyncClient.class, "deleteKeyPairInRegion", String.class, String.class); + Invokable method = method(KeyPairApi.class, "deleteKeyPairInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -55,7 +55,7 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest method = method(KeyPairAsyncClient.class, "describeKeyPairsInRegion", String.class, String[].class); + Invokable method = method(KeyPairApi.class, "describeKeyPairsInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -71,7 +71,7 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest method = method(KeyPairAsyncClient.class, "describeKeyPairsInRegion", String.class, String[].class); + Invokable method = method(KeyPairApi.class, "describeKeyPairsInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/SecurityGroupApiLiveTest.java similarity index 92% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/SecurityGroupApiLiveTest.java index c6d02d2fad..220e14f6f5 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/SecurityGroupApiLiveTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static com.google.common.base.Predicates.compose; import static com.google.common.base.Predicates.in; @@ -28,8 +28,8 @@ import static org.testng.Assert.assertTrue; import java.util.Set; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.EC2ApiMetadata; -import org.jclouds.ec2.EC2Client; import org.jclouds.ec2.domain.SecurityGroup; import org.jclouds.ec2.domain.UserIdGroupPair; import org.jclouds.net.domain.IpPermission; @@ -44,30 +44,30 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; /** - * Tests behavior of {@code SecurityGroupClient} + * Tests behavior of {@code SecurityGroupApi} * * @author Adrian Cole */ -@Test(groups = "live", singleThreaded = true, testName = "SecurityGroupClientLiveTest") -public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTest { - public SecurityGroupClientLiveTest() { +@Test(groups = "live", singleThreaded = true, testName = "SecurityGroupApiLiveTest") +public class SecurityGroupApiLiveTest extends BaseComputeServiceContextLiveTest { + public SecurityGroupApiLiveTest() { provider = "ec2"; } - private EC2Client ec2Client; - protected SecurityGroupClient client; + private EC2Api ec2Api; + protected SecurityGroupApi client; @Override @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - ec2Client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi(); - client = ec2Client.getSecurityGroupServices(); + ec2Api = view.unwrapApi(EC2Api.class); + client = ec2Api.getSecurityGroupApi().get(); } @Test void testDescribe() { - for (String region : ec2Client.getConfiguredRegions()) { + for (String region : ec2Api.getConfiguredRegions()) { Set allResults = client.describeSecurityGroupsInRegion(region); assertNotNull(allResults); if (allResults.size() >= 1) { @@ -196,11 +196,11 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe } public static final class GroupHasPermission implements Runnable { - private final SecurityGroupClient client; + private final SecurityGroupApi client; private final String group; private final Predicate permission; - public GroupHasPermission(SecurityGroupClient client, String group, Predicate permission) { + public GroupHasPermission(SecurityGroupApi client, String group, Predicate permission) { this.client = client; this.group = group; this.permission = permission; @@ -218,10 +218,10 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe } public static final class GroupHasNoPermissions implements Runnable { - private final SecurityGroupClient client; + private final SecurityGroupApi client; private final String group; - public GroupHasNoPermissions(SecurityGroupClient client, String group) { + public GroupHasNoPermissions(SecurityGroupApi client, String group) { this.client = client; this.group = group; } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java similarity index 91% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupAsyncClientTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java index c22a279563..85b73741de 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.jclouds.reflect.Reflection2.method; @@ -34,16 +34,16 @@ import org.testng.annotations.Test; import com.google.common.collect.Lists; import com.google.common.reflect.Invokable; /** - * Tests behavior of {@code SecurityGroupAsyncClient} + * Tests behavior of {@code SecurityGroupApi} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "SecurityGroupAsyncClientTest") -public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest { +@Test(groups = "unit", testName = "SecurityGroupApiTest") +public class SecurityGroupApiTest extends BaseEC2ApiTest { public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(SecurityGroupAsyncClient.class, "deleteSecurityGroupInRegion", String.class, + Invokable method = method(SecurityGroupApi.class, "deleteSecurityGroupInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name")); @@ -73,7 +73,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = method(SecurityGroupAsyncClient.class, "createSecurityGroupInRegion", String.class, + Invokable method = method(SecurityGroupApi.class, "createSecurityGroupInRegion", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "description")); @@ -92,7 +92,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = method(SecurityGroupAsyncClient.class, "describeSecurityGroupsInRegion", String.class, + Invokable method = method(SecurityGroupApi.class, "describeSecurityGroupsInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); @@ -109,7 +109,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = method(SecurityGroupAsyncClient.class, "describeSecurityGroupsInRegion", String.class, + Invokable method = method(SecurityGroupApi.class, "describeSecurityGroupsInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); @@ -126,7 +126,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = method(SecurityGroupAsyncClient.class, "authorizeSecurityGroupIngressInRegion", String.class, + Invokable method = method(SecurityGroupApi.class, "authorizeSecurityGroupIngressInRegion", String.class, String.class, UserIdGroupPair.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", new UserIdGroupPair("sourceUser", "sourceGroup"))); @@ -162,7 +162,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = method(SecurityGroupAsyncClient.class, "authorizeSecurityGroupIngressInRegion", String.class, + Invokable method = method(SecurityGroupApi.class, "authorizeSecurityGroupIngressInRegion", String.class, String.class, IpProtocol.class, int.class, int.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0")); @@ -180,7 +180,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = method(SecurityGroupAsyncClient.class, "revokeSecurityGroupIngressInRegion", String.class, + Invokable method = method(SecurityGroupApi.class, "revokeSecurityGroupIngressInRegion", String.class, String.class, UserIdGroupPair.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", new UserIdGroupPair("sourceUser", "sourceGroup"))); @@ -216,7 +216,7 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest method = method(SecurityGroupAsyncClient.class, "revokeSecurityGroupIngressInRegion", String.class, + Invokable method = method(SecurityGroupApi.class, "revokeSecurityGroupIngressInRegion", String.class, String.class, IpProtocol.class, int.class, int.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpProtocol.TCP, 6000, 7000, "0.0.0.0/0")); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsAsyncClientTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/features/WindowsApiTest.java similarity index 92% rename from apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsAsyncClientTest.java rename to apis/ec2/src/test/java/org/jclouds/ec2/features/WindowsApiTest.java index fb825cb2e2..572b247f85 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsAsyncClientTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/features/WindowsApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.ec2.services; +package org.jclouds.ec2.features; import static org.jclouds.reflect.Reflection2.method; @@ -32,13 +32,13 @@ import org.testng.annotations.Test; import com.google.common.collect.Lists; import com.google.common.reflect.Invokable; /** - * Tests behavior of {@code WindowsAsyncClient} + * Tests behavior of {@code WindowsApi} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "WindowsAsyncClientTest") -public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest { +@Test(groups = "unit", testName = "WindowsApiTest") +public class WindowsApiTest extends BaseEC2ApiTest { HttpRequest bundleInstanceInRegion = HttpRequest.builder().method("POST") .endpoint("https://ec2.us-east-1.amazonaws.com/") @@ -57,7 +57,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest method = method(WindowsAsyncClient.class, "bundleInstanceInRegion", String.class, String.class, + Invokable method = method(WindowsApi.class, "bundleInstanceInRegion", String.class, String.class, String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class); GeneratedHttpRequest request = processor .createRequest( @@ -101,7 +101,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest method = method(WindowsAsyncClient.class, "bundleInstanceInRegion", String.class, String.class, + Invokable method = method(WindowsApi.class, "bundleInstanceInRegion", String.class, String.class, String.class, String.class, String.class, BundleInstanceS3StorageOptions[].class); GeneratedHttpRequest request = processor .createRequest( @@ -129,7 +129,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest method = method(WindowsAsyncClient.class, "describeBundleTasksInRegion", String.class, String[].class); + Invokable method = method(WindowsApi.class, "describeBundleTasksInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -145,7 +145,7 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest method = method(WindowsAsyncClient.class, "describeBundleTasksInRegion", String.class, String[].class); + Invokable method = method(WindowsApi.class, "describeBundleTasksInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiExpectTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiExpectTest.java index bb84890885..574ef6bb46 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiExpectTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiExpectTest.java @@ -20,9 +20,8 @@ import java.util.concurrent.atomic.AtomicInteger; import org.jclouds.date.DateService; import org.jclouds.ec2.EC2Api; -import org.jclouds.ec2.EC2AsyncApi; -import org.jclouds.ec2.config.EC2RestClientModule; -import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.ec2.config.BaseEC2HttpApiModule; +import org.jclouds.rest.ConfiguresHttpApi; import com.google.common.base.Supplier; import com.google.inject.Module; @@ -31,9 +30,13 @@ import com.google.inject.TypeLiteral; public abstract class BaseEC2ApiExpectTest extends BaseEC2ExpectTest { - @ConfiguresRestClient - protected static class TestEC2RestClientModule extends EC2RestClientModule { + @ConfiguresHttpApi + protected static class TestEC2HttpApiModule extends BaseEC2HttpApiModule { + protected TestEC2HttpApiModule() { + super(EC2Api.class); + } + @Override protected void configure() { super.configure(); @@ -59,6 +62,6 @@ public abstract class BaseEC2ApiExpectTest extends BaseEC2ExpectTest { @Override protected Module createModule() { - return new TestEC2RestClientModule(); + return new TestEC2HttpApiModule(); } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/internal/BaseEC2ClientExpectTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/internal/BaseEC2ClientExpectTest.java deleted file mode 100644 index 15b8b27875..0000000000 --- a/apis/ec2/src/test/java/org/jclouds/ec2/internal/BaseEC2ClientExpectTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.internal; - -import java.util.concurrent.atomic.AtomicInteger; - -import org.jclouds.date.DateService; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.config.EC2RestClientModule; -import org.jclouds.rest.ConfiguresRestClient; - -import com.google.common.base.Supplier; -import com.google.inject.Module; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; - -public abstract class BaseEC2ClientExpectTest extends BaseEC2ExpectTest { - - @ConfiguresRestClient - protected static class TestEC2RestClientModule extends EC2RestClientModule { - - @Override - protected void configure() { - super.configure(); - // predictable node names - final AtomicInteger suffix = new AtomicInteger(); - bind(new TypeLiteral>() { - }).toInstance(new Supplier() { - - @Override - public String get() { - return suffix.getAndIncrement() + ""; - } - - }); - } - - @Override - @Provides - protected String provideTimeStamp(DateService dateService) { - return CONSTANT_DATE; - } - } - - @Override - protected Module createModule() { - return new TestEC2RestClientModule(); - } -} diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java index a30c1e0109..3d3d70f1d6 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java @@ -30,7 +30,7 @@ import java.util.Set; import org.jclouds.ec2.domain.Attachment; import org.jclouds.ec2.domain.Attachment.Status; import org.jclouds.ec2.domain.Volume; -import org.jclouds.ec2.services.ElasticBlockStoreClient; +import org.jclouds.ec2.features.ElasticBlockStoreApi; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -41,12 +41,12 @@ import org.testng.annotations.Test; @Test(groups = "unit", singleThreaded = true) public class VolumeDetachedTest { - private ElasticBlockStoreClient client; + private ElasticBlockStoreApi client; private VolumeDetached volumeDetached; @BeforeMethod public void setUp() { - client = createMock(ElasticBlockStoreClient.class); + client = createMock(ElasticBlockStoreApi.class); volumeDetached = new VolumeDetached(client); } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java index ecc9acefa3..89148056d6 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java @@ -25,13 +25,14 @@ import java.util.Map; import java.util.Set; import org.easymock.classextension.IMocksControl; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.domain.AvailabilityZoneInfo; -import org.jclouds.ec2.services.AvailabilityZoneAndRegionClient; +import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpResponseException; import org.testng.annotations.Test; +import com.google.common.base.Optional; import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -46,15 +47,15 @@ public class DescribeAvailabilityZonesInRegionTest { @Test public void testDescribeAvailabilityZonesInRegion_BestEffort() { IMocksControl control = createControl(); - EC2Client client = control.createMock(EC2Client.class); - AvailabilityZoneAndRegionClient regionClient = control.createMock(AvailabilityZoneAndRegionClient.class); + EC2Api client = control.createMock(EC2Api.class); + AvailabilityZoneAndRegionApi regionClient = control.createMock(AvailabilityZoneAndRegionApi.class); AvailabilityZoneInfo info1 = control.createMock(AvailabilityZoneInfo.class); AvailabilityZoneInfo info2 = control.createMock(AvailabilityZoneInfo.class); HttpCommand command = control.createMock(HttpCommand.class); HttpResponseException exception = new HttpResponseException("Error: Unable to tunnel through proxy: ...", command, null); - expect(client.getAvailabilityZoneAndRegionServices()).andStubReturn(regionClient); + expect(client.getAvailabilityZoneAndRegionApi()).andStubReturn((Optional) Optional.of(regionClient)); expect(regionClient.describeAvailabilityZonesInRegion("accessibleRegion1")).andReturn( ImmutableSet.of(info1)); expect(regionClient.describeAvailabilityZonesInRegion("inaccessibleRegion")).andThrow(exception); @@ -79,13 +80,13 @@ public class DescribeAvailabilityZonesInRegionTest { @Test public void testDescribeAvailabilityZonesInRegion_RethrowIfNoneFound() { IMocksControl control = createControl(); - EC2Client client = control.createMock(EC2Client.class); - AvailabilityZoneAndRegionClient regionClient = control.createMock(AvailabilityZoneAndRegionClient.class); + EC2Api client = control.createMock(EC2Api.class); + AvailabilityZoneAndRegionApi regionClient = control.createMock(AvailabilityZoneAndRegionApi.class); HttpCommand command = control.createMock(HttpCommand.class); HttpResponseException exception = new HttpResponseException("Error: Unable to tunnel through proxy: ...", command, null); - expect(client.getAvailabilityZoneAndRegionServices()).andStubReturn(regionClient); + expect(client.getAvailabilityZoneAndRegionApi()).andStubReturn((Optional) Optional.of(regionClient)); expect(regionClient.describeAvailabilityZonesInRegion("inaccessibleRegion")).andThrow(exception); Set regions = ImmutableSet.of("inaccessibleRegion"); @@ -105,10 +106,10 @@ public class DescribeAvailabilityZonesInRegionTest { @Test public void testDescribeAvailabilityZonesInRegion_NoZones() { IMocksControl control = createControl(); - EC2Client client = control.createMock(EC2Client.class); - AvailabilityZoneAndRegionClient regionClient = control.createMock(AvailabilityZoneAndRegionClient.class); + EC2Api client = control.createMock(EC2Api.class); + AvailabilityZoneAndRegionApi regionClient = control.createMock(AvailabilityZoneAndRegionApi.class); - expect(client.getAvailabilityZoneAndRegionServices()).andStubReturn(regionClient); + expect(client.getAvailabilityZoneAndRegionApi()).andStubReturn((Optional) Optional.of(regionClient)); expect(regionClient.describeAvailabilityZonesInRegion("emptyRegion")).andReturn( ImmutableSet. of()); diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2Client.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2Api.java similarity index 62% rename from apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2Client.java rename to apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2Api.java index f0c0bea8a3..47800acf9b 100644 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2Client.java +++ b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2Api.java @@ -16,21 +16,32 @@ */ package org.jclouds.openstack.nova.ec2; -import org.jclouds.ec2.EC2Client; -import org.jclouds.openstack.nova.ec2.services.NovaEC2KeyPairClient; +import org.jclouds.ec2.EC2Api; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; +import org.jclouds.openstack.nova.ec2.features.NovaEC2KeyPairApi; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; + +import com.google.common.base.Optional; /** * Provides synchronous access to EC2 services. * * @author Adam Lowe */ -public interface NovaEC2Client extends EC2Client { +public interface NovaEC2Api extends EC2Api { /** * {@inheritDoc} */ @Delegate @Override - NovaEC2KeyPairClient getKeyPairServices(); + Optional getKeyPairApi(); + + @Delegate + @Override + Optional getKeyPairApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + } diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java index 5c6a22c0a6..d24e334a66 100644 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java +++ b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2ApiMetadata.java @@ -30,7 +30,7 @@ import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; import org.jclouds.openstack.nova.ec2.config.HyphenToNullIso8601Module; import org.jclouds.openstack.nova.ec2.config.NovaEC2ComputeServiceContextModule; -import org.jclouds.openstack.nova.ec2.config.NovaEC2RestClientModule; +import org.jclouds.openstack.nova.ec2.config.NovaEC2HttpApiModule; import com.google.common.collect.ImmutableSet; import com.google.common.reflect.TypeToken; @@ -43,15 +43,6 @@ import com.google.inject.Module; */ public class NovaEC2ApiMetadata extends EC2ApiMetadata { - /** - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(NovaEC2Client.class)} as - * {@link NovaEC2AsyncClient} interface will be removed in jclouds 1.7. - */ - @Deprecated - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -85,15 +76,13 @@ public class NovaEC2ApiMetadata extends EC2ApiMetadata { public static class Builder extends EC2ApiMetadata.Builder { @SuppressWarnings("deprecation") protected Builder(){ - super(NovaEC2Client.class, NovaEC2AsyncClient.class); id("openstack-nova-ec2") .name("OpenStack Nova's EC2-clone API") .version("2009-04-04") .defaultEndpoint("http://localhost:8773/services/Cloud") .defaultProperties(NovaEC2ApiMetadata.defaultProperties()) - .context(CONTEXT_TOKEN) .defaultModules(ImmutableSet.>builder() - .add(NovaEC2RestClientModule.class) + .add(NovaEC2HttpApiModule.class) .add(EC2ResolveImagesModule.class) .add(NovaEC2ComputeServiceContextModule.class) .add(HyphenToNullIso8601Module.class).build()); diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2AsyncClient.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2AsyncClient.java deleted file mode 100644 index 0e208e9be5..0000000000 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/NovaEC2AsyncClient.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.openstack.nova.ec2; - -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.openstack.nova.ec2.services.NovaEC2KeyPairAsyncClient; -import org.jclouds.rest.annotations.Delegate; - -/** - * Provides asynchronous access to EC2 services. - * - * @author Adam Lowe - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(NovaEC2Client.class)} as - * {@link NovaEC2AsyncClient} interface will be removed in jclouds 1.7. - */ -@Deprecated -public interface NovaEC2AsyncClient extends EC2AsyncClient { - /** - * {@inheritDoc} - */ - @Delegate - @Override - NovaEC2KeyPairAsyncClient getKeyPairServices(); -} diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2HttpApiModule.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2HttpApiModule.java new file mode 100644 index 0000000000..08ff6659e3 --- /dev/null +++ b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2HttpApiModule.java @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.openstack.nova.ec2.config; + +import static org.jclouds.reflect.Reflection2.typeToken; + +import java.util.Map; + +import javax.inject.Singleton; + +import org.jclouds.ec2.EC2Api; +import org.jclouds.ec2.config.BaseEC2HttpApiModule; +import org.jclouds.ec2.features.SubnetApi; +import org.jclouds.ec2.features.TagApi; +import org.jclouds.ec2.features.WindowsApi; +import org.jclouds.ec2.features.AMIApi; +import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi; +import org.jclouds.ec2.features.ElasticBlockStoreApi; +import org.jclouds.ec2.features.ElasticIPAddressApi; +import org.jclouds.ec2.features.InstanceApi; +import org.jclouds.ec2.features.SecurityGroupApi; +import org.jclouds.ec2.suppliers.DescribeAvailabilityZonesInRegion; +import org.jclouds.ec2.xml.CreateVolumeResponseHandler; +import org.jclouds.ec2.xml.DescribeImagesResponseHandler; +import org.jclouds.location.config.LocationModule; +import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; +import org.jclouds.location.suppliers.ZoneIdsSupplier; +import org.jclouds.location.suppliers.derived.ZoneIdsFromRegionIdToZoneIdsValues; +import org.jclouds.openstack.nova.ec2.NovaEC2Api; +import org.jclouds.openstack.nova.ec2.features.NovaEC2KeyPairApi; +import org.jclouds.openstack.nova.ec2.xml.NovaCreateVolumeResponseHandler; +import org.jclouds.openstack.nova.ec2.xml.NovaDescribeImagesResponseHandler; +import org.jclouds.rest.ConfiguresHttpApi; + +import com.google.common.collect.ImmutableMap; +import com.google.inject.Provides; +import com.google.inject.Scopes; + +/** + * + * @author Adrian Cole + * @author Adam Lowe + */ +@ConfiguresHttpApi +public class NovaEC2HttpApiModule extends BaseEC2HttpApiModule { + + public NovaEC2HttpApiModule() { + super(NovaEC2Api.class); + } + + @Override + protected void configure() { + bind(EC2Api.class).to(NovaEC2Api.class); + super.configure(); + bind(CreateVolumeResponseHandler.class).to(NovaCreateVolumeResponseHandler.class).in(Scopes.SINGLETON); + bind(DescribeImagesResponseHandler.class).to(NovaDescribeImagesResponseHandler.class); + } + + @Override + protected void installLocations() { + install(new LocationModule()); + bind(RegionIdToZoneIdsSupplier.class).to(DescribeAvailabilityZonesInRegion.class).in(Scopes.SINGLETON); + // there is only one region, and its endpoint is the same as the provider + bind(ZoneIdsSupplier.class).to(ZoneIdsFromRegionIdToZoneIdsValues.class).in(Scopes.SINGLETON); + } + +} diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java deleted file mode 100644 index 0669f149d8..0000000000 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/config/NovaEC2RestClientModule.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.openstack.nova.ec2.config; - -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.util.Map; - -import javax.inject.Singleton; - -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.config.EC2RestClientModule; -import org.jclouds.ec2.features.SubnetApi; -import org.jclouds.ec2.features.SubnetAsyncApi; -import org.jclouds.ec2.features.TagApi; -import org.jclouds.ec2.features.TagAsyncApi; -import org.jclouds.ec2.features.WindowsApi; -import org.jclouds.ec2.features.WindowsAsyncApi; -import org.jclouds.ec2.services.AMIAsyncClient; -import org.jclouds.ec2.services.AMIClient; -import org.jclouds.ec2.services.AvailabilityZoneAndRegionAsyncClient; -import org.jclouds.ec2.services.AvailabilityZoneAndRegionClient; -import org.jclouds.ec2.services.ElasticBlockStoreAsyncClient; -import org.jclouds.ec2.services.ElasticBlockStoreClient; -import org.jclouds.ec2.services.ElasticIPAddressAsyncClient; -import org.jclouds.ec2.services.ElasticIPAddressClient; -import org.jclouds.ec2.services.InstanceAsyncClient; -import org.jclouds.ec2.services.InstanceClient; -import org.jclouds.ec2.services.SecurityGroupAsyncClient; -import org.jclouds.ec2.services.SecurityGroupClient; -import org.jclouds.ec2.services.WindowsAsyncClient; -import org.jclouds.ec2.services.WindowsClient; -import org.jclouds.ec2.suppliers.DescribeAvailabilityZonesInRegion; -import org.jclouds.ec2.xml.CreateVolumeResponseHandler; -import org.jclouds.ec2.xml.DescribeImagesResponseHandler; -import org.jclouds.location.config.LocationModule; -import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; -import org.jclouds.location.suppliers.ZoneIdsSupplier; -import org.jclouds.location.suppliers.derived.ZoneIdsFromRegionIdToZoneIdsValues; -import org.jclouds.openstack.nova.ec2.NovaEC2AsyncClient; -import org.jclouds.openstack.nova.ec2.NovaEC2Client; -import org.jclouds.openstack.nova.ec2.services.NovaEC2KeyPairAsyncClient; -import org.jclouds.openstack.nova.ec2.services.NovaEC2KeyPairClient; -import org.jclouds.openstack.nova.ec2.xml.NovaCreateVolumeResponseHandler; -import org.jclouds.openstack.nova.ec2.xml.NovaDescribeImagesResponseHandler; -import org.jclouds.rest.ConfiguresRestClient; - -import com.google.common.collect.ImmutableMap; -import com.google.inject.Provides; -import com.google.inject.Scopes; - -/** - * - * @author Adrian Cole - * @author Adam Lowe - */ -@ConfiguresRestClient -public class NovaEC2RestClientModule extends EC2RestClientModule { - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// - .put(AMIClient.class, AMIAsyncClient.class)// - .put(ElasticIPAddressClient.class, ElasticIPAddressAsyncClient.class)// - .put(InstanceClient.class, InstanceAsyncClient.class)// - .put(NovaEC2KeyPairClient.class, NovaEC2KeyPairAsyncClient.class)// - .put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)// - .put(WindowsClient.class, WindowsAsyncClient.class)// - .put(AvailabilityZoneAndRegionClient.class, AvailabilityZoneAndRegionAsyncClient.class)// - .put(ElasticBlockStoreClient.class, ElasticBlockStoreAsyncClient.class)// - .put(WindowsApi.class, WindowsAsyncApi.class)// - .put(TagApi.class, TagAsyncApi.class)// - .put(SubnetApi.class, SubnetAsyncApi.class)// - .build(); - - public NovaEC2RestClientModule() { - super(typeToken(NovaEC2Client.class), typeToken(NovaEC2AsyncClient.class), DELEGATE_MAP); - } - - @Override - protected void configure() { - super.configure(); - bind(CreateVolumeResponseHandler.class).to(NovaCreateVolumeResponseHandler.class).in(Scopes.SINGLETON); - bind(DescribeImagesResponseHandler.class).to(NovaDescribeImagesResponseHandler.class); - } - - @Override - protected void installLocations() { - install(new LocationModule()); - bind(RegionIdToZoneIdsSupplier.class).to(DescribeAvailabilityZonesInRegion.class).in(Scopes.SINGLETON); - // there is only one region, and its endpoint is the same as the provider - bind(ZoneIdsSupplier.class).to(ZoneIdsFromRegionIdToZoneIdsValues.class).in(Scopes.SINGLETON); - } - - @Singleton - @Provides - EC2Client provide(NovaEC2Client in) { - return in; - } - - @Singleton - @Provides - EC2AsyncClient provide(NovaEC2AsyncClient in) { - return in; - } -} diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClient.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/features/NovaEC2KeyPairApi.java similarity index 63% rename from apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClient.java rename to apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/features/NovaEC2KeyPairApi.java index bb202961d3..b1a21c4997 100644 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClient.java +++ b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/features/NovaEC2KeyPairApi.java @@ -14,17 +14,35 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.nova.ec2.services; +package org.jclouds.openstack.nova.ec2.features; +import static org.jclouds.aws.reference.FormParameters.ACTION; + +import javax.inject.Named; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +import org.jclouds.aws.filters.FormSigner; import org.jclouds.ec2.domain.KeyPair; -import org.jclouds.ec2.services.KeyPairClient; +import org.jclouds.ec2.features.KeyPairApi; +import org.jclouds.ec2.functions.EncodedRSAPublicKeyToBase64; +import org.jclouds.ec2.xml.KeyPairResponseHandler; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.FormParams; +import org.jclouds.rest.annotations.ParamParser; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.VirtualHost; +import org.jclouds.rest.annotations.XMLResponseParser; /** - * * @author Adrian Cole */ -public interface NovaEC2KeyPairClient extends KeyPairClient { +@RequestFilters(FormSigner.class) +@VirtualHost +public interface NovaEC2KeyPairApi extends KeyPairApi { /** * Imports the public key from an RSA key pair that you created with a third-party tool. Compare @@ -58,6 +76,13 @@ public interface NovaEC2KeyPairClient extends KeyPairClient { * The public key * @return imported key including fingerprint */ - KeyPair importKeyPairInRegion(@Nullable String region, String keyName, String publicKeyMaterial); - + @Named("keypair:import") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "ImportKeyPair") + @XMLResponseParser(KeyPairResponseHandler.class) + KeyPair importKeyPairInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("KeyName") String keyName, + @FormParam("PublicKeyMaterial") @ParamParser(EncodedRSAPublicKeyToBase64.class) String publicKeyMaterial); } diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/loaders/NovaCreateSecurityGroupIfNeeded.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/loaders/NovaCreateSecurityGroupIfNeeded.java index b9c1e76d1d..77c9a2976e 100644 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/loaders/NovaCreateSecurityGroupIfNeeded.java +++ b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/loaders/NovaCreateSecurityGroupIfNeeded.java @@ -23,7 +23,7 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.aws.AWSResponseException; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.loaders.CreateSecurityGroupIfNeeded; @@ -37,9 +37,9 @@ import com.google.common.base.Predicate; public class NovaCreateSecurityGroupIfNeeded extends CreateSecurityGroupIfNeeded { @Inject - public NovaCreateSecurityGroupIfNeeded(EC2Client ec2Client, + public NovaCreateSecurityGroupIfNeeded(EC2Api ec2Client, @Named("SECURITY") Predicate securityGroupEventualConsistencyDelay) { - super(checkNotNull(ec2Client, "ec2Client").getSecurityGroupServices(), securityGroupEventualConsistencyDelay); + super(checkNotNull(ec2Client, "ec2Client").getSecurityGroupApi().get(), securityGroupEventualConsistencyDelay); } protected void authorizeGroupToItself(String region, String name) { diff --git a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairAsyncClient.java b/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairAsyncClient.java deleted file mode 100644 index d1fcd46950..0000000000 --- a/apis/openstack-nova-ec2/src/main/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairAsyncClient.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.openstack.nova.ec2.services; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.ec2.domain.KeyPair; -import org.jclouds.ec2.functions.EncodedRSAPublicKeyToBase64; -import org.jclouds.ec2.services.KeyPairAsyncClient; -import org.jclouds.ec2.xml.KeyPairResponseHandler; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.ParamParser; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface NovaEC2KeyPairAsyncClient extends KeyPairAsyncClient { - - /** - * @see NovaEC2KeyPairClient#importKeyPairInRegion(String, String, String) - */ - @Named("keypair:import") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "ImportKeyPair") - @XMLResponseParser(KeyPairResponseHandler.class) - ListenableFuture importKeyPairInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("KeyName") String keyName, - @FormParam("PublicKeyMaterial") @ParamParser(EncodedRSAPublicKeyToBase64.class) String publicKeyMaterial); -} diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2AMIClientExpectTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2AMIApiExpectTest.java similarity index 82% rename from apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2AMIClientExpectTest.java rename to apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2AMIApiExpectTest.java index 54e4404feb..492346aa38 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2AMIClientExpectTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2AMIApiExpectTest.java @@ -14,27 +14,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.nova.ec2.services; +package org.jclouds.openstack.nova.ec2.features; import static org.testng.Assert.assertEquals; import java.util.Set; import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.services.AMIClient; +import org.jclouds.ec2.features.AMIApi; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.openstack.nova.ec2.internal.BaseNovaEC2RestClientExpectTest; +import org.jclouds.openstack.nova.ec2.internal.BaseNovaEC2RestApiExpectTest; import org.testng.annotations.Test; /** * @author Adam Lowe */ -@Test(groups = "unit", testName = "NovaEC2ElasticBlockStoreClientTest") -public class NovaEC2AMIClientExpectTest extends BaseNovaEC2RestClientExpectTest { +@Test(groups = "unit", testName = "NovaEC2ElasticBlockStoreApiTest") +public class NovaEC2AMIApiExpectTest extends BaseNovaEC2RestApiExpectTest { public void testDescribeImagesWithNonMachineTypes() { - AMIClient client = requestsSendResponses( + AMIApi client = requestsSendResponses( describeAvailabilityZonesRequest, describeAvailabilityZonesResponse, HttpRequest.builder().method("POST") @@ -42,7 +42,7 @@ public class NovaEC2AMIClientExpectTest extends BaseNovaEC2RestClientExpectTest .addHeader("Host", "localhost:8773") .payload(payloadFromStringWithContentType("Action=DescribeImages&Signature=Z3q3jSutwlfgvbcINT0Ed3AjrjxM4WMvQloXu/1kd40%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2009-04-04&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/nova_ec2_images_with_ramdisk.xml")).build() - ).getAMIServices(); + ).getAMIApi().get(); Set images = client.describeImagesInRegion("nova"); diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2AMIClientLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2AMIApiLiveTest.java similarity index 81% rename from apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2AMIClientLiveTest.java rename to apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2AMIApiLiveTest.java index 4b15421d81..4110467c95 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2AMIClientLiveTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2AMIApiLiveTest.java @@ -14,18 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.nova.ec2.services; +package org.jclouds.openstack.nova.ec2.features; -import org.jclouds.ec2.services.AMIClientLiveTest; +import org.jclouds.ec2.features.AMIApiLiveTest; import org.testng.annotations.Test; /** * * @author Adrian Cole */ -@Test(groups = "live", singleThreaded = true, testName = "NovaEC2AMIClientLiveTest") -public class NovaEC2AMIClientLiveTest extends AMIClientLiveTest { - public NovaEC2AMIClientLiveTest() { +@Test(groups = "live", singleThreaded = true, testName = "NovaEC2AMIApiLiveTest") +public class NovaEC2AMIApiLiveTest extends AMIApiLiveTest { + public NovaEC2AMIApiLiveTest() { provider = "openstack-nova-ec2"; } diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticBlockStoreClientLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2AvailabilityZoneAndRegionApiLiveTest.java similarity index 75% rename from apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticBlockStoreClientLiveTest.java rename to apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2AvailabilityZoneAndRegionApiLiveTest.java index 6a8f27d5fe..be4ac8dc8c 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticBlockStoreClientLiveTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2AvailabilityZoneAndRegionApiLiveTest.java @@ -14,18 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.nova.ec2.services; +package org.jclouds.openstack.nova.ec2.features; -import org.jclouds.ec2.services.ElasticBlockStoreClientLiveTest; +import org.jclouds.ec2.features.AvailabilityZoneAndRegionApiLiveTest; import org.testng.annotations.Test; /** * * @author Adrian Cole */ -@Test(groups = "live", singleThreaded = true, testName = "NovaEC2ElasticBlockStoreClientLiveTest") -public class NovaEC2ElasticBlockStoreClientLiveTest extends ElasticBlockStoreClientLiveTest { - public NovaEC2ElasticBlockStoreClientLiveTest() { +@Test(groups = "live", singleThreaded = true, testName = "NovaEC2AvailabilityZoneAndRegionApiLiveTest") +public class NovaEC2AvailabilityZoneAndRegionApiLiveTest extends AvailabilityZoneAndRegionApiLiveTest { + public NovaEC2AvailabilityZoneAndRegionApiLiveTest() { provider = "openstack-nova-ec2"; } diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticIPAddressClientLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2ElasticBlockStoreApiLiveTest.java similarity index 77% rename from apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticIPAddressClientLiveTest.java rename to apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2ElasticBlockStoreApiLiveTest.java index fcf8c1b88d..7714579260 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticIPAddressClientLiveTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2ElasticBlockStoreApiLiveTest.java @@ -14,18 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.nova.ec2.services; +package org.jclouds.openstack.nova.ec2.features; -import org.jclouds.ec2.services.ElasticIPAddressClientLiveTest; +import org.jclouds.ec2.features.ElasticBlockStoreApiLiveTest; import org.testng.annotations.Test; /** * * @author Adrian Cole */ -@Test(groups = "live", singleThreaded = true, testName = "NovaEC2ElasticIPAddressClientLiveTest") -public class NovaEC2ElasticIPAddressClientLiveTest extends ElasticIPAddressClientLiveTest { - public NovaEC2ElasticIPAddressClientLiveTest() { +@Test(groups = "live", singleThreaded = true, testName = "NovaEC2ElasticBlockStoreApiLiveTest") +public class NovaEC2ElasticBlockStoreApiLiveTest extends ElasticBlockStoreApiLiveTest { + public NovaEC2ElasticBlockStoreApiLiveTest() { provider = "openstack-nova-ec2"; } diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticBlockStoreExpectClientTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2ElasticBlockStoreExpectApiTest.java similarity index 83% rename from apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticBlockStoreExpectClientTest.java rename to apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2ElasticBlockStoreExpectApiTest.java index e4a83a25d2..0c6151ed41 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2ElasticBlockStoreExpectClientTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2ElasticBlockStoreExpectApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.nova.ec2.services; +package org.jclouds.openstack.nova.ec2.features; import static org.testng.Assert.assertEquals; @@ -22,10 +22,10 @@ import java.util.Set; import org.jclouds.ec2.domain.Attachment; import org.jclouds.ec2.domain.Volume; -import org.jclouds.ec2.services.ElasticBlockStoreClient; +import org.jclouds.ec2.features.ElasticBlockStoreApi; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.openstack.nova.ec2.internal.BaseNovaEC2RestClientExpectTest; +import org.jclouds.openstack.nova.ec2.internal.BaseNovaEC2RestApiExpectTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -33,11 +33,11 @@ import com.google.common.collect.ImmutableSet; /** * @author Adam Lowe */ -@Test(groups = "unit", testName = "NovaEC2ElasticBlockStoreClientTest") -public class NovaEC2ElasticBlockStoreExpectClientTest extends BaseNovaEC2RestClientExpectTest { +@Test(groups = "unit", testName = "NovaEC2ElasticBlockStoreApiTest") +public class NovaEC2ElasticBlockStoreExpectApiTest extends BaseNovaEC2RestApiExpectTest { public void testDescribeVolumesWithNovaEC2Status() { - ElasticBlockStoreClient client = requestsSendResponses( + ElasticBlockStoreApi client = requestsSendResponses( describeAvailabilityZonesRequest, describeAvailabilityZonesResponse, HttpRequest.builder().method("POST") @@ -45,7 +45,7 @@ public class NovaEC2ElasticBlockStoreExpectClientTest extends BaseNovaEC2RestCli .addHeader("Host", "localhost:8773") .payload(payloadFromStringWithContentType("Action=DescribeVolumes&Signature=AvRznSzGExM%2Buaj2JJj66wq4v4f%2BakicyLooRDtC0t0%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2009-04-04&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/nova_ec2_describe_volumes.xml")).build() - ).getElasticBlockStoreServices(); + ).getElasticBlockStoreApi().get(); Set expected = ImmutableSet.of(Volume .builder() diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2SecurityGroupClientLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2ElasticIPAddressApiLiveTest.java similarity index 78% rename from apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2SecurityGroupClientLiveTest.java rename to apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2ElasticIPAddressApiLiveTest.java index 4c3dced64b..96aaa2555a 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2SecurityGroupClientLiveTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2ElasticIPAddressApiLiveTest.java @@ -14,18 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.nova.ec2.services; +package org.jclouds.openstack.nova.ec2.features; -import org.jclouds.ec2.services.SecurityGroupClientLiveTest; +import org.jclouds.ec2.features.ElasticIPAddressApiLiveTest; import org.testng.annotations.Test; /** * * @author Adrian Cole */ -@Test(groups = "live", singleThreaded = true, testName = "NovaEC2SecurityGroupClientLiveTest") -public class NovaEC2SecurityGroupClientLiveTest extends SecurityGroupClientLiveTest { - public NovaEC2SecurityGroupClientLiveTest() { +@Test(groups = "live", singleThreaded = true, testName = "NovaEC2ElasticIPAddressApiLiveTest") +public class NovaEC2ElasticIPAddressApiLiveTest extends ElasticIPAddressApiLiveTest { + public NovaEC2ElasticIPAddressApiLiveTest() { provider = "openstack-nova-ec2"; } diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2InstanceClientExpectTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2InstanceApiExpectTest.java similarity index 87% rename from apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2InstanceClientExpectTest.java rename to apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2InstanceApiExpectTest.java index 3c412f38c2..7f32f0a6e1 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2InstanceClientExpectTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2InstanceApiExpectTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.nova.ec2.services; +package org.jclouds.openstack.nova.ec2.features; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; @@ -25,20 +25,20 @@ import java.util.Set; import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.ec2.services.InstanceClient; +import org.jclouds.ec2.features.InstanceApi; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.openstack.nova.ec2.internal.BaseNovaEC2RestClientExpectTest; +import org.jclouds.openstack.nova.ec2.internal.BaseNovaEC2RestApiExpectTest; import com.google.common.collect.Iterables; /** * @author Adam Lowe */ -public class NovaEC2InstanceClientExpectTest extends BaseNovaEC2RestClientExpectTest { +public class NovaEC2InstanceApiExpectTest extends BaseNovaEC2RestApiExpectTest { public void testDescribeInstancesWithDashesInPlaceOfNullDates() { - InstanceClient client = requestsSendResponses( + InstanceApi client = requestsSendResponses( describeAvailabilityZonesRequest, describeAvailabilityZonesResponse, HttpRequest.builder().method("POST") @@ -46,7 +46,7 @@ public class NovaEC2InstanceClientExpectTest extends BaseNovaEC2RestClientExpect .addHeader("Host", "localhost:8773") .payload(payloadFromStringWithContentType("Action=DescribeInstances&Signature=kkCE1HzyntmkICEidOizw50B9yjLdNZvAWUXVse1c8o%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2009-04-04&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/nova_ec2_describe_instances.xml")).build() - ).getInstanceServices(); + ).getInstanceApi().get(); Set> response = client.describeInstancesInRegion("nova"); diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2InstanceClientLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2InstanceApiLiveTest.java similarity index 79% rename from apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2InstanceClientLiveTest.java rename to apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2InstanceApiLiveTest.java index 4244688a67..6a2b2362a4 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2InstanceClientLiveTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2InstanceApiLiveTest.java @@ -14,18 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.nova.ec2.services; +package org.jclouds.openstack.nova.ec2.features; -import org.jclouds.ec2.services.InstanceClientLiveTest; +import org.jclouds.ec2.features.InstanceApiLiveTest; import org.testng.annotations.Test; /** * * @author Adrian Cole */ -@Test(groups = "live", singleThreaded = true, testName = "NovaEC2InstanceClientLiveTest") -public class NovaEC2InstanceClientLiveTest extends InstanceClientLiveTest { - public NovaEC2InstanceClientLiveTest() { +@Test(groups = "live", singleThreaded = true, testName = "NovaEC2InstanceApiLiveTest") +public class NovaEC2InstanceApiLiveTest extends InstanceApiLiveTest { + public NovaEC2InstanceApiLiveTest() { provider = "openstack-nova-ec2"; } diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClientExpectTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2KeyPairApiExpectTest.java similarity index 88% rename from apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClientExpectTest.java rename to apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2KeyPairApiExpectTest.java index 9c3903d661..8bc493e232 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClientExpectTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2KeyPairApiExpectTest.java @@ -14,24 +14,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.nova.ec2.services; +package org.jclouds.openstack.nova.ec2.features; import static org.testng.Assert.assertEquals; import org.jclouds.ec2.domain.KeyPair; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.openstack.nova.ec2.internal.BaseNovaEC2RestClientExpectTest; +import org.jclouds.openstack.nova.ec2.internal.BaseNovaEC2RestApiExpectTest; import org.jclouds.rest.ResourceNotFoundException; import org.testng.annotations.Test; /** * @author Adam Lowe */ -public class NovaEC2KeyPairClientExpectTest extends BaseNovaEC2RestClientExpectTest { +public class NovaEC2KeyPairApiExpectTest extends BaseNovaEC2RestApiExpectTest { public void testImportKeyPair() { - NovaEC2KeyPairClient client = requestsSendResponses( + NovaEC2KeyPairApi client = requestsSendResponses( describeAvailabilityZonesRequest, describeAvailabilityZonesResponse, HttpRequest.builder().method("POST") @@ -39,7 +39,7 @@ public class NovaEC2KeyPairClientExpectTest extends BaseNovaEC2RestClientExpectT .addHeader("Host", "localhost:8773") .payload(payloadFromStringWithContentType("Action=ImportKeyPair&KeyName=mykey&PublicKeyMaterial=c3NoLXJzYSBBQQ%3D%3D&Signature=wOOKOlDfJezRkx7NKcyOyaBQuY7PoVE3HFa9495RL7s%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2009-04-04&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/nova_ec2_import_keypair_response.xml")).build() - ).getKeyPairServices(); + ).getKeyPairApi().get(); KeyPair result = client.importKeyPairInRegion(null, "mykey", "ssh-rsa AA"); assertEquals(result.getKeyName(), "aplowe-nova-ec22"); @@ -48,7 +48,7 @@ public class NovaEC2KeyPairClientExpectTest extends BaseNovaEC2RestClientExpectT @Test(expectedExceptions = ResourceNotFoundException.class) public void testImportKeyPairFailsNotFound() { - NovaEC2KeyPairClient client = requestsSendResponses( + NovaEC2KeyPairApi client = requestsSendResponses( describeAvailabilityZonesRequest, describeAvailabilityZonesResponse, HttpRequest.builder().method("POST") @@ -56,14 +56,14 @@ public class NovaEC2KeyPairClientExpectTest extends BaseNovaEC2RestClientExpectT .addHeader("Host", "localhost:8773") .payload(payloadFromStringWithContentType("Action=ImportKeyPair&KeyName=mykey&PublicKeyMaterial=c3NoLXJzYSBBQQ%3D%3D&Signature=wOOKOlDfJezRkx7NKcyOyaBQuY7PoVE3HFa9495RL7s%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2009-04-04&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(), HttpResponse.builder().statusCode(404).build() - ).getKeyPairServices(); + ).getKeyPairApi().get(); client.importKeyPairInRegion(null, "mykey", "ssh-rsa AA"); } @Test(expectedExceptions = IllegalStateException.class) public void testImportKeyPairFailsAlreadyExists() { - NovaEC2KeyPairClient client = requestsSendResponses( + NovaEC2KeyPairApi client = requestsSendResponses( describeAvailabilityZonesRequest, describeAvailabilityZonesResponse, HttpRequest.builder().method("POST") @@ -71,7 +71,7 @@ public class NovaEC2KeyPairClientExpectTest extends BaseNovaEC2RestClientExpectT .addHeader("Host", "localhost:8773") .payload(payloadFromStringWithContentType("Action=ImportKeyPair&KeyName=mykey&PublicKeyMaterial=c3NoLXJzYSBBQQ%3D%3D&Signature=wOOKOlDfJezRkx7NKcyOyaBQuY7PoVE3HFa9495RL7s%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-04-16T15%3A54%3A08.897Z&Version=2009-04-04&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(), HttpResponse.builder().statusCode(409).build() - ).getKeyPairServices(); + ).getKeyPairApi().get(); client.importKeyPairInRegion(null, "mykey", "ssh-rsa AA"); } diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClientLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2KeyPairApiLiveTest.java similarity index 89% rename from apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClientLiveTest.java rename to apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2KeyPairApiLiveTest.java index 85aa0c5e99..7b02d12614 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2KeyPairClientLiveTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2KeyPairApiLiveTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.openstack.nova.ec2.services; +package org.jclouds.openstack.nova.ec2.features; import static com.google.common.collect.Sets.newTreeSet; import static org.testng.Assert.assertEquals; @@ -29,34 +29,35 @@ import java.util.SortedSet; import org.jclouds.compute.ComputeTestUtils; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.ec2.domain.KeyPair; +import org.jclouds.openstack.nova.ec2.NovaEC2Api; import org.jclouds.openstack.nova.ec2.NovaEC2ApiMetadata; import org.jclouds.ssh.SshKeys; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** - * Tests behavior of {@code NovaKeyPairClient} + * Tests behavior of {@code NovaKeyPairApi} * * @author Adam Lowe */ @Test(groups = "live", singleThreaded = true) -public class NovaEC2KeyPairClientLiveTest extends BaseComputeServiceContextLiveTest { +public class NovaEC2KeyPairApiLiveTest extends BaseComputeServiceContextLiveTest { public static final String PREFIX = System.getProperty("user.name") + "-nova-ec2"; - public NovaEC2KeyPairClientLiveTest() { + public NovaEC2KeyPairApiLiveTest() { provider = "openstack-nova-ec2"; } - private NovaEC2KeyPairClient client; + private NovaEC2KeyPairApi client; private Set regions; @Override @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = view.unwrap(NovaEC2ApiMetadata.CONTEXT_TOKEN).getApi().getKeyPairServices(); - regions = view.unwrap(NovaEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet(); + client = view.unwrapApi(NovaEC2Api.class).getKeyPairApi().get(); + regions = view.unwrapApi(NovaEC2Api.class).getAvailabilityZoneAndRegionApi().get().describeRegions().keySet(); } @Test diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2SecurityGroupApiLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2SecurityGroupApiLiveTest.java new file mode 100644 index 0000000000..11b30a82a3 --- /dev/null +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/features/NovaEC2SecurityGroupApiLiveTest.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.openstack.nova.ec2.features; + +import org.jclouds.ec2.features.SecurityGroupApiLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", singleThreaded = true, testName = "NovaEC2SecurityGroupApiLiveTest") +public class NovaEC2SecurityGroupApiLiveTest extends SecurityGroupApiLiveTest { + public NovaEC2SecurityGroupApiLiveTest() { + provider = "openstack-nova-ec2"; + } + +} diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/internal/BaseNovaEC2RestClientExpectTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/internal/BaseNovaEC2RestApiExpectTest.java similarity index 81% rename from apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/internal/BaseNovaEC2RestClientExpectTest.java rename to apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/internal/BaseNovaEC2RestApiExpectTest.java index c57e3830cc..462bd536bf 100644 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/internal/BaseNovaEC2RestClientExpectTest.java +++ b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/internal/BaseNovaEC2RestApiExpectTest.java @@ -24,15 +24,15 @@ import org.jclouds.date.DateService; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.openstack.nova.ec2.NovaEC2Client; -import org.jclouds.openstack.nova.ec2.config.NovaEC2RestClientModule; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.internal.BaseRestClientExpectTest; +import org.jclouds.openstack.nova.ec2.NovaEC2Api; +import org.jclouds.openstack.nova.ec2.config.NovaEC2HttpApiModule; +import org.jclouds.rest.ConfiguresHttpApi; +import org.jclouds.rest.internal.BaseRestApiExpectTest; import com.google.inject.Module; import com.google.inject.Provides; -public abstract class BaseNovaEC2RestClientExpectTest extends BaseRestClientExpectTest { +public abstract class BaseNovaEC2RestApiExpectTest extends BaseRestApiExpectTest { protected static final String CONSTANT_DATE = "2012-04-16T15:54:08.897Z"; protected DateService dateService = new SimpleDateFormatDateService(); @@ -50,12 +50,13 @@ public abstract class BaseNovaEC2RestClientExpectTest extends BaseRestClientExpe .payload(payloadFromResourceWithContentType("/nova_ec2_availabilityZones.xml", MediaType.APPLICATION_XML)) .build(); - public BaseNovaEC2RestClientExpectTest() { + public BaseNovaEC2RestApiExpectTest() { provider = "openstack-nova-ec2"; } - @ConfiguresRestClient - private static final class TestNovaEC2RestClientModule extends NovaEC2RestClientModule { + @ConfiguresHttpApi + private static final class TestNovaEC2HttpApiModule extends NovaEC2HttpApiModule { + @Override @Provides protected String provideTimeStamp(DateService dateService) { @@ -65,6 +66,6 @@ public abstract class BaseNovaEC2RestClientExpectTest extends BaseRestClientExpe @Override protected Module createModule() { - return new TestNovaEC2RestClientModule(); + return new TestNovaEC2HttpApiModule(); } } diff --git a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2AvailabilityZoneAndRegionClientLiveTest.java b/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2AvailabilityZoneAndRegionClientLiveTest.java deleted file mode 100644 index bff82485aa..0000000000 --- a/apis/openstack-nova-ec2/src/test/java/org/jclouds/openstack/nova/ec2/services/NovaEC2AvailabilityZoneAndRegionClientLiveTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.openstack.nova.ec2.services; - -import org.jclouds.ec2.services.AvailabilityZoneAndRegionClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true, testName = "NovaEC2AvailabilityZoneAndRegionClientLiveTest") -public class NovaEC2AvailabilityZoneAndRegionClientLiveTest extends AvailabilityZoneAndRegionClientLiveTest { - public NovaEC2AvailabilityZoneAndRegionClientLiveTest() { - provider = "openstack-nova-ec2"; - } - -} diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java new file mode 100644 index 0000000000..ad6e536289 --- /dev/null +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.ec2; + +import org.jclouds.aws.ec2.features.AWSAMIApi; +import org.jclouds.aws.ec2.features.AWSInstanceApi; +import org.jclouds.aws.ec2.features.AWSKeyPairApi; +import org.jclouds.aws.ec2.features.AWSSecurityGroupApi; +import org.jclouds.aws.ec2.features.MonitoringApi; +import org.jclouds.aws.ec2.features.PlacementGroupApi; +import org.jclouds.aws.ec2.features.SpotInstanceApi; +import org.jclouds.ec2.EC2Api; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.location.Region; +import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; +import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; + +import com.google.common.base.Optional; + +/** + * Provides synchronous access to EC2 services. + * + * @author Adrian Cole + */ +public interface AWSEC2Api extends EC2Api { + + /** + * {@inheritDoc} + */ + @Delegate + @Override + Optional getInstanceApi(); + + @Delegate + @Override + Optional getInstanceApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * {@inheritDoc} + */ + @Delegate + @Override + Optional getSecurityGroupApi(); + + @Delegate + @Override + Optional getSecurityGroupApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * {@inheritDoc} + */ + @Delegate + @Override + Optional getAMIApi(); + + @Delegate + @Override + Optional getAMIApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + + /** + * Provides synchronous access to PlacementGroup services. + */ + @Delegate + Optional getPlacementGroupApi(); + + @Delegate + Optional getPlacementGroupApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * Provides synchronous access to Monitoring services. + */ + @Delegate + Optional getMonitoringApi(); + + @Delegate + Optional getMonitoringApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * {@inheritDoc} + */ + @Delegate + @Override + Optional getKeyPairApi(); + + @Delegate + @Override + Optional getKeyPairApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); + + /** + * Provides synchronous access to SpotInstance services. + */ + @Delegate + Optional getSpotInstanceApi(); + + @Delegate + Optional getSpotInstanceApiForRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region); +} diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java index 4427fdd6e4..1724331ec9 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java @@ -23,7 +23,7 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.aws.ec2.compute.config.AWSEC2ComputeServiceContextModule; -import org.jclouds.aws.ec2.config.AWSEC2RestClientModule; +import org.jclouds.aws.ec2.config.AWSEC2HttpApiModule; import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.compute.config.EC2ResolveImagesModule; @@ -38,15 +38,6 @@ import com.google.inject.Module; */ public class AWSEC2ApiMetadata extends EC2ApiMetadata { - /** - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(AWSEC2Client.class)} as - * {@link AWSEC2AsyncClient} interface will be removed in jclouds 1.7. - */ - @Deprecated - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - @Override public Builder toBuilder() { return new Builder().fromApiMetadata(this); @@ -73,14 +64,12 @@ public class AWSEC2ApiMetadata extends EC2ApiMetadata { public static class Builder extends EC2ApiMetadata.Builder { @SuppressWarnings("deprecation") protected Builder(){ - super(AWSEC2Client.class, AWSEC2AsyncClient.class); id("aws-ec2") .version("2012-06-01") .name("Amazon-specific EC2 API") .view(AWSEC2ComputeServiceContext.class) - .context(CONTEXT_TOKEN) .defaultProperties(AWSEC2ApiMetadata.defaultProperties()) - .defaultModules(ImmutableSet.>of(AWSEC2RestClientModule.class, EC2ResolveImagesModule.class, AWSEC2ComputeServiceContextModule.class)); + .defaultModules(ImmutableSet.>of(AWSEC2HttpApiModule.class, EC2ResolveImagesModule.class, AWSEC2ComputeServiceContextModule.class)); } @Override diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2AsyncClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2AsyncClient.java deleted file mode 100644 index 2d638b0701..0000000000 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2AsyncClient.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2; - -import org.jclouds.aws.ec2.services.AWSAMIAsyncClient; -import org.jclouds.aws.ec2.services.AWSInstanceAsyncClient; -import org.jclouds.aws.ec2.services.AWSKeyPairAsyncClient; -import org.jclouds.aws.ec2.services.AWSSecurityGroupAsyncClient; -import org.jclouds.aws.ec2.services.MonitoringAsyncClient; -import org.jclouds.aws.ec2.services.PlacementGroupAsyncClient; -import org.jclouds.aws.ec2.services.SpotInstanceAsyncClient; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.rest.annotations.Delegate; - -/** - * Provides asynchronous access to EC2 services. - * - * @author Adrian Cole - * - * @deprecated please use - * {@code org.jclouds.ContextBuilder#buildApi(AWSEC2Client.class)} - * as {@link AWSEC2AsyncClient} interface will be removed in jclouds 1.7. - */ -@Deprecated -public interface AWSEC2AsyncClient extends EC2AsyncClient { - - /** - * {@inheritDoc} - */ - @Delegate - @Override - AWSInstanceAsyncClient getInstanceServices(); - - /** - * {@inheritDoc} - */ - @Delegate - @Override - AWSAMIAsyncClient getAMIServices(); - - /** - * {@inheritDoc} - */ - @Delegate - @Override - AWSSecurityGroupAsyncClient getSecurityGroupServices(); - - /** - * Provides asynchronous access to PlacementGroup services. - */ - @Delegate - PlacementGroupAsyncClient getPlacementGroupServices(); - - /** - * Provides asynchronous access to Monitoring services. - */ - @Delegate - MonitoringAsyncClient getMonitoringServices(); - - /** - * {@inheritDoc} - */ - @Delegate - @Override - AWSKeyPairAsyncClient getKeyPairServices(); - - /** - * Provides asynchronous access to SpotInstance services. - */ - @Delegate - SpotInstanceAsyncClient getSpotInstanceServices(); -} diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Client.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Client.java deleted file mode 100644 index a605e3c912..0000000000 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2Client.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2; - -import org.jclouds.aws.ec2.services.AWSAMIClient; -import org.jclouds.aws.ec2.services.AWSInstanceClient; -import org.jclouds.aws.ec2.services.AWSKeyPairClient; -import org.jclouds.aws.ec2.services.AWSSecurityGroupClient; -import org.jclouds.aws.ec2.services.MonitoringClient; -import org.jclouds.aws.ec2.services.PlacementGroupClient; -import org.jclouds.aws.ec2.services.SpotInstanceClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.rest.annotations.Delegate; - -/** - * Provides synchronous access to EC2 services. - * - * @author Adrian Cole - */ -public interface AWSEC2Client extends EC2Client { - - /** - * {@inheritDoc} - */ - @Delegate - @Override - AWSInstanceClient getInstanceServices(); - - /** - * {@inheritDoc} - */ - @Delegate - @Override - AWSSecurityGroupClient getSecurityGroupServices(); - - /** - * {@inheritDoc} - */ - @Delegate - @Override - AWSAMIClient getAMIServices(); - - /** - * Provides synchronous access to PlacementGroup services. - */ - @Delegate - PlacementGroupClient getPlacementGroupServices(); - - /** - * Provides synchronous access to Monitoring services. - */ - @Delegate - MonitoringClient getMonitoringServices(); - - /** - * {@inheritDoc} - */ - @Delegate - @Override - AWSKeyPairClient getKeyPairServices(); - - /** - * Provides synchronous access to SpotInstance services. - */ - @Delegate - SpotInstanceClient getSpotInstanceServices(); -} diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java index 8bcc4d58e0..f512074ce6 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java @@ -35,7 +35,7 @@ import javax.inject.Provider; import javax.inject.Singleton; import org.jclouds.Constants; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.domain.PlacementGroup; import org.jclouds.aws.ec2.domain.PlacementGroup.State; import org.jclouds.collect.Memoized; @@ -82,7 +82,7 @@ public class AWSEC2ComputeService extends EC2ComputeService { private final LoadingCache placementGroupMap; private final Predicate placementGroupDeleted; - private final AWSEC2Client client; + private final AWSEC2Api client; @Inject protected AWSEC2ComputeService(ComputeServiceContext context, Map credentialStore, @@ -99,7 +99,7 @@ public class AWSEC2ComputeService extends EC2ComputeService { InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory, RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess, PersistNodeCredentials persistNodeCredentials, Timeouts timeouts, - @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, AWSEC2Client client, + @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, AWSEC2Api client, ConcurrentMap credentialsMap, @Named("SECURITY") LoadingCache securityGroupMap, @Named("PLACEMENT") LoadingCache placementGroupMap, @@ -125,10 +125,10 @@ public class AWSEC2ComputeService extends EC2ComputeService { // http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?using_cluster_computing.html String placementGroup = String.format("jclouds#%s#%s", group, region); try { - if (client.getPlacementGroupServices().describePlacementGroupsInRegion(region, placementGroup).size() > 0) { + if (client.getPlacementGroupApi().get().describePlacementGroupsInRegion(region, placementGroup).size() > 0) { logger.debug(">> deleting placementGroup(%s)", placementGroup); try { - client.getPlacementGroupServices().deletePlacementGroupInRegion(region, placementGroup); + client.getPlacementGroupApi().get().deletePlacementGroupInRegion(region, placementGroup); checkState(placementGroupDeleted.apply(new PlacementGroup(region, placementGroup, "cluster", State.PENDING)), String.format("placementGroup region(%s) name(%s) failed to delete", region, placementGroup)); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java index c0e21f0da4..ef1257671f 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java @@ -35,7 +35,7 @@ import javax.inject.Named; import javax.inject.Provider; import org.jclouds.Constants; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.util.AWSUtils; import org.jclouds.collect.Memoized; import org.jclouds.compute.domain.SecurityGroup; @@ -72,10 +72,10 @@ import com.google.common.util.concurrent.UncheckedTimeoutException; * @author Andrew Bayer */ public class AWSEC2SecurityGroupExtension extends EC2SecurityGroupExtension { - protected final AWSEC2Client client; + protected final AWSEC2Api client; @Inject - public AWSEC2SecurityGroupExtension(AWSEC2Client client, + public AWSEC2SecurityGroupExtension(AWSEC2Api client, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, @Region Supplier> regions, Function groupConverter, @@ -93,7 +93,7 @@ public class AWSEC2SecurityGroupExtension extends EC2SecurityGroupExtension { String region = AWSUtils.getRegionFromLocationOrNull(group.getLocation()); String name = group.getName(); - client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(region, name, ipPermission); + client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(region, name, ipPermission); return getSecurityGroupById(new RegionAndName(region, group.getName()).slashEncode()); } @@ -126,7 +126,7 @@ public class AWSEC2SecurityGroupExtension extends EC2SecurityGroupExtension { } } - client.getSecurityGroupServices().authorizeSecurityGroupIngressInRegion(region, name, builder.build()); + client.getSecurityGroupApi().get().authorizeSecurityGroupIngressInRegion(region, name, builder.build()); return getSecurityGroupById(new RegionAndName(region, group.getName()).slashEncode()); } @@ -136,7 +136,7 @@ public class AWSEC2SecurityGroupExtension extends EC2SecurityGroupExtension { String region = AWSUtils.getRegionFromLocationOrNull(group.getLocation()); String name = group.getName(); - client.getSecurityGroupServices().revokeSecurityGroupIngressInRegion(region, name, ipPermission); + client.getSecurityGroupApi().get().revokeSecurityGroupIngressInRegion(region, name, ipPermission); return getSecurityGroupById(new RegionAndName(region, group.getName()).slashEncode()); } @@ -170,7 +170,7 @@ public class AWSEC2SecurityGroupExtension extends EC2SecurityGroupExtension { } } - client.getSecurityGroupServices().revokeSecurityGroupIngressInRegion(region, name, builder.build()); + client.getSecurityGroupApi().get().revokeSecurityGroupIngressInRegion(region, name, builder.build()); return getSecurityGroupById(new RegionAndName(region, group.getName()).slashEncode()); } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java index ee04c14eec..24b3a8a7bb 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java @@ -33,7 +33,7 @@ import java.util.Set; import javax.inject.Singleton; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.SpotInstanceRequest; import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance; @@ -56,11 +56,11 @@ import com.google.inject.Inject; @Singleton public class PresentSpotRequestsAndInstances extends PresentInstances { - private final AWSEC2Client client; + private final AWSEC2Api client; private final Function spotConverter; @Inject - public PresentSpotRequestsAndInstances(AWSEC2Client client, Function spotConverter) { + public PresentSpotRequestsAndInstances(AWSEC2Api client, Function spotConverter) { super(client); this.client = checkNotNull(client, "client"); this.spotConverter = checkNotNull(spotConverter, "spotConverter"); @@ -83,7 +83,7 @@ public class PresentSpotRequestsAndInstances extends PresentInstances { Collection spotIds = entry.getValue(); logger.trace("looking for spots %s in region %s", spotIds, region); builder.addAll(transform( - client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion(region, + client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(region, toArray(spotIds, String.class)), spotConverter)); } return builder.build(); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java index 6676ef676a..c794fdbfc9 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java @@ -27,8 +27,8 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.services.AWSSecurityGroupClient; +import org.jclouds.aws.ec2.AWSEC2Api; +import org.jclouds.aws.ec2.features.AWSSecurityGroupApi; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules; @@ -52,18 +52,18 @@ public class AWSEC2CreateSecurityGroupIfNeeded extends CacheLoader securityGroupEventualConsistencyDelay; @Inject - public AWSEC2CreateSecurityGroupIfNeeded(AWSEC2Client ec2Client, + public AWSEC2CreateSecurityGroupIfNeeded(AWSEC2Api ec2Api, @Named("SECURITY") Predicate securityGroupEventualConsistencyDelay) { - this(checkNotNull(ec2Client, "ec2Client").getSecurityGroupServices(), securityGroupEventualConsistencyDelay); + this(checkNotNull(ec2Api, "ec2Api").getSecurityGroupApi().get(), securityGroupEventualConsistencyDelay); } - public AWSEC2CreateSecurityGroupIfNeeded(AWSSecurityGroupClient securityClient, + public AWSEC2CreateSecurityGroupIfNeeded(AWSSecurityGroupApi securityApi, @Named("SECURITY") Predicate securityGroupEventualConsistencyDelay) { - this.securityClient = checkNotNull(securityClient, "securityClient"); + this.securityApi = checkNotNull(securityApi, "securityApi"); this.securityGroupEventualConsistencyDelay = checkNotNull(securityGroupEventualConsistencyDelay, "securityGroupEventualConsistencyDelay"); } @@ -80,7 +80,7 @@ public class AWSEC2CreateSecurityGroupIfNeeded extends CacheLoader> creating securityGroup region(%s) name(%s)", region, name); try { - securityClient.createSecurityGroupInRegion(region, name, name); + securityApi.createSecurityGroupInRegion(region, name, name); boolean created = securityGroupEventualConsistencyDelay.apply(new RegionAndName(region, name)); if (!created) throw new RuntimeException(String.format("security group %s/%s is not available after creating", region, @@ -99,7 +99,7 @@ public class AWSEC2CreateSecurityGroupIfNeeded extends CacheLoader 0) { logger.debug(">> authorizing securityGroup region(%s) name(%s) IpPermissions(%s)", region, name, perms); - securityClient.authorizeSecurityGroupIngressInRegion(region, name, perms); + securityApi.authorizeSecurityGroupIngressInRegion(region, name, perms); logger.debug("<< authorized securityGroup(%s)", name); } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java index b9c205fcc6..5faaba6db2 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java @@ -29,7 +29,7 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions; import org.jclouds.aws.ec2.compute.functions.PresentSpotRequestsAndInstances; import org.jclouds.aws.ec2.domain.LaunchSpecification; @@ -68,12 +68,12 @@ public class AWSEC2CreateNodesInGroupThenAddToSet extends EC2CreateNodesInGroupT private Logger logger = Logger.NULL; @VisibleForTesting - private final AWSEC2Client client; + private final AWSEC2Api client; private final SpotInstanceRequestToAWSRunningInstance spotConverter; @Inject protected AWSEC2CreateNodesInGroupThenAddToSet( - AWSEC2Client client, + AWSEC2Api client, @Named("ELASTICIP") LoadingCache elasticIpCache, @Named(TIMEOUT_NODE_RUNNING) Predicate> nodeRunning, @Named(PROPERTY_EC2_GENERATE_INSTANCE_NAMES) boolean generateInstanceNames, @@ -103,7 +103,7 @@ public class AWSEC2CreateNodesInGroupThenAddToSet extends EC2CreateNodesInGroupT if (logger.isDebugEnabled()) logger.debug(">> requesting %d spot instances region(%s) price(%f) spec(%s) options(%s)", count, region, spotPrice, spec, options); - return ImmutableSet. copyOf(transform(client.getSpotInstanceServices() + return ImmutableSet. copyOf(transform(client.getSpotInstanceApi().get() .requestSpotInstancesInRegion(region, spotPrice, count, spec, options), spotConverter)); } return super.createNodesInRegionAndZone(region, zone, group, count, template, instanceOptions); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java index 84efca0ecf..ee7b03bac3 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java @@ -26,7 +26,7 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.compute.strategy.GetNodeMetadataStrategy; import org.jclouds.domain.Credentials; import org.jclouds.ec2.compute.domain.RegionAndName; @@ -42,11 +42,11 @@ import com.google.common.collect.Iterables; @Singleton public class AWSEC2DestroyNodeStrategy extends EC2DestroyNodeStrategy { - protected final AWSEC2Client client; + protected final AWSEC2Api client; protected final Map credentialStore; @Inject - protected AWSEC2DestroyNodeStrategy(AWSEC2Client client, GetNodeMetadataStrategy getNode, + protected AWSEC2DestroyNodeStrategy(AWSEC2Api client, GetNodeMetadataStrategy getNode, @Named("ELASTICIP") LoadingCache elasticIpCache, Map credentialStore) { super(client, getNode, elasticIpCache); @@ -60,14 +60,14 @@ public class AWSEC2DestroyNodeStrategy extends EC2DestroyNodeStrategy { if (id.indexOf("sir-") != 0) { try { spotId = getOnlyElement( - Iterables.concat(client.getInstanceServices().describeInstancesInRegion(region, id))) + Iterables.concat(client.getInstanceApi().get().describeInstancesInRegion(region, id))) .getSpotInstanceRequestId(); credentialStore.remove("node#" + region + "/" + spotId); } catch (NoSuchElementException e) { } super.destroyInstanceInRegion(id, region); } else { - client.getSpotInstanceServices().cancelSpotInstanceRequestsInRegion(region, spotId); + client.getSpotInstanceApi().get().cancelSpotInstanceRequestsInRegion(region, spotId); credentialStore.remove("node#" + region + "/" + id); } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java index b44257642e..ffc2e0b218 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java @@ -22,7 +22,7 @@ import static com.google.common.collect.Iterables.getOnlyElement; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.domain.SpotInstanceRequest; import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance; import org.jclouds.compute.domain.NodeMetadata; @@ -38,11 +38,11 @@ import com.google.common.base.Function; @Singleton public class AWSEC2GetNodeMetadataStrategy extends EC2GetNodeMetadataStrategy { - private final AWSEC2Client client; + private final AWSEC2Api client; private final SpotInstanceRequestToAWSRunningInstance spotConverter; @Inject - protected AWSEC2GetNodeMetadataStrategy(AWSEC2Client client, + protected AWSEC2GetNodeMetadataStrategy(AWSEC2Api client, Function runningInstanceToNodeMetadata, SpotInstanceRequestToAWSRunningInstance spotConverter) { super(client, runningInstanceToNodeMetadata); @@ -54,7 +54,7 @@ public class AWSEC2GetNodeMetadataStrategy extends EC2GetNodeMetadataStrategy { public RunningInstance getRunningInstanceInRegion(String region, String id) { if (id.indexOf("sir-") != 0) return super.getRunningInstanceInRegion(region, id); - SpotInstanceRequest spot = getOnlyElement(client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion( + SpotInstanceRequest spot = getOnlyElement(client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion( region, id)); if (spot.getState() == SpotInstanceRequest.State.ACTIVE) return super.getRunningInstanceInRegion(region, spot.getInstanceId()); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java index 35d193ee8f..0d3b03423c 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java @@ -31,7 +31,7 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.Constants; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.SpotInstanceRequest; import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance; @@ -55,11 +55,11 @@ import com.google.inject.Inject; @Singleton public class AWSEC2ListNodesStrategy extends EC2ListNodesStrategy { - protected final AWSEC2Client client; + protected final AWSEC2Api client; protected final SpotInstanceRequestToAWSRunningInstance spotConverter; @Inject - protected AWSEC2ListNodesStrategy(AWSEC2Client client, @Region Supplier> regions, + protected AWSEC2ListNodesStrategy(AWSEC2Api client, @Region Supplier> regions, Function runningInstanceToNodeMetadata, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, SpotInstanceRequestToAWSRunningInstance spotConverter) { @@ -92,7 +92,7 @@ public class AWSEC2ListNodesStrategy extends EC2ListNodesStrategy { @Override public Set apply(String from) { - return client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion(from); + return client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(from); } }; } @@ -102,7 +102,7 @@ public class AWSEC2ListNodesStrategy extends EC2ListNodesStrategy { @Override public Set apply(String from) { - return client.getSpotInstanceServices() + return client.getSpotInstanceApi().get() .describeSpotInstanceRequestsInRegion(from, toArray(idsByRegions.get(from), String.class)); } }; diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java new file mode 100644 index 0000000000..db1f8d2e18 --- /dev/null +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF 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.ec2.config; +import static org.jclouds.reflect.Reflection2.typeToken; + +import java.util.Map; + +import javax.inject.Singleton; + +import org.jclouds.aws.ec2.AWSEC2Api; +import org.jclouds.aws.ec2.domain.AWSRunningInstance; +import org.jclouds.aws.ec2.domain.SpotInstanceRequest; +import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance; +import org.jclouds.aws.ec2.options.AWSRunInstancesOptions; +import org.jclouds.aws.ec2.features.AWSAMIApi; +import org.jclouds.aws.ec2.features.AWSInstanceApi; +import org.jclouds.aws.ec2.features.AWSKeyPairApi; +import org.jclouds.aws.ec2.features.AWSSecurityGroupApi; +import org.jclouds.aws.ec2.features.MonitoringApi; +import org.jclouds.aws.ec2.features.PlacementGroupApi; +import org.jclouds.aws.ec2.features.SpotInstanceApi; +import org.jclouds.ec2.EC2Api; +import org.jclouds.ec2.config.BaseEC2HttpApiModule; +import org.jclouds.ec2.features.SubnetApi; +import org.jclouds.ec2.features.TagApi; +import org.jclouds.ec2.features.WindowsApi; +import org.jclouds.ec2.options.RunInstancesOptions; +import org.jclouds.ec2.features.AMIApi; +import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi; +import org.jclouds.ec2.features.ElasticBlockStoreApi; +import org.jclouds.ec2.features.ElasticIPAddressApi; +import org.jclouds.ec2.features.InstanceApi; +import org.jclouds.ec2.features.SecurityGroupApi; +import org.jclouds.rest.ConfiguresHttpApi; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableMap; +import com.google.inject.Provides; +import com.google.inject.TypeLiteral; + +/** + * Configures the EC2 connection. + * + * @author Adrian Cole + */ +@ConfiguresHttpApi +public class AWSEC2HttpApiModule extends BaseEC2HttpApiModule { + + public AWSEC2HttpApiModule() { + super(AWSEC2Api.class); + } + + @Singleton + @Provides + EC2Api provide(AWSEC2Api in) { + return in; + } + + @Singleton + @Provides + InstanceApi getInstanceApi(AWSEC2Api in) { + return in.getInstanceApi().get(); + } + + @Singleton + @Provides + SecurityGroupApi getSecurityGroupApi(AWSEC2Api in) { + return in.getSecurityGroupApi().get(); + } + + @Singleton + @Provides + AMIApi getAMIApi(AWSEC2Api in) { + return in.getAMIApi().get(); + } + + @Override + protected void configure() { + bind(RunInstancesOptions.class).to(AWSRunInstancesOptions.class); + bind(new TypeLiteral>() { + }).to(SpotInstanceRequestToAWSRunningInstance.class); + super.configure(); + } +} diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java deleted file mode 100644 index 0ebba84537..0000000000 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/config/AWSEC2RestClientModule.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.config; -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.util.Map; - -import javax.inject.Singleton; - -import org.jclouds.aws.ec2.AWSEC2AsyncClient; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.domain.AWSRunningInstance; -import org.jclouds.aws.ec2.domain.SpotInstanceRequest; -import org.jclouds.aws.ec2.functions.SpotInstanceRequestToAWSRunningInstance; -import org.jclouds.aws.ec2.options.AWSRunInstancesOptions; -import org.jclouds.aws.ec2.services.AWSAMIAsyncClient; -import org.jclouds.aws.ec2.services.AWSAMIClient; -import org.jclouds.aws.ec2.services.AWSInstanceAsyncClient; -import org.jclouds.aws.ec2.services.AWSInstanceClient; -import org.jclouds.aws.ec2.services.AWSKeyPairAsyncClient; -import org.jclouds.aws.ec2.services.AWSKeyPairClient; -import org.jclouds.aws.ec2.services.AWSSecurityGroupAsyncClient; -import org.jclouds.aws.ec2.services.AWSSecurityGroupClient; -import org.jclouds.aws.ec2.services.MonitoringAsyncClient; -import org.jclouds.aws.ec2.services.MonitoringClient; -import org.jclouds.aws.ec2.services.PlacementGroupAsyncClient; -import org.jclouds.aws.ec2.services.PlacementGroupClient; -import org.jclouds.aws.ec2.services.SpotInstanceAsyncClient; -import org.jclouds.aws.ec2.services.SpotInstanceClient; -import org.jclouds.ec2.EC2AsyncClient; -import org.jclouds.ec2.EC2Client; -import org.jclouds.ec2.config.EC2RestClientModule; -import org.jclouds.ec2.features.SubnetApi; -import org.jclouds.ec2.features.SubnetAsyncApi; -import org.jclouds.ec2.features.TagApi; -import org.jclouds.ec2.features.TagAsyncApi; -import org.jclouds.ec2.features.WindowsApi; -import org.jclouds.ec2.features.WindowsAsyncApi; -import org.jclouds.ec2.options.RunInstancesOptions; -import org.jclouds.ec2.services.AMIAsyncClient; -import org.jclouds.ec2.services.AMIClient; -import org.jclouds.ec2.services.AvailabilityZoneAndRegionAsyncClient; -import org.jclouds.ec2.services.AvailabilityZoneAndRegionClient; -import org.jclouds.ec2.services.ElasticBlockStoreAsyncClient; -import org.jclouds.ec2.services.ElasticBlockStoreClient; -import org.jclouds.ec2.services.ElasticIPAddressAsyncClient; -import org.jclouds.ec2.services.ElasticIPAddressClient; -import org.jclouds.ec2.services.InstanceAsyncClient; -import org.jclouds.ec2.services.InstanceClient; -import org.jclouds.ec2.services.SecurityGroupAsyncClient; -import org.jclouds.ec2.services.SecurityGroupClient; -import org.jclouds.ec2.services.WindowsAsyncClient; -import org.jclouds.ec2.services.WindowsClient; -import org.jclouds.rest.ConfiguresRestClient; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; - -/** - * Configures the EC2 connection. - * - * @author Adrian Cole - */ -@ConfiguresRestClient -public class AWSEC2RestClientModule extends EC2RestClientModule { - - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// - .put(AWSAMIClient.class, AWSAMIAsyncClient.class)// - .put(ElasticIPAddressClient.class, ElasticIPAddressAsyncClient.class)// - .put(AWSInstanceClient.class, AWSInstanceAsyncClient.class)// - .put(AWSKeyPairClient.class, AWSKeyPairAsyncClient.class)// - .put(AWSSecurityGroupClient.class, AWSSecurityGroupAsyncClient.class)// - .put(PlacementGroupClient.class, PlacementGroupAsyncClient.class)// - .put(MonitoringClient.class, MonitoringAsyncClient.class)// - .put(WindowsClient.class, WindowsAsyncClient.class)// - .put(AvailabilityZoneAndRegionClient.class, AvailabilityZoneAndRegionAsyncClient.class)// - .put(ElasticBlockStoreClient.class, ElasticBlockStoreAsyncClient.class)// - .put(SpotInstanceClient.class, SpotInstanceAsyncClient.class)// - .put(WindowsApi.class, WindowsAsyncApi.class)// - .put(TagApi.class, TagAsyncApi.class)// - .put(SubnetApi.class, SubnetAsyncApi.class)// - .build(); - - public AWSEC2RestClientModule() { - super(typeToken(AWSEC2Client.class), typeToken(AWSEC2AsyncClient.class), DELEGATE_MAP); - } - - @Singleton - @Provides - EC2Client provide(AWSEC2Client in) { - return in; - } - - @Singleton - @Provides - EC2AsyncClient provide(AWSEC2AsyncClient in) { - return in; - } - - @Singleton - @Provides - InstanceClient getInstanceServices(AWSEC2Client in) { - return in.getInstanceServices(); - } - - @Singleton - @Provides - InstanceAsyncClient getInstanceServices(AWSEC2AsyncClient in) { - return in.getInstanceServices(); - } - - @Singleton - @Provides - SecurityGroupClient getSecurityGroupServices(AWSEC2Client in) { - return in.getSecurityGroupServices(); - } - - @Singleton - @Provides - SecurityGroupAsyncClient getSecurityGroupServices(AWSEC2AsyncClient in) { - return in.getSecurityGroupServices(); - } - - @Singleton - @Provides - AMIClient getAMIServices(AWSEC2Client in) { - return in.getAMIServices(); - } - - @Singleton - @Provides - AMIAsyncClient getAMIServices(AWSEC2AsyncClient in) { - return in.getAMIServices(); - } - - @Override - protected void configure() { - bind(RunInstancesOptions.class).to(AWSRunInstancesOptions.class); - bind(new TypeLiteral>() { - }).to(SpotInstanceRequestToAWSRunningInstance.class); - super.configure(); - } -} diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSAMIAsyncClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java similarity index 62% rename from providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSAMIAsyncClient.java rename to providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java index 0a1c48b151..92eb3b0f92 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSAMIAsyncClient.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static org.jclouds.aws.reference.FormParameters.ACTION; @@ -28,7 +28,7 @@ import javax.ws.rs.Path; import org.jclouds.aws.ec2.xml.ProductCodesHandler; import org.jclouds.aws.filters.FormSigner; import org.jclouds.ec2.binders.BindProductCodesToIndexedFormParams; -import org.jclouds.ec2.services.AMIAsyncClient; +import org.jclouds.ec2.features.AMIApi; import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; import org.jclouds.rest.annotations.BinderParam; @@ -38,8 +38,6 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.VirtualHost; import org.jclouds.rest.annotations.XMLResponseParser; -import com.google.common.util.concurrent.ListenableFuture; - /** * Provides access to AMI Services. *

@@ -48,43 +46,80 @@ import com.google.common.util.concurrent.ListenableFuture; */ @RequestFilters(FormSigner.class) @VirtualHost -public interface AWSAMIAsyncClient extends AMIAsyncClient { +public interface AWSAMIApi extends AMIApi { // TODO make AWSImage as it has product codes... /** - * @see AMIClient#getProductCodesForImageInRegion + * Returns the Product Codes of an image. + * + * @param region + * AMIs are tied to the Region where its files are located within Amazon S3. + * @param imageId + * The ID of the AMI for which an attribute will be described + * @see #describeImages + * @see #modifyImageAttribute + * @see #resetImageAttribute + * @see + * @see DescribeImagesOptions */ @Named("DescribeImageAttribute") @POST @Path("/") @FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute", "productCodes" }) @XMLResponseParser(ProductCodesHandler.class) - ListenableFuture> getProductCodesForImageInRegion( + Set getProductCodesForImageInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("ImageId") String imageId); /** - * @see AMIClient#addProductCodesToImageInRegion + * Adds {@code productCode}s to an AMI. + * + * @param region + * AMIs are tied to the Region where its files are located within Amazon S3. + * @param productCodes + * Product Codes + * @param imageId + * The AMI ID. + * + * @see #removeProductCodesFromImage + * @see #describeImageAttribute + * @see #resetImageAttribute + * @see */ @Named("ModifyImageAttribute") @POST @Path("/") @FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute", "add", "productCodes" }) - ListenableFuture addProductCodesToImageInRegion( + void addProductCodesToImageInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @BinderParam(BindProductCodesToIndexedFormParams.class) Iterable productCodes, @FormParam("ImageId") String imageId); /** - * @see AMIClient#removeProductCodesToImageInRegion + * Removes {@code productCode}s from an AMI. + * + * @param region + * AMIs are tied to the Region where its files are located within Amazon S3. + * @param productCodes + * Product Codes + * @param imageId + * The AMI ID. + * + * @see #addProductCodesToImage + * @see #describeImageAttribute + * @see #resetImageAttribute + * @see */ @Named("ModifyImageAttribute") @POST @Path("/") @FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute", "remove", "productCodes" }) - ListenableFuture removeProductCodesFromImageInRegion( + void removeProductCodesFromImageInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @BinderParam(BindProductCodesToIndexedFormParams.class) Iterable productCodes, @FormParam("ImageId") String imageId); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java similarity index 85% rename from providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClient.java rename to providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java index de55b010e3..5a26707a9e 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClient.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static org.jclouds.aws.reference.FormParameters.ACTION; @@ -34,7 +34,7 @@ import org.jclouds.ec2.binders.BindInstanceIdsToIndexedFormParams; import org.jclouds.ec2.binders.IfNotNullBindAvailabilityZoneToFormParam; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.options.RunInstancesOptions; -import org.jclouds.ec2.services.InstanceAsyncClient; +import org.jclouds.ec2.features.InstanceApi; import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; import org.jclouds.rest.annotations.BinderParam; @@ -45,8 +45,6 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.VirtualHost; import org.jclouds.rest.annotations.XMLResponseParser; -import com.google.common.util.concurrent.ListenableFuture; - /** * Provides access to EC2 Instance Services via their REST API. *

@@ -55,11 +53,8 @@ import com.google.common.util.concurrent.ListenableFuture; */ @RequestFilters(FormSigner.class) @VirtualHost -public interface AWSInstanceAsyncClient extends InstanceAsyncClient { +public interface AWSInstanceApi extends InstanceApi { - /** - * @see AWSInstanceClient#describeInstancesInRegion - */ @Named("DescribeInstances") @Override @POST @@ -67,20 +62,17 @@ public interface AWSInstanceAsyncClient extends InstanceAsyncClient { @FormParams(keys = ACTION, values = "DescribeInstances") @XMLResponseParser(AWSDescribeInstancesResponseHandler.class) @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture>> describeInstancesInRegion( + Set> describeInstancesInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds); - /** - * @see AWSInstanceClient#runInstancesInRegion - */ @Named("RunInstances") @Override @POST @Path("/") @FormParams(keys = ACTION, values = "RunInstances") @XMLResponseParser(AWSRunInstancesResponseHandler.class) - ListenableFuture> runInstancesInRegion( + Reservation runInstancesInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @Nullable @BinderParam(IfNotNullBindAvailabilityZoneToFormParam.class) String nullableAvailabilityZone, @FormParam("ImageId") String imageId, @FormParam("MinCount") int minCount, diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSKeyPairClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java similarity index 64% rename from providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSKeyPairClient.java rename to providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java index 3d23d0b779..5813dce259 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSKeyPairClient.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java @@ -14,17 +14,35 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; +import static org.jclouds.aws.reference.FormParameters.ACTION; + +import javax.inject.Named; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +import org.jclouds.aws.filters.FormSigner; import org.jclouds.ec2.domain.KeyPair; -import org.jclouds.ec2.services.KeyPairClient; +import org.jclouds.ec2.functions.EncodedRSAPublicKeyToBase64; +import org.jclouds.ec2.features.KeyPairApi; +import org.jclouds.ec2.xml.KeyPairResponseHandler; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.FormParams; +import org.jclouds.rest.annotations.ParamParser; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.VirtualHost; +import org.jclouds.rest.annotations.XMLResponseParser; /** - * * @author Adrian Cole */ -public interface AWSKeyPairClient extends KeyPairClient { +@RequestFilters(FormSigner.class) +@VirtualHost +public interface AWSKeyPairApi extends KeyPairApi { /** * Imports the public key from an RSA key pair that you created with a third-party tool. Compare @@ -58,6 +76,13 @@ public interface AWSKeyPairClient extends KeyPairClient { * The public key * @return imported key including fingerprint */ - KeyPair importKeyPairInRegion(@Nullable String region, String keyName, String publicKeyMaterial); - + @Named("ImportKeyPair") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "ImportKeyPair") + @XMLResponseParser(KeyPairResponseHandler.class) + KeyPair importKeyPairInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("KeyName") String keyName, + @FormParam("PublicKeyMaterial") @ParamParser(EncodedRSAPublicKeyToBase64.class) String publicKeyMaterial); } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSSecurityGroupAsyncClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApi.java similarity index 77% rename from providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSSecurityGroupAsyncClient.java rename to providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApi.java index 25acb03666..d71d544fb6 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSSecurityGroupAsyncClient.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApi.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static org.jclouds.aws.reference.FormParameters.ACTION; @@ -34,7 +34,7 @@ import org.jclouds.ec2.binders.BindGroupIdsToIndexedFormParams; import org.jclouds.ec2.binders.BindIpPermissionToIndexedFormParams; import org.jclouds.ec2.binders.BindIpPermissionsToIndexedFormParams; import org.jclouds.ec2.domain.SecurityGroup; -import org.jclouds.ec2.services.SecurityGroupAsyncClient; +import org.jclouds.ec2.features.SecurityGroupApi; import org.jclouds.ec2.xml.DescribeSecurityGroupsResponseHandler; import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; @@ -48,7 +48,6 @@ import org.jclouds.rest.annotations.VirtualHost; import org.jclouds.rest.annotations.XMLResponseParser; import com.google.common.annotations.Beta; -import com.google.common.util.concurrent.ListenableFuture; /** * Provides access to EC2 SecurityGroup Services via their REST API. @@ -59,91 +58,67 @@ import com.google.common.util.concurrent.ListenableFuture; @RequestFilters(FormSigner.class) @VirtualHost @Beta -public interface AWSSecurityGroupAsyncClient extends SecurityGroupAsyncClient { - /** - * @see AWSSecurityGroupClient#createSecurityGroupInRegion - */ +public interface AWSSecurityGroupApi extends SecurityGroupApi { + @Named("CreateSecurityGroup") @POST @Path("/") @XMLResponseParser(CreateSecurityGroupResponseHandler.class) @FormParams(keys = ACTION, values = "CreateSecurityGroup") - ListenableFuture createSecurityGroupInRegionAndReturnId( + String createSecurityGroupInRegionAndReturnId( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupName") String name, @FormParam("GroupDescription") String description, CreateSecurityGroupOptions... options); - /** - * @see AWSSecurityGroupClient#authorizeSecurityGroupIngressInRegion(String, - * String,IpPermission) - */ @Named("AuthorizeSecurityGroupIngress") @POST @Path("/") @FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress") - ListenableFuture authorizeSecurityGroupIngressInRegion( + void authorizeSecurityGroupIngressInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupId") String groupId, @BinderParam(BindIpPermissionToIndexedFormParams.class) IpPermission perm); - /** - * @see AWSSecurityGroupClient#authorizeSecurityGroupIngressInRegion(String, - * String,Iterable) - */ @Named("AuthorizeSecurityGroupIngress") @POST @Path("/") @FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress") - ListenableFuture authorizeSecurityGroupIngressInRegion( + void authorizeSecurityGroupIngressInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupId") String groupId, @BinderParam(BindIpPermissionsToIndexedFormParams.class) Iterable perms); - /** - * @see AWSSecurityGroupClient#revokeSecurityGroupIngressInRegion(@Nullable - * Region, String,IpPermission) - */ @Named("RevokeSecurityGroupIngress") @POST @Path("/") @FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress") - ListenableFuture revokeSecurityGroupIngressInRegion( + void revokeSecurityGroupIngressInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupId") String groupId, @BinderParam(BindIpPermissionToIndexedFormParams.class) IpPermission perm); - /** - * @see AWSSecurityGroupClient#revokeSecurityGroupIngressInRegion(@Nullable - * Region, String,Iterable) - */ @Named("RevokeSecurityGroupIngress") @POST @Path("/") @FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress") - ListenableFuture revokeSecurityGroupIngressInRegion( + void revokeSecurityGroupIngressInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupId") String groupId, @BinderParam(BindIpPermissionsToIndexedFormParams.class) Iterable perms); - /** - * @see AWSSecurityGroupClient#deleteSecurityGroupInRegionById - */ @Named("DeleteSecurityGroup") @POST @Path("/") @FormParams(keys = ACTION, values = "DeleteSecurityGroup") @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture deleteSecurityGroupInRegionById( + void deleteSecurityGroupInRegionById( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupId") String name); - /** - * @see AWSSecurityGroupClient#describeSecurityGroupsInRegionById - */ @Named("DescribeSecurityGroups") @POST @Path("/") @FormParams(keys = ACTION, values = "DescribeSecurityGroups") @XMLResponseParser(DescribeSecurityGroupsResponseHandler.class) @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> describeSecurityGroupsInRegionById( + Set describeSecurityGroupsInRegionById( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @BinderParam(BindGroupIdsToIndexedFormParams.class) String... securityGroupNames); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/MonitoringAsyncClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/MonitoringApi.java similarity index 69% rename from providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/MonitoringAsyncClient.java rename to providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/MonitoringApi.java index 61d96b47db..bb1de8a11d 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/MonitoringAsyncClient.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/MonitoringApi.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static org.jclouds.aws.reference.FormParameters.ACTION; @@ -38,8 +38,6 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.VirtualHost; import org.jclouds.rest.annotations.XMLResponseParser; -import com.google.common.util.concurrent.ListenableFuture; - /** * Provides access to EC2 Monitoring Services via their REST API. *

@@ -48,30 +46,51 @@ import com.google.common.util.concurrent.ListenableFuture; */ @RequestFilters(FormSigner.class) @VirtualHost -public interface MonitoringAsyncClient { +public interface MonitoringApi { /** - * @see Monitoring#monitorInstancesInRegion + * Enables monitoring for a running instance. For more information, refer to the Amazon + * CloudWatch Developer Guide. + * + * @param region + * Instances are tied to Availability Zones. However, the instance ID is tied to the + * Region. + * @see InstanceApi#runInstances + * @see #unmonitorInstances + * + * @see */ @Named("MonitorInstances") @POST @Path("/") @FormParams(keys = ACTION, values = "MonitorInstances") @XMLResponseParser(MonitoringStateHandler.class) - ListenableFuture> monitorInstancesInRegion( + Map monitorInstancesInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("InstanceId.0") String instanceId, @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds); /** - * @see Monitoring#monitorInstancesInRegion + * Disables monitoring for a running instance. For more information, refer to the Amazon + * CloudWatch Developer Guide. + * + * @param region + * Instances are tied to Availability Zones. However, the instance ID is tied to the + * Region. + * + * @see InstanceApi#runInstances + * @see #monitorInstances + * + * @see */ @Named("UnmonitorInstances") @POST @Path("/") @FormParams(keys = ACTION, values = "UnmonitorInstances") @XMLResponseParser(MonitoringStateHandler.class) - ListenableFuture> unmonitorInstancesInRegion( + Map unmonitorInstancesInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("InstanceId.0") String instanceId, @BinderParam(BindInstanceIdsToIndexedFormParams.class) String... instanceIds); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/PlacementGroupAsyncClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/PlacementGroupApi.java similarity index 60% rename from providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/PlacementGroupAsyncClient.java rename to providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/PlacementGroupApi.java index bd79cb4afb..1acc1217ec 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/PlacementGroupAsyncClient.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/PlacementGroupApi.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static org.jclouds.aws.reference.FormParameters.ACTION; @@ -41,8 +41,6 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.VirtualHost; import org.jclouds.rest.annotations.XMLResponseParser; -import com.google.common.util.concurrent.ListenableFuture; - /** * Provides access to EC2 Placement Groups via their REST API. *

@@ -51,42 +49,79 @@ import com.google.common.util.concurrent.ListenableFuture; */ @RequestFilters(FormSigner.class) @VirtualHost -public interface PlacementGroupAsyncClient { +public interface PlacementGroupApi { /** - * @see PlacementGroupClient#createPlacementGroupInRegion(String,String,String) + * Creates a placement group that you launch cluster compute instances into. You must give the + * group a name unique within the scope of your account. + * + * @param region + * Region to create the placement group in. + * @param name + * The name of the placement group.. + * @param strategy + * The placement group strategy. + * @see #describePlacementGroupsInRegion + * @see #deletePlacementGroupInRegion + * + * @see */ @Named("CreatePlacementGroup") @POST @Path("/") @FormParams(keys = ACTION, values = "CreatePlacementGroup") - ListenableFuture createPlacementGroupInRegion( + void createPlacementGroupInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupName") String name, @FormParam("Strategy") String strategy); /** - * @see PlacementGroupClient#createPlacementGroupInRegion(String,String) + * like {@link #createPlacementGroupInRegion(String,String,String) except that the strategy is default: "cluster". */ @Named("CreatePlacementGroup") @POST @Path("/") @FormParams(keys = { ACTION, "Strategy" }, values = { "CreatePlacementGroup", "cluster" }) - ListenableFuture createPlacementGroupInRegion( + void createPlacementGroupInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupName") String name); /** - * @see PlacementGroupClient#deletePlacementGroupInRegion + * Deletes a placement group from your account. You must terminate all instances in the placement group before deleting it. + * + * @param region + * Region to delete the placement from from + * @param name + * Name of the security group to delete. + * + * @see #describePlacementGroupsInRegion + * @see #createPlacementGroupInRegion + * + * @see */ @Named("DeletePlacementGroup") @POST @Path("/") @FormParams(keys = ACTION, values = "DeletePlacementGroup") @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture deletePlacementGroupInRegion( + void deletePlacementGroupInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupName") String name); /** - * @see PlacementGroupClient#describePlacementGroupsInRegion + * + * Returns information about one or more placement groups in your account. + * + * @param region + * The bundleTask ID is tied to the Region. + * @param groupNames + * The name of the placement group. You can specify more than one in the request, or + * omit the parameter if you want information about all your placement groups. By + * default, all placement groups are described + * + * @see #deletePlacementGroupInRegion + * @see #createPlacementGroupInRegion + * @see */ @Named("DescribePlacementGroups") @POST @@ -94,7 +129,7 @@ public interface PlacementGroupAsyncClient { @FormParams(keys = ACTION, values = "DescribePlacementGroups") @XMLResponseParser(DescribePlacementGroupsResponseHandler.class) @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> describePlacementGroupsInRegion( + Set describePlacementGroupsInRegion( @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @BinderParam(BindGroupNamesToIndexedFormParams.class) String... placementGroupIds); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/SpotInstanceClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/SpotInstanceApi.java similarity index 62% rename from providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/SpotInstanceClient.java rename to providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/SpotInstanceApi.java index d7ee0470d3..2d728e444f 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/SpotInstanceClient.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/features/SpotInstanceApi.java @@ -14,24 +14,50 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; + +import static org.jclouds.aws.reference.FormParameters.ACTION; import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; +import org.jclouds.aws.ec2.binders.BindLaunchSpecificationToFormParams; +import org.jclouds.aws.ec2.binders.BindSpotInstanceRequestIdsToIndexedFormParams; import org.jclouds.aws.ec2.domain.LaunchSpecification; import org.jclouds.aws.ec2.domain.Spot; import org.jclouds.aws.ec2.domain.SpotInstanceRequest; import org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions; import org.jclouds.aws.ec2.options.RequestSpotInstancesOptions; +import org.jclouds.aws.ec2.xml.DescribeSpotPriceHistoryResponseHandler; +import org.jclouds.aws.ec2.xml.SpotInstanceHandler; +import org.jclouds.aws.ec2.xml.SpotInstancesHandler; +import org.jclouds.aws.filters.FormSigner; import org.jclouds.javax.annotation.Nullable; +import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.FormParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.VirtualHost; +import org.jclouds.rest.annotations.XMLResponseParser; /** - * Provides Spot Instance services for EC2. For more information, refer to the Amazon EC2 Developer - * Guide. + * Provides access to EC2 Spot Instances via their REST API. *

* * @author Adrian Cole */ -public interface SpotInstanceClient { +@RequestFilters(FormSigner.class) +@VirtualHost +public interface SpotInstanceApi { + /** * Describes Spot Instance requests. Spot Instances are instances that Amazon EC2 starts on your * behalf when the maximum price that you specify exceeds the current Spot Price. Amazon EC2 @@ -52,7 +78,15 @@ public interface SpotInstanceClient { * /> * @return TODO */ - Set describeSpotInstanceRequestsInRegion(@Nullable String region, String... requestIds); + @Named("DescribeSpotInstanceRequests") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DescribeSpotInstanceRequests") + @Fallback(EmptySetOnNotFoundOr404.class) + @XMLResponseParser(SpotInstancesHandler.class) + Set describeSpotInstanceRequestsInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @BinderParam(BindSpotInstanceRequestIdsToIndexedFormParams.class) String... requestIds); /** * request a single spot instance @@ -69,8 +103,15 @@ public interface SpotInstanceClient { * @return spot instance request * @see #requestSpotInstancesInRegion */ - SpotInstanceRequest requestSpotInstanceInRegion(@Nullable String region, float spotPrice, String imageId, - String instanceType); + @Named("RequestSpotInstances") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "RequestSpotInstances") + @XMLResponseParser(SpotInstanceHandler.class) + SpotInstanceRequest requestSpotInstanceInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("SpotPrice") float spotPrice, @FormParam("LaunchSpecification.ImageId") String imageId, + @FormParam("LaunchSpecification.InstanceType") String instanceType); /** * Creates a Spot Instance request. Spot Instances are instances that Amazon EC2 starts on your @@ -99,8 +140,16 @@ public interface SpotInstanceClient { * /> * @return set of spot instance requests */ - Set requestSpotInstancesInRegion(@Nullable String region, float spotPrice, int instanceCount, - LaunchSpecification launchSpec, RequestSpotInstancesOptions... options); + @Named("RequestSpotInstances") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "RequestSpotInstances") + @XMLResponseParser(SpotInstancesHandler.class) + Set requestSpotInstancesInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @FormParam("SpotPrice") float spotPrice, @FormParam("InstanceCount") int instanceCount, + @BinderParam(BindLaunchSpecificationToFormParams.class) LaunchSpecification launchSpec, + RequestSpotInstancesOptions... options); /** * @@ -123,7 +172,15 @@ public interface SpotInstanceClient { * /> * @return TODO */ - Set describeSpotPriceHistoryInRegion(@Nullable String region, DescribeSpotPriceHistoryOptions... options); + @Named("DescribeSpotPriceHistory") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "DescribeSpotPriceHistory") + @XMLResponseParser(DescribeSpotPriceHistoryResponseHandler.class) + @Fallback(EmptySetOnNotFoundOr404.class) + Set describeSpotPriceHistoryInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + DescribeSpotPriceHistoryOptions... options); /** * Cancels one or more Spot Instance requests. Spot Instances are instances that Amazon EC2 @@ -145,6 +202,13 @@ public interface SpotInstanceClient { * /> * @return TODO */ - String cancelSpotInstanceRequestsInRegion(@Nullable String region, String... requestIds); + @Named("CancelSpotInstanceRequests") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "CancelSpotInstanceRequests") + @Fallback(VoidOnNotFoundOr404.class) + void cancelSpotInstanceRequestsInRegion( + @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, + @BinderParam(BindSpotInstanceRequestIdsToIndexedFormParams.class) String... requestIds); } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java index 86eee5426d..0143aaef23 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java @@ -25,7 +25,7 @@ import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.aws.AWSResponseException; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.domain.PlacementGroup; import org.jclouds.aws.ec2.domain.PlacementGroup.State; import org.jclouds.compute.reference.ComputeServiceConstants; @@ -44,13 +44,13 @@ public class CreatePlacementGroupIfNeeded extends CacheLoader placementGroupAvailable; @Inject - public CreatePlacementGroupIfNeeded(AWSEC2Client ec2Client, + public CreatePlacementGroupIfNeeded(AWSEC2Api ec2Api, @Named("AVAILABLE") Predicate placementGroupAvailable) { - this.ec2Client = ec2Client; + this.ec2Api = ec2Api; this.placementGroupAvailable = placementGroupAvailable; } @@ -65,7 +65,7 @@ public class CreatePlacementGroupIfNeeded extends CacheLoader> creating placementGroup region(%s) name(%s)", region, name); try { - ec2Client.getPlacementGroupServices().createPlacementGroupInRegion(region, name); + ec2Api.getPlacementGroupApi().get().createPlacementGroupInRegion(region, name); logger.debug("<< created placementGroup(%s)", name); checkState(placementGroupAvailable.apply(new PlacementGroup(region, name, "cluster", State.PENDING)), String .format("placementGroup region(%s) name(%s) failed to become available", region, name)); diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java index f194cfa553..52bef6c47b 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java @@ -24,7 +24,7 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.domain.RegionNameAndPublicKeyMaterial; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.ec2.domain.KeyPair; @@ -43,11 +43,11 @@ public class ImportOrReturnExistingKeypair implements Function * import static org.jclouds.aws.ec2.options.RunInstancesOptions.Builder.* *

- * EC2Client connection = // get connection + * EC2Api connection = // get connection * Future instances = connection.runInstances(executableBy("123125").imageIds(1000, 1004)); * * diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java index be409eb833..3a929bf0da 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java @@ -30,7 +30,7 @@ import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; * * import static org.jclouds.aws.ec2.options.CreateSecurityGroupOptions.Builder.* *

- * AWSEC2Client connection = // get connection + * AWSEC2Api connection = // get connection * group = connection.getAMIServices().createSecurityGroup(vpcId("123125").noReboot()); * * diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java index d7cc9b1d81..228f681bad 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java @@ -33,7 +33,7 @@ import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; * * import static org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions.Builder.* *

- * AWSEC2Client client = // get connection + * AWSEC2Api client = // get connection * history = client.getSpotInstanceServices().describeSpotPriceHistoryInRegion(from(yesterday).instanceType("m1.small")); * * diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java index 9bbe248668..7f902693db 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java @@ -34,7 +34,7 @@ import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; * * import static org.jclouds.aws.ec2.options.RequestSpotInstancesOptions.Builder.* *

- * AWSEC2Client client = // get connection + * AWSEC2Api client = // get connection * history = client.getSpotInstanceServices().requestSpotInstancesInRegion("us-east-1",validFrom(yesterday).type("m1.small")); * * diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java index 5f9d024920..c04b8d574a 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java @@ -21,7 +21,7 @@ import java.util.NoSuchElementException; import javax.annotation.Resource; import javax.inject.Singleton; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.domain.PlacementGroup; import org.jclouds.logging.Logger; import org.jclouds.rest.ResourceNotFoundException; @@ -38,13 +38,13 @@ import com.google.inject.Inject; @Singleton public class PlacementGroupAvailable implements Predicate { - private final AWSEC2Client client; + private final AWSEC2Api client; @Resource protected Logger logger = Logger.NULL; @Inject - public PlacementGroupAvailable(AWSEC2Client client) { + public PlacementGroupAvailable(AWSEC2Api client) { this.client = client; } @@ -63,7 +63,7 @@ public class PlacementGroupAvailable implements Predicate { } private PlacementGroup refresh(PlacementGroup group) { - return Iterables.getOnlyElement(client.getPlacementGroupServices().describePlacementGroupsInRegion( + return Iterables.getOnlyElement(client.getPlacementGroupApi().get().describePlacementGroupsInRegion( group.getRegion(), group.getName())); } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java index ad116f5cd7..b8257ebee5 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java @@ -21,7 +21,7 @@ import java.util.NoSuchElementException; import javax.annotation.Resource; import javax.inject.Singleton; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.domain.PlacementGroup; import org.jclouds.logging.Logger; @@ -37,13 +37,13 @@ import com.google.inject.Inject; @Singleton public class PlacementGroupDeleted implements Predicate { - private final AWSEC2Client client; + private final AWSEC2Api client; @Resource protected Logger logger = Logger.NULL; @Inject - public PlacementGroupDeleted(AWSEC2Client client) { + public PlacementGroupDeleted(AWSEC2Api client) { this.client = client; } @@ -60,7 +60,7 @@ public class PlacementGroupDeleted implements Predicate { } private PlacementGroup refresh(PlacementGroup group) { - return Iterables.getOnlyElement(client.getPlacementGroupServices().describePlacementGroupsInRegion( + return Iterables.getOnlyElement(client.getPlacementGroupApi().get().describePlacementGroupsInRegion( group.getRegion(), group.getName())); } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java index 9ec31aeee0..83951612ee 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java @@ -21,7 +21,7 @@ import java.util.NoSuchElementException; import javax.annotation.Resource; import javax.inject.Singleton; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.domain.SpotInstanceRequest; import org.jclouds.logging.Logger; import org.jclouds.rest.ResourceNotFoundException; @@ -38,13 +38,13 @@ import com.google.inject.Inject; @Singleton public class SpotInstanceRequestActive implements Predicate { - private final AWSEC2Client client; + private final AWSEC2Api client; @Resource protected Logger logger = Logger.NULL; @Inject - public SpotInstanceRequestActive(AWSEC2Client client) { + public SpotInstanceRequestActive(AWSEC2Api client) { this.client = client; } @@ -69,7 +69,7 @@ public class SpotInstanceRequestActive implements Predicate } private SpotInstanceRequest refresh(SpotInstanceRequest spot) { - return Iterables.getOnlyElement(client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion( + return Iterables.getOnlyElement(client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion( spot.getRegion(), spot.getId())); } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSAMIClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSAMIClient.java deleted file mode 100644 index 75247ad41d..0000000000 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSAMIClient.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import java.util.Set; -import org.jclouds.ec2.services.AMIClient; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides access to EC2 via their REST API. - *

- * - * @author Adrian Cole - */ -public interface AWSAMIClient extends AMIClient { - - - /** - * Returns the Product Codes of an image. - * - * @param region - * AMIs are tied to the Region where its files are located within Amazon S3. - * @param imageId - * The ID of the AMI for which an attribute will be described - * @see #describeImages - * @see #modifyImageAttribute - * @see #resetImageAttribute - * @see - * @see DescribeImagesOptions - */ - Set getProductCodesForImageInRegion(@Nullable String region, String imageId); - - - /** - * Adds {@code productCode}s to an AMI. - * - * @param region - * AMIs are tied to the Region where its files are located within Amazon S3. - * @param productCodes - * Product Codes - * @param imageId - * The AMI ID. - * - * @see #removeProductCodesFromImage - * @see #describeImageAttribute - * @see #resetImageAttribute - * @see - */ - void addProductCodesToImageInRegion(@Nullable String region, Iterable productCodes, String imageId); - - /** - * Removes {@code productCode}s from an AMI. - * - * @param region - * AMIs are tied to the Region where its files are located within Amazon S3. - * @param productCodes - * Product Codes - * @param imageId - * The AMI ID. - * - * @see #addProductCodesToImage - * @see #describeImageAttribute - * @see #resetImageAttribute - * @see - */ - void removeProductCodesFromImageInRegion(@Nullable String region, Iterable productCodes, - String imageId); -} diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSInstanceClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSInstanceClient.java deleted file mode 100644 index deb911b3e4..0000000000 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSInstanceClient.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import java.util.Set; -import org.jclouds.aws.ec2.domain.AWSRunningInstance; -import org.jclouds.ec2.domain.Reservation; -import org.jclouds.ec2.options.RunInstancesOptions; -import org.jclouds.ec2.services.InstanceClient; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides access to EC2 via their REST API. - *

- * - * @author Adrian Cole - */ -public interface AWSInstanceClient extends InstanceClient { - - @Override - Set> describeInstancesInRegion(@Nullable String region, - String... instanceIds); - - @Override - Reservation runInstancesInRegion(@Nullable String region, - @Nullable String nullableAvailabilityZone, String imageId, int minCount, int maxCount, - RunInstancesOptions... options); - -} diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClient.java deleted file mode 100644 index 8cb9abd938..0000000000 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClient.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.ec2.domain.KeyPair; -import org.jclouds.ec2.functions.EncodedRSAPublicKeyToBase64; -import org.jclouds.ec2.services.KeyPairAsyncClient; -import org.jclouds.ec2.xml.KeyPairResponseHandler; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.FormParams; -import org.jclouds.rest.annotations.ParamParser; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.VirtualHost; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface AWSKeyPairAsyncClient extends KeyPairAsyncClient { - - /** - * @see AWSKeyPairClient#importKeyPairInRegion - */ - @Named("ImportKeyPair") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "ImportKeyPair") - @XMLResponseParser(KeyPairResponseHandler.class) - ListenableFuture importKeyPairInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("KeyName") String keyName, - @FormParam("PublicKeyMaterial") @ParamParser(EncodedRSAPublicKeyToBase64.class) String publicKeyMaterial); -} diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClient.java deleted file mode 100644 index ac3b3013a1..0000000000 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClient.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import java.util.Set; -import org.jclouds.aws.ec2.options.CreateSecurityGroupOptions; -import org.jclouds.ec2.domain.SecurityGroup; -import org.jclouds.ec2.services.SecurityGroupClient; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.net.domain.IpPermission; - -import com.google.common.annotations.Beta; - -/** - * Provides access to EC2 via their REST API. - *

- * - * @author Adrian Cole - */ -@Beta -public interface AWSSecurityGroupClient extends SecurityGroupClient { - - String createSecurityGroupInRegionAndReturnId(@Nullable String region, String name, String desc, - CreateSecurityGroupOptions... options); - - void authorizeSecurityGroupIngressInRegion(@Nullable String region, String groupId, IpPermission perm); - - void authorizeSecurityGroupIngressInRegion(@Nullable String region, String groupId, Iterable perm); - - void revokeSecurityGroupIngressInRegion(@Nullable String region, String groupId, IpPermission perm); - - void revokeSecurityGroupIngressInRegion(@Nullable String region, String groupId, Iterable perm); - - Set describeSecurityGroupsInRegionById(@Nullable String region, String... securityGroupIds); - - void deleteSecurityGroupInRegionById(@Nullable String region, String name); -} diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/MonitoringClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/MonitoringClient.java deleted file mode 100644 index 66c44ee9cf..0000000000 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/MonitoringClient.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import java.util.Map; -import org.jclouds.aws.ec2.domain.MonitoringState; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides monitoring services for EC2. For more information, refer to the Amazon CloudWatch - * Developer Guide. - *

- * - * @author Adrian Cole - */ -public interface MonitoringClient { - - /** - * Enables monitoring for a running instance. For more information, refer to the Amazon - * CloudWatch Developer Guide. - * - * @param region - * Instances are tied to Availability Zones. However, the instance ID is tied to the - * Region. - * @see InstanceClient#runInstances - * @see #unmonitorInstances - * - * @see - */ - Map monitorInstancesInRegion(@Nullable String region, String instanceId, - String... instanceIds); - - /** - * Disables monitoring for a running instance. For more information, refer to the Amazon - * CloudWatch Developer Guide. - * - * @param region - * Instances are tied to Availability Zones. However, the instance ID is tied to the - * Region. - * - * @see InstanceClient#runInstances - * @see #monitorInstances - * - * @see - */ - Map unmonitorInstancesInRegion(@Nullable String region, String instanceId, - String... instanceIds); -} diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/PlacementGroupClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/PlacementGroupClient.java deleted file mode 100644 index 3dfd8cc936..0000000000 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/PlacementGroupClient.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import java.util.Set; -import org.jclouds.aws.ec2.domain.PlacementGroup; -import org.jclouds.javax.annotation.Nullable; - -/** - * Provides Placement Group services for EC2. For more information, refer to the Amazon EC2 - * Developer Guide. - *

- * - * @author Adrian Cole - */ -public interface PlacementGroupClient { - - /** - * Creates a placement group that you launch cluster compute instances into. You must give the - * group a name unique within the scope of your account. - * - * @param region - * Region to create the placement group in. - * @param name - * The name of the placement group.. - * @param strategy - * The placement group strategy. - * @see #describePlacementGroupsInRegion - * @see #deletePlacementGroupInRegion - * - * @see - */ - void createPlacementGroupInRegion(@Nullable String region, String name, String strategy); - - /** - * like {@link #createPlacementGroupInRegion(String,String,String) except that the strategy is default: "cluster". - */ - void createPlacementGroupInRegion(@Nullable String region, String name); - - /** - * Deletes a placement group from your account. You must terminate all instances in the placement group before deleting it. - * - * @param region - * Region to delete the placement from from - * @param name - * Name of the security group to delete. - * - * @see #describePlacementGroupsInRegion - * @see #createPlacementGroupInRegion - * - * @see - */ - void deletePlacementGroupInRegion(@Nullable String region, String name); - - /** - * - * Returns information about one or more placement groups in your account. - * - * @param region - * The bundleTask ID is tied to the Region. - * @param groupNames - * The name of the placement group. You can specify more than one in the request, or - * omit the parameter if you want information about all your placement groups. By - * default, all placement groups are described - * - * @see #deletePlacementGroupInRegion - * @see #createPlacementGroupInRegion - * @see - */ - Set describePlacementGroupsInRegion(@Nullable String region, - String... groupNames); -} diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClient.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClient.java deleted file mode 100644 index bf773cdc1d..0000000000 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClient.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2.services; - -import static org.jclouds.aws.reference.FormParameters.ACTION; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.FormParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.aws.ec2.binders.BindLaunchSpecificationToFormParams; -import org.jclouds.aws.ec2.binders.BindSpotInstanceRequestIdsToIndexedFormParams; -import org.jclouds.aws.ec2.domain.LaunchSpecification; -import org.jclouds.aws.ec2.domain.Spot; -import org.jclouds.aws.ec2.domain.SpotInstanceRequest; -import org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions; -import org.jclouds.aws.ec2.options.RequestSpotInstancesOptions; -import org.jclouds.aws.ec2.xml.DescribeSpotPriceHistoryResponseHandler; -import org.jclouds.aws.ec2.xml.SpotInstanceHandler; -import org.jclouds.aws.ec2.xml.SpotInstancesHandler; -import org.jclouds.aws.filters.FormSigner; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.EndpointParam; -import org.jclouds.rest.annotations.Fallback; -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 com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides access to EC2 Spot Instances via their REST API. - *

- * - * @author Adrian Cole - */ -@RequestFilters(FormSigner.class) -@VirtualHost -public interface SpotInstanceAsyncClient { - - /** - * @see SpotInstanceClient#describeSpotInstanceRequestsInRegion - */ - @Named("DescribeSpotInstanceRequests") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DescribeSpotInstanceRequests") - @Fallback(EmptySetOnNotFoundOr404.class) - @XMLResponseParser(SpotInstancesHandler.class) - ListenableFuture> describeSpotInstanceRequestsInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @BinderParam(BindSpotInstanceRequestIdsToIndexedFormParams.class) String... requestIds); - - /** - * @see SpotInstanceClient#requestSpotInstanceInRegion - */ - @Named("RequestSpotInstances") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "RequestSpotInstances") - @XMLResponseParser(SpotInstanceHandler.class) - ListenableFuture requestSpotInstanceInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("SpotPrice") float spotPrice, @FormParam("LaunchSpecification.ImageId") String imageId, - @FormParam("LaunchSpecification.InstanceType") String instanceType); - - /** - * @see SpotInstanceClient#requestSpotInstancesInRegion - */ - @Named("RequestSpotInstances") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "RequestSpotInstances") - @XMLResponseParser(SpotInstancesHandler.class) - ListenableFuture> requestSpotInstancesInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @FormParam("SpotPrice") float spotPrice, @FormParam("InstanceCount") int instanceCount, - @BinderParam(BindLaunchSpecificationToFormParams.class) LaunchSpecification launchSpec, - RequestSpotInstancesOptions... options); - - /** - * @see SpotInstanceClient#describeSpotPriceHistoryInRegion - */ - @Named("DescribeSpotPriceHistory") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "DescribeSpotPriceHistory") - @XMLResponseParser(DescribeSpotPriceHistoryResponseHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - ListenableFuture> describeSpotPriceHistoryInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - DescribeSpotPriceHistoryOptions... options); - - /** - * @see SpotInstanceClient#cancelSpotInstanceRequestsInRegion - */ - @Named("CancelSpotInstanceRequests") - @POST - @Path("/") - @FormParams(keys = ACTION, values = "CancelSpotInstanceRequests") - @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture cancelSpotInstanceRequestsInRegion( - @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, - @BinderParam(BindSpotInstanceRequestIdsToIndexedFormParams.class) String... requestIds); - -} diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2AsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2AsyncClientTest.java deleted file mode 100644 index 838fa542af..0000000000 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2AsyncClientTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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.ec2; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; - -import org.jclouds.aws.ec2.services.BaseAWSEC2AsyncClientTest; -import org.jclouds.http.HttpRequest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code AWSEC2AsyncClient} - * - * @author Adrian Cole - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "AWSEC2AsyncClientTest") -public class AWSEC2AsyncClientTest extends BaseAWSEC2AsyncClientTest { - - private AWSEC2AsyncClient asyncClient; - private AWSEC2Client syncClient; - - public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException { - assert syncClient.getAMIServices() != null; - assert syncClient.getAvailabilityZoneAndRegionServices() != null; - assert syncClient.getElasticBlockStoreServices() != null; - assert syncClient.getElasticIPAddressServices() != null; - assert syncClient.getInstanceServices() != null; - assert syncClient.getKeyPairServices() != null; - assert syncClient.getMonitoringServices() != null; - assert syncClient.getSecurityGroupServices() != null; - assert syncClient.getPlacementGroupServices() != null; - assert syncClient.getWindowsServices() != null; - - } - - public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException { - assert asyncClient.getAMIServices() != null; - assert asyncClient.getAvailabilityZoneAndRegionServices() != null; - assert asyncClient.getElasticBlockStoreServices() != null; - assert asyncClient.getElasticIPAddressServices() != null; - assert asyncClient.getInstanceServices() != null; - assert asyncClient.getKeyPairServices() != null; - assert asyncClient.getMonitoringServices() != null; - assert asyncClient.getSecurityGroupServices() != null; - assert asyncClient.getPlacementGroupServices() != null; - assert asyncClient.getWindowsServices() != null; - } - - @BeforeClass - @Override - protected void setupFactory() throws IOException { - super.setupFactory(); - asyncClient = injector.getInstance(AWSEC2AsyncClient.class); - syncClient = injector.getInstance(AWSEC2Client.class); - } - - @Override - protected void checkFilters(HttpRequest request) { - - } - -} diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java index ae395235e2..235e596a1f 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java @@ -30,10 +30,10 @@ import java.util.concurrent.TimeUnit; import org.jclouds.ContextBuilder; import org.jclouds.aws.cloudwatch.AWSCloudWatchProviderMetadata; import org.jclouds.aws.ec2.AWSEC2ApiMetadata; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.MonitoringState; -import org.jclouds.aws.ec2.services.AWSSecurityGroupClient; +import org.jclouds.aws.ec2.features.AWSSecurityGroupApi; import org.jclouds.cloudwatch.CloudWatchApi; import org.jclouds.cloudwatch.domain.Dimension; import org.jclouds.cloudwatch.domain.EC2Constants; @@ -46,12 +46,12 @@ import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.Template; import org.jclouds.compute.predicates.NodePredicates; import org.jclouds.domain.LoginCredentials; -import org.jclouds.ec2.EC2Client; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.EC2ComputeServiceLiveTest; import org.jclouds.ec2.domain.KeyPair; import org.jclouds.ec2.domain.SecurityGroup; -import org.jclouds.ec2.services.InstanceClient; -import org.jclouds.ec2.services.KeyPairClient; +import org.jclouds.ec2.features.InstanceApi; +import org.jclouds.ec2.features.KeyPairApi; import org.jclouds.net.domain.IpProtocol; import org.jclouds.scriptbuilder.domain.Statements; import org.testng.annotations.Test; @@ -78,14 +78,11 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { public void testExtendedOptionsAndLogin() throws Exception { String region = "us-west-2"; - AWSSecurityGroupClient securityGroupClient = AWSEC2Client.class.cast( - view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()).getSecurityGroupServices(); + AWSSecurityGroupApi securityGroupApi = view.unwrapApi(AWSEC2Api.class).getSecurityGroupApi().get(); - KeyPairClient keyPairClient = EC2Client.class.cast(view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) - .getKeyPairServices(); + KeyPairApi keyPairApi = view.unwrapApi(AWSEC2Api.class).getKeyPairApi().get(); - InstanceClient instanceClient = EC2Client.class.cast(view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) - .getInstanceServices(); + InstanceApi instanceApi = view.unwrapApi(AWSEC2Api.class).getInstanceApi().get(); String group = this.group + "o"; @@ -105,20 +102,20 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { String startedId = null; try { - cleanupExtendedStuffInRegion(region, securityGroupClient, keyPairClient, group); + cleanupExtendedStuffInRegion(region, securityGroupApi, keyPairApi, group); Thread.sleep(3000);// eventual consistency if deletes actually occurred. // create a security group that allows ssh in so that our scripts later // will work - String groupId = securityGroupClient.createSecurityGroupInRegionAndReturnId(region, group, group); + String groupId = securityGroupApi.createSecurityGroupInRegionAndReturnId(region, group, group); - securityGroupClient.authorizeSecurityGroupIngressInRegion(region, groupId, permit(IpProtocol.TCP).port(22)); + securityGroupApi.authorizeSecurityGroupIngressInRegion(region, groupId, permit(IpProtocol.TCP).port(22)); template.getOptions().as(AWSEC2TemplateOptions.class).securityGroupIds(groupId); // create a keypair to pass in as well - KeyPair result = keyPairClient.createKeyPairInRegion(region, group); + KeyPair result = keyPairApi.createKeyPairInRegion(region, group); template.getOptions().as(AWSEC2TemplateOptions.class).keyPair(result.getKeyName()); // pass in the private key, so that we can run a script with it @@ -136,7 +133,7 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { startedId = first.getProviderId(); - AWSRunningInstance instance = AWSRunningInstance.class.cast(getOnlyElement(getOnlyElement(instanceClient + AWSRunningInstance instance = AWSRunningInstance.class.cast(getOnlyElement(getOnlyElement(instanceApi .describeInstancesInRegion(region, startedId)))); assertEquals(instance.getKeyName(), group); @@ -179,7 +176,7 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { assertEquals(newTreeSet(instance.getGroupNames()), ImmutableSortedSet. of("jclouds#" + group, group)); // make sure our dummy group has no rules - SecurityGroup secgroup = getOnlyElement(securityGroupClient.describeSecurityGroupsInRegion(instance + SecurityGroup secgroup = getOnlyElement(securityGroupApi.describeSecurityGroupsInRegion(instance .getRegion(), "jclouds#" + group)); assert secgroup.size() == 0 : secgroup; @@ -192,10 +189,10 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { client.destroyNodesMatching(NodePredicates.inGroup(group)); if (startedId != null) { // ensure we didn't delete these resources! - assertEquals(keyPairClient.describeKeyPairsInRegion(region, group).size(), 1); - assertEquals(securityGroupClient.describeSecurityGroupsInRegion(region, group).size(), 1); + assertEquals(keyPairApi.describeKeyPairsInRegion(region, group).size(), 1); + assertEquals(securityGroupApi.describeSecurityGroupsInRegion(region, group).size(), 1); } - cleanupExtendedStuffInRegion(region, securityGroupClient, keyPairClient, group); + cleanupExtendedStuffInRegion(region, securityGroupApi, keyPairApi, group); } } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index 240105fca8..ca94b70cc4 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -26,12 +26,14 @@ import java.util.Properties; import java.util.Set; import org.jclouds.aws.domain.Region; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.aws.ec2.reference.AWSEC2Constants; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; +import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.EC2ApiMetadata; import org.jclouds.ec2.compute.EC2TemplateBuilderLiveTest; import org.jclouds.ec2.compute.predicates.EC2ImagePredicates; @@ -40,7 +42,7 @@ import org.jclouds.ec2.domain.RootDeviceType; import org.jclouds.ec2.options.DescribeAvailabilityZonesOptions; import org.jclouds.ec2.options.DescribeRegionsOptions; import org.jclouds.ec2.reference.EC2Constants; -import org.jclouds.ec2.services.AvailabilityZoneAndRegionAsyncClient; +import org.jclouds.ec2.features.AvailabilityZoneAndRegionApi; import org.jclouds.http.HttpCommand; import org.jclouds.http.internal.TrackingJavaUrlHttpCommandExecutorService; import org.jclouds.location.reference.LocationConstants; @@ -336,9 +338,9 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { throws NoSuchMethodException { assert commandsInvoked.size() == 2 : commandsInvoked; assertEquals(getInvokerOfRequestAtIndex(commandsInvoked, 0), - AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeRegions", DescribeRegionsOptions[].class)); + AvailabilityZoneAndRegionApi.class.getMethod("describeRegions", DescribeRegionsOptions[].class)); assertEquals(getInvokerOfRequestAtIndex(commandsInvoked, 1), - AvailabilityZoneAndRegionAsyncClient.class.getMethod("describeAvailabilityZonesInRegion", String.class, + AvailabilityZoneAndRegionApi.class.getMethod("describeAvailabilityZonesInRegion", String.class, DescribeAvailabilityZonesOptions[].class)); } @@ -355,8 +357,8 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { @Test public void testAssignability() { - view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN); - view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN); + view.unwrapApi(EC2Api.class); + view.unwrapApi(AWSEC2Api.class); } @Override diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java index ae303c6e37..6481efd373 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java @@ -18,7 +18,7 @@ package org.jclouds.aws.ec2.compute.extensions; import static com.google.common.collect.Iterables.transform; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.util.AWSUtils; import org.jclouds.compute.domain.Image; import org.jclouds.compute.extensions.ImageExtension; @@ -45,13 +45,13 @@ public class AWSEC2ImageExtensionLiveTest extends BaseImageExtensionLiveTest { @Override protected Iterable listImages() { - AWSEC2Client client = view.utils().injector().getInstance(AWSEC2Client.class); + AWSEC2Api client = view.unwrapApi(AWSEC2Api.class); String[] parts = AWSUtils.parseHandle(imageId); String region = parts[0]; String imageId = parts[1]; EC2ImageParser parser = view.utils().injector().getInstance(EC2ImageParser.class); return transform( - client.getAMIServices().describeImagesInRegion(region, new DescribeImagesOptions().imageIds(imageId)), + client.getAMIApi().get().describeImagesInRegion(region, new DescribeImagesOptions().imageIds(imageId)), parser); } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java index de7360dd60..babe978882 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java @@ -24,17 +24,18 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.SpotInstanceRequest; -import org.jclouds.aws.ec2.services.AWSInstanceClient; -import org.jclouds.aws.ec2.services.SpotInstanceClient; +import org.jclouds.aws.ec2.features.AWSInstanceApi; +import org.jclouds.aws.ec2.features.SpotInstanceApi; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.domain.Reservation; import org.testng.annotations.Test; import com.google.common.base.Function; import com.google.common.base.Functions; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -50,25 +51,25 @@ public class PresentSpotRequestsAndInstancesTest { @Test public void testWhenInstancesPresentSingleCall() { - AWSEC2Client client = createMock(AWSEC2Client.class); - AWSInstanceClient instanceClient = createMock(AWSInstanceClient.class); + AWSEC2Api client = createMock(AWSEC2Api.class); + AWSInstanceApi instanceApi = createMock(AWSInstanceApi.class); Function converter = createMock(Function.class); - expect(client.getInstanceServices()).andReturn(instanceClient); + expect(client.getInstanceApi()).andReturn((Optional) Optional.of(instanceApi)); // avoid imatcher fail. if you change this, be sure to check multiple jres - expect(instanceClient.describeInstancesInRegion("us-east-1", "i-aaaa", "i-bbbb")).andReturn( + expect(instanceApi.describeInstancesInRegion("us-east-1", "i-aaaa", "i-bbbb")).andReturn( Set.class.cast(ImmutableSet.of(Reservation. builder().region("us-east-1") .instances(ImmutableSet.of(instance1, instance2)).build()))); - replay(client, instanceClient, converter); + replay(client, instanceApi, converter); PresentSpotRequestsAndInstances fn = new PresentSpotRequestsAndInstances(client, converter); assertEquals(fn.apply(ImmutableSet.of(new RegionAndName("us-east-1", "i-aaaa"), new RegionAndName("us-east-1", "i-bbbb"))), ImmutableSet.of(instance1, instance2)); - verify(client, instanceClient, converter); + verify(client, instanceApi, converter); } SpotInstanceRequest spot1 = createMock(SpotInstanceRequest.class); @@ -80,20 +81,20 @@ public class PresentSpotRequestsAndInstancesTest { Function converter = Functions.forMap(ImmutableMap.of(spot1, instance1, spot2, instance2)); - AWSEC2Client client = createMock(AWSEC2Client.class); - SpotInstanceClient spotClient = createMock(SpotInstanceClient.class); + AWSEC2Api client = createMock(AWSEC2Api.class); + SpotInstanceApi spotApi = createMock(SpotInstanceApi.class); - expect(client.getSpotInstanceServices()).andReturn(spotClient); - expect(spotClient.describeSpotInstanceRequestsInRegion("us-east-1", "sir-aaaa", "sir-bbbb")).andReturn( + expect(client.getSpotInstanceApi()).andReturn((Optional) Optional.of(spotApi)); + expect(spotApi.describeSpotInstanceRequestsInRegion("us-east-1", "sir-aaaa", "sir-bbbb")).andReturn( ImmutableSet.of(spot1, spot2)); - replay(client, spotClient); + replay(client, spotApi); PresentSpotRequestsAndInstances fn = new PresentSpotRequestsAndInstances(client, converter); assertEquals(fn.apply(ImmutableSet.of(new RegionAndName("us-east-1", "sir-aaaa"), new RegionAndName("us-east-1", "sir-bbbb"))), ImmutableSet.of(instance1, instance2)); - verify(client, spotClient); + verify(client, spotApi); } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java index 193cd72a00..e643f9e09b 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java @@ -22,11 +22,11 @@ import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_GENERATE_INSTA import java.util.Properties; import java.util.concurrent.atomic.AtomicInteger; -import org.jclouds.aws.ec2.config.AWSEC2RestClientModule; +import org.jclouds.aws.ec2.config.AWSEC2HttpApiModule; import org.jclouds.date.DateService; import org.jclouds.ec2.compute.internal.BaseEC2ComputeServiceExpectTest; import org.jclouds.http.HttpRequest; -import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.ConfiguresHttpApi; import org.testng.annotations.BeforeClass; import com.google.common.base.Supplier; @@ -100,8 +100,8 @@ public abstract class BaseAWSEC2ComputeServiceExpectTest extends BaseEC2ComputeS .addFormParam("Filter.3.Value.1", "machine").build()); } - @ConfiguresRestClient - protected static class TestAWSEC2RestClientModule extends AWSEC2RestClientModule { + @ConfiguresHttpApi + protected static class TestAWSEC2HttpApiModule extends AWSEC2HttpApiModule { @Override protected void configure() { @@ -128,6 +128,6 @@ public abstract class BaseAWSEC2ComputeServiceExpectTest extends BaseEC2ComputeS @Override protected Module createModule() { - return new TestAWSEC2RestClientModule(); + return new TestAWSEC2HttpApiModule(); } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java index 269a8f09dd..f61bf2e442 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java @@ -27,7 +27,7 @@ import static org.testng.Assert.assertEquals; import java.util.Set; import java.util.concurrent.ExecutionException; -import org.jclouds.aws.ec2.services.AWSSecurityGroupClient; +import org.jclouds.aws.ec2.features.AWSSecurityGroupApi; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.domain.RegionNameAndIngressRules; import org.jclouds.ec2.domain.SecurityGroup; @@ -51,7 +51,7 @@ public class AWSEC2CreateSecurityGroupIfNeededTest { @Test public void testWhenPort22AndToItselfAuthorizesIngressOnce() throws ExecutionException { - AWSSecurityGroupClient client = createMock(AWSSecurityGroupClient.class); + AWSSecurityGroupApi client = createMock(AWSSecurityGroupApi.class); Predicate tester = Predicates.alwaysTrue(); SecurityGroup group = createNiceMock(SecurityGroup.class); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java similarity index 90% rename from providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java rename to providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java index 0c8f36f27e..747e2248ba 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.filters; import static org.testng.Assert.assertNotNull; @@ -23,21 +23,21 @@ import java.util.Set; import org.jclouds.aws.domain.Region; import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.services.AMIClientLiveTest; +import org.jclouds.ec2.features.AMIApiLiveTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; /** - * Tests behavior of {@code AMIClient} + * Tests behavior of {@code AMIApi} * * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AWSAMIClientLiveTest extends AMIClientLiveTest { +public class AWSAMIApiLiveTest extends AMIApiLiveTest { - public AWSAMIClientLiveTest() { + public AWSAMIApiLiveTest() { provider = "aws-ec2"; } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiTest.java similarity index 92% rename from providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIAsyncClientTest.java rename to providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiTest.java index aee9b01b4c..8f8a856aca 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static org.jclouds.ec2.options.DescribeImagesOptions.Builder.executableBy; import static org.jclouds.reflect.Reflection2.method; @@ -41,14 +41,14 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.reflect.Invokable; /** - * Tests behavior of {@code AWSAMIAsyncClient} + * Tests behavior of {@code AWSAMIApi} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "AWSAMIAsyncClientTest") -public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest { - public AWSAMIAsyncClientTest() { +@Test(groups = "unit", testName = "AWSAMIApiTest") +public class AWSAMIApiTest extends BaseAWSEC2ApiTest { + public AWSAMIApiTest() { provider = "aws-ec2"; } @@ -60,7 +60,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "createImageInRegion", String.class, String.class, String.class, + Invokable method = method(AWSAMIApi.class, "createImageInRegion", String.class, String.class, String.class, CreateImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId")); @@ -87,7 +87,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "createImageInRegion", String.class, String.class, String.class, + Invokable method = method(AWSAMIApi.class, "createImageInRegion", String.class, String.class, String.class, CreateImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "instanceId", new CreateImageOptions() .withDescription("description").noReboot())); @@ -112,7 +112,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "describeImagesInRegion", String.class, + Invokable method = method(AWSAMIApi.class, "describeImagesInRegion", String.class, DescribeImagesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); @@ -141,7 +141,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "describeImagesInRegion", String.class, + Invokable method = method(AWSAMIApi.class, "describeImagesInRegion", String.class, DescribeImagesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, executableBy("me").ownedBy("fred", "nancy").imageIds( "1", "2"))); @@ -167,7 +167,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "deregisterImageInRegion", String.class, String.class); + Invokable method = method(AWSAMIApi.class, "deregisterImageInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -192,7 +192,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "registerImageFromManifestInRegion", String.class, String.class, + Invokable method = method(AWSAMIApi.class, "registerImageFromManifestInRegion", String.class, String.class, String.class, RegisterImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest")); @@ -218,7 +218,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "registerImageFromManifestInRegion", String.class, String.class, + Invokable method = method(AWSAMIApi.class, "registerImageFromManifestInRegion", String.class, String.class, String.class, RegisterImageOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "pathToManifest", new RegisterImageOptions() .withDescription("description"))); @@ -247,7 +247,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "registerUnixImageBackedByEbsInRegion", String.class, + Invokable method = method(AWSAMIApi.class, "registerUnixImageBackedByEbsInRegion", String.class, String.class, String.class, RegisterImageBackedByEbsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId")); @@ -282,7 +282,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "registerUnixImageBackedByEbsInRegion", String.class, + Invokable method = method(AWSAMIApi.class, "registerUnixImageBackedByEbsInRegion", String.class, String.class, String.class, RegisterImageBackedByEbsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId", new RegisterImageBackedByEbsOptions().withDescription("description").addBlockDeviceFromSnapshot( @@ -310,7 +310,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "getBlockDeviceMappingsForImageInRegion", String.class, + Invokable method = method(AWSAMIApi.class, "getBlockDeviceMappingsForImageInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); @@ -336,7 +336,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "getLaunchPermissionForImageInRegion", String.class, String.class); + Invokable method = method(AWSAMIApi.class, "getLaunchPermissionForImageInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); @@ -365,7 +365,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "addLaunchPermissionsToImageInRegion", String.class, + Invokable method = method(AWSAMIApi.class, "addLaunchPermissionsToImageInRegion", String.class, Iterable.class, Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "imageId")); @@ -396,7 +396,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "removeLaunchPermissionsFromImageInRegion", String.class, + Invokable method = method(AWSAMIApi.class, "removeLaunchPermissionsFromImageInRegion", String.class, Iterable.class, Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("bob", "sue"), ImmutableList .of("all"), "imageId")); @@ -422,7 +422,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "resetLaunchPermissionsOnImageInRegion", String.class, + Invokable method = method(AWSAMIApi.class, "resetLaunchPermissionsOnImageInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); @@ -441,7 +441,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "getProductCodesForImageInRegion", String.class, String.class); + Invokable method = method(AWSAMIApi.class, "getProductCodesForImageInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageId")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -458,7 +458,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "addProductCodesToImageInRegion", String.class, Iterable.class, + Invokable method = method(AWSAMIApi.class, "addProductCodesToImageInRegion", String.class, Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("code1", "code2"), "imageId")); @@ -477,7 +477,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSAMIAsyncClient.class, "removeProductCodesFromImageInRegion", String.class, + Invokable method = method(AWSAMIApi.class, "removeProductCodesFromImageInRegion", String.class, Iterable.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, ImmutableList.of("code1", "code2"), "imageId")); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java similarity index 78% rename from providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java rename to providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java index f2a360061b..468de54e18 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java @@ -14,12 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static org.testng.Assert.assertNotNull; import java.util.Set; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.AWSEC2ApiMetadata; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.ec2.domain.Reservation; @@ -28,30 +29,30 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** - * Tests behavior of {@code EC2Client} + * Tests behavior of {@code AWSEC2Api} * * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AWSInstanceClientLiveTest extends BaseComputeServiceContextLiveTest { - public AWSInstanceClientLiveTest() { +public class AWSInstanceApiLiveTest extends BaseComputeServiceContextLiveTest { + public AWSInstanceApiLiveTest() { provider = "aws-ec2"; } public static final String PREFIX = System.getProperty("user.name") + "-ec2"; - private AWSInstanceClient client; + private AWSInstanceApi client; @Override @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices(); + client = view.unwrapApi(AWSEC2Api.class).getInstanceApi().get(); } @Test void testDescribeInstances() { - for (String region : view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { + for (String region : view.unwrapApi(AWSEC2Api.class).getAvailabilityZoneAndRegionApi().get().describeRegions().keySet()) { Set> allResults = client.describeInstancesInRegion(region); assertNotNull(allResults); assert allResults.size() >= 0 : allResults.size(); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiTest.java similarity index 90% rename from providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java rename to providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiTest.java index 6fa19d731d..c59037d22a 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static org.jclouds.reflect.Reflection2.method; @@ -46,16 +46,16 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.reflect.Invokable; /** - * Tests behavior of {@code AWSInstanceAsyncClient} + * Tests behavior of {@code AWSInstanceApi} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire -@Test(groups = "unit", testName = "AWSInstanceAsyncClientTest") -public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest { +@Test(groups = "unit", testName = "AWSInstanceApiTest") +public class AWSInstanceApiTest extends BaseAWSEC2ApiTest { public void testDescribeInstances() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AWSInstanceAsyncClient.class, "describeInstancesInRegion", String.class, String[].class); + Invokable method = method(AWSInstanceApi.class, "describeInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -71,7 +71,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "describeInstancesInRegion", String.class, String[].class); + Invokable method = method(AWSInstanceApi.class, "describeInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -87,7 +87,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "terminateInstancesInRegion", String.class, String[].class); + Invokable method = method(AWSInstanceApi.class, "terminateInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -103,7 +103,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "runInstancesInRegion", String.class, String.class, + Invokable method = method(AWSInstanceApi.class, "runInstancesInRegion", String.class, String.class, String.class, int.class, int.class, RunInstancesOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, null, "ami-voo", 1, 1)); @@ -119,7 +119,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "runInstancesInRegion", String.class, String.class, + Invokable method = method(AWSInstanceApi.class, "runInstancesInRegion", String.class, String.class, String.class, int.class, int.class, RunInstancesOptions[].class); GeneratedHttpRequest request = processor.createRequest( method, @@ -145,7 +145,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "stopInstancesInRegion", String.class, boolean.class, + Invokable method = method(AWSInstanceApi.class, "stopInstancesInRegion", String.class, boolean.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, true, "1", "2")); @@ -162,7 +162,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "rebootInstancesInRegion", String.class, + Invokable method = method(AWSInstanceApi.class, "rebootInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); @@ -179,7 +179,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "startInstancesInRegion", String.class, + Invokable method = method(AWSInstanceApi.class, "startInstancesInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); @@ -196,7 +196,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "getUserDataForInstanceInRegion", String.class, + Invokable method = method(AWSInstanceApi.class, "getUserDataForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); @@ -214,7 +214,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "getRootDeviceNameForInstanceInRegion", String.class, + Invokable method = method(AWSInstanceApi.class, "getRootDeviceNameForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); @@ -232,7 +232,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "getRamdiskForInstanceInRegion", String.class, + Invokable method = method(AWSInstanceApi.class, "getRamdiskForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); @@ -251,7 +251,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "isApiTerminationDisabledForInstanceInRegion", + Invokable method = method(AWSInstanceApi.class, "isApiTerminationDisabledForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); @@ -269,7 +269,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "getKernelForInstanceInRegion", String.class, String.class); + Invokable method = method(AWSInstanceApi.class, "getKernelForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -285,7 +285,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "getInstanceTypeForInstanceInRegion", String.class, + Invokable method = method(AWSInstanceApi.class, "getInstanceTypeForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); @@ -304,7 +304,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "getInstanceInitiatedShutdownBehaviorForInstanceInRegion", + Invokable method = method(AWSInstanceApi.class, "getInstanceInitiatedShutdownBehaviorForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); @@ -324,7 +324,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "getBlockDeviceMappingForInstanceInRegion", String.class, + Invokable method = method(AWSInstanceApi.class, "getBlockDeviceMappingForInstanceInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1")); @@ -350,7 +350,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "setUserDataForInstanceInRegion", String.class, String.class, + Invokable method = method(AWSInstanceApi.class, "setUserDataForInstanceInRegion", String.class, String.class, byte[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test".getBytes())); @@ -377,7 +377,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "setRamdiskForInstanceInRegion", String.class, String.class, + Invokable method = method(AWSInstanceApi.class, "setRamdiskForInstanceInRegion", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); @@ -404,7 +404,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "setKernelForInstanceInRegion", String.class, String.class, + Invokable method = method(AWSInstanceApi.class, "setKernelForInstanceInRegion", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "test")); @@ -432,7 +432,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "setApiTerminationDisabledForInstanceInRegion", String.class, + Invokable method = method(AWSInstanceApi.class, "setApiTerminationDisabledForInstanceInRegion", String.class, String.class, boolean.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", true)); @@ -459,7 +459,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "setInstanceTypeForInstanceInRegion", String.class, + Invokable method = method(AWSInstanceApi.class, "setInstanceTypeForInstanceInRegion", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceType.C1_MEDIUM)); @@ -487,7 +487,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "setInstanceInitiatedShutdownBehaviorForInstanceInRegion", + Invokable method = method(AWSInstanceApi.class, "setInstanceInitiatedShutdownBehaviorForInstanceInRegion", String.class, String.class, InstanceInitiatedShutdownBehavior.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", InstanceInitiatedShutdownBehavior.TERMINATE)); @@ -516,7 +516,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSInstanceAsyncClient.class, "setBlockDeviceMappingForInstanceInRegion", String.class, + Invokable method = method(AWSInstanceApi.class, "setBlockDeviceMappingForInstanceInRegion", String.class, String.class, Map.class); Map mapping = Maps.newLinkedHashMap(); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiLiveTest.java similarity index 90% rename from providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java rename to providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiLiveTest.java index 62cc31388c..e629e7f4ab 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiLiveTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static com.google.common.collect.Iterables.get; import static com.google.common.collect.Iterables.getOnlyElement; @@ -35,7 +35,7 @@ import java.util.SortedSet; import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.AWSEC2ApiMetadata; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.compute.ComputeServiceContext; @@ -55,30 +55,30 @@ import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** - * Tests behavior of {@code AWSKeyPairClient} + * Tests behavior of {@code AWSKeyPairApi} * * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest { - public AWSKeyPairClientLiveTest() { +public class AWSKeyPairApiLiveTest extends BaseComputeServiceContextLiveTest { + public AWSKeyPairApiLiveTest() { provider = "aws-ec2"; } - private AWSKeyPairClient client; + private AWSKeyPairApi client; @Override @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getKeyPairServices(); + client = view.unwrapApi(AWSEC2Api.class).getKeyPairApi().get(); } public void testNoSsh() throws Exception { Map keyPair = ComputeTestUtils.setupKeyPair(); - AWSInstanceClient instanceClient = AWSEC2Client.class.cast(view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()).getInstanceServices(); + AWSInstanceApi instanceApi = view.unwrapApi(AWSEC2Api.class).getInstanceApi().get(); String group = PREFIX + "unssh"; view.getComputeService().destroyNodesMatching(inGroup(group)); @@ -100,7 +100,7 @@ public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest // the related private key assert first.getCredentials().credential == null : first; - AWSRunningInstance instance = getInstance(instanceClient, first.getProviderId()); + AWSRunningInstance instance = getInstance(instanceApi, first.getProviderId()); assertEquals(instance.getKeyName(), "jclouds#" + group); @@ -198,8 +198,8 @@ public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest assertEquals(listPair.getSha1OfPrivateKey(), keyPair.getSha1OfPrivateKey()); } - protected AWSRunningInstance getInstance(AWSInstanceClient instanceClient, String id) { - return getOnlyElement(getOnlyElement(instanceClient.describeInstancesInRegion(null, id))); + protected AWSRunningInstance getInstance(AWSInstanceApi instanceApi, String id) { + return getOnlyElement(getOnlyElement(instanceApi.describeInstancesInRegion(null, id))); } @Override diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiTest.java similarity index 87% rename from providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClientTest.java rename to providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiTest.java index ef2a9e3c8a..d97ee6efdf 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static org.jclouds.reflect.Reflection2.method; @@ -32,16 +32,16 @@ import org.testng.annotations.Test; import com.google.common.collect.Lists; import com.google.common.reflect.Invokable; /** - * Tests behavior of {@code AWSKeyPairAsyncClient} + * Tests behavior of {@code AWSKeyPairApi} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "AWSKeyPairAsyncClientTest") -public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest { +@Test(groups = "unit", testName = "AWSKeyPairApiTest") +public class AWSKeyPairApiTest extends BaseAWSEC2ApiTest { public void testCreateKeyPair() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AWSKeyPairAsyncClient.class, "createKeyPairInRegion", String.class, String.class); + Invokable method = method(AWSKeyPairApi.class, "createKeyPairInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -64,7 +64,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSKeyPairAsyncClient.class, "importKeyPairInRegion", String.class, String.class, + Invokable method = method(AWSKeyPairApi.class, "importKeyPairInRegion", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey", "ssh-rsa AA")); @@ -83,7 +83,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSKeyPairAsyncClient.class, "deleteKeyPairInRegion", String.class, String.class); + Invokable method = method(AWSKeyPairApi.class, "deleteKeyPairInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "mykey")); assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1"); @@ -99,7 +99,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSKeyPairAsyncClient.class, "describeKeyPairsInRegion", String.class, + Invokable method = method(AWSKeyPairApi.class, "describeKeyPairsInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); @@ -116,7 +116,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSKeyPairAsyncClient.class, "describeKeyPairsInRegion", String.class, + Invokable method = method(AWSKeyPairApi.class, "describeKeyPairsInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java similarity index 81% rename from providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java rename to providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java index 76c7e91ef3..731c70376f 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -22,7 +22,7 @@ import static org.testng.Assert.assertNotNull; import java.util.Set; import org.jclouds.ec2.domain.SecurityGroup; -import org.jclouds.ec2.services.SecurityGroupClientLiveTest; +import org.jclouds.ec2.features.SecurityGroupApiLiveTest; import org.jclouds.ec2.util.IpPermissions; import org.jclouds.net.domain.IpPermission; import org.jclouds.net.domain.IpProtocol; @@ -36,8 +36,8 @@ import com.google.common.collect.ImmutableMultimap; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class AWSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest { - public AWSSecurityGroupClientLiveTest() { +public class AWSSecurityGroupApiLiveTest extends SecurityGroupApiLiveTest { + public AWSSecurityGroupApiLiveTest() { provider = "aws-ec2"; } @@ -48,13 +48,13 @@ public class AWSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest cleanupAndSleep(group2Name); cleanupAndSleep(group1Name); try { - String group1Id = AWSSecurityGroupClient.class.cast(client).createSecurityGroupInRegionAndReturnId(null, + String group1Id = AWSSecurityGroupApi.class.cast(client).createSecurityGroupInRegionAndReturnId(null, group1Name, group1Name); - String group2Id = AWSSecurityGroupClient.class.cast(client).createSecurityGroupInRegionAndReturnId(null, + String group2Id = AWSSecurityGroupApi.class.cast(client).createSecurityGroupInRegionAndReturnId(null, group2Name, group2Name); Thread.sleep(100);// eventual consistent ensureGroupsExist(group1Name, group2Name); - AWSSecurityGroupClient.class.cast(client).authorizeSecurityGroupIngressInRegion(null, group1Id, + AWSSecurityGroupApi.class.cast(client).authorizeSecurityGroupIngressInRegion(null, group1Id, IpPermissions.permit(IpProtocol.TCP).port(80)); assertEventually(new GroupHasPermission(client, group1Name, new TCPPort80AllIPs())); Set oneResult = client.describeSecurityGroupsInRegion(null, group1Name); @@ -64,7 +64,7 @@ public class AWSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest assertEquals(group.getName(), group1Name); IpPermissions group2CanHttpGroup1 = IpPermissions.permit(IpProtocol.TCP).port(80) .originatingFromSecurityGroupId(group1Id); - AWSSecurityGroupClient.class.cast(client).authorizeSecurityGroupIngressInRegion(null, group2Id, + AWSSecurityGroupApi.class.cast(client).authorizeSecurityGroupIngressInRegion(null, group2Id, group2CanHttpGroup1); assertEventually(new GroupHasPermission(client, group2Name, new Predicate() { @Override @@ -74,7 +74,7 @@ public class AWSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest } })); - AWSSecurityGroupClient.class.cast(client).revokeSecurityGroupIngressInRegion(null, group2Id, + AWSSecurityGroupApi.class.cast(client).revokeSecurityGroupIngressInRegion(null, group2Id, group2CanHttpGroup1); assertEventually(new GroupHasNoPermissions(client, group2Name)); } finally { diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java similarity index 88% rename from providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupAsyncClientTest.java rename to providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java index 9ebead5cf0..93798aa554 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSSecurityGroupAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static org.jclouds.reflect.Reflection2.method; @@ -36,20 +36,20 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.reflect.Invokable; /** - * Tests behavior of {@code AWSSecurityGroupAsyncClient} + * Tests behavior of {@code AWSSecurityGroupApi} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire -@Test(groups = "unit", testName = "AWSSecurityGroupAsyncClientTest") -public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest { - public AWSSecurityGroupAsyncClientTest() { +@Test(groups = "unit", testName = "AWSSecurityGroupApiTest") +public class AWSSecurityGroupApiTest extends BaseAWSEC2ApiTest { + public AWSSecurityGroupApiTest() { provider = "aws-ec2"; } public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(AWSSecurityGroupAsyncClient.class, "deleteSecurityGroupInRegionById", String.class, + Invokable method = method(AWSSecurityGroupApi.class, "deleteSecurityGroupInRegionById", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id")); @@ -66,7 +66,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSSecurityGroupAsyncClient.class, "describeSecurityGroupsInRegionById", String.class, + Invokable method = method(AWSSecurityGroupApi.class, "describeSecurityGroupsInRegionById", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); @@ -83,7 +83,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSSecurityGroupAsyncClient.class, "describeSecurityGroupsInRegionById", String.class, + Invokable method = method(AWSSecurityGroupApi.class, "describeSecurityGroupsInRegionById", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); @@ -107,7 +107,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSSecurityGroupAsyncClient.class, "createSecurityGroupInRegion", String.class, + Invokable method = method(AWSSecurityGroupApi.class, "createSecurityGroupInRegion", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "description")); @@ -126,7 +126,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSSecurityGroupAsyncClient.class, "authorizeSecurityGroupIngressInRegion", + Invokable method = method(AWSSecurityGroupApi.class, "authorizeSecurityGroupIngressInRegion", String.class, String.class, IpPermission.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpPermissions.permitAnyProtocol())); @@ -145,7 +145,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSSecurityGroupAsyncClient.class, "authorizeSecurityGroupIngressInRegion", + Invokable method = method(AWSSecurityGroupApi.class, "authorizeSecurityGroupIngressInRegion", String.class, String.class, Iterable.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", ImmutableSet. of(IpPermissions .permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"), IpPermissions.permitICMP().type(8).andCode(0) @@ -166,7 +166,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSSecurityGroupAsyncClient.class, "revokeSecurityGroupIngressInRegion", String.class, + Invokable method = method(AWSSecurityGroupApi.class, "revokeSecurityGroupIngressInRegion", String.class, String.class, IpPermission.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", IpPermissions.permitAnyProtocol())); @@ -185,7 +185,7 @@ public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(AWSSecurityGroupAsyncClient.class, "revokeSecurityGroupIngressInRegion", String.class, + Invokable method = method(AWSSecurityGroupApi.class, "revokeSecurityGroupIngressInRegion", String.class, String.class, Iterable.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "group", ImmutableSet. of(IpPermissions .permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"), IpPermissions.permitICMP().type(8).andCode(0) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java similarity index 90% rename from providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java rename to providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java index 3c712c1022..aa796211fc 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/BaseAWSEC2AsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static com.google.common.collect.Maps.transformValues; import static org.testng.Assert.assertEquals; @@ -28,7 +28,7 @@ import javax.inject.Singleton; import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.AWSEC2ProviderMetadata; -import org.jclouds.aws.ec2.config.AWSEC2RestClientModule; +import org.jclouds.aws.ec2.config.AWSEC2HttpApiModule; import org.jclouds.aws.filters.FormSigner; import org.jclouds.compute.domain.Image; import org.jclouds.date.DateService; @@ -37,8 +37,8 @@ import org.jclouds.http.HttpRequest; import org.jclouds.location.config.LocationModule; import org.jclouds.location.suppliers.RegionIdToURISupplier; import org.jclouds.location.suppliers.RegionIdToZoneIdsSupplier; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.internal.BaseAsyncClientTest; +import org.jclouds.rest.ConfiguresHttpApi; +import org.jclouds.rest.internal.BaseAsyncApiTest; import org.jclouds.util.Suppliers2; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -56,10 +56,10 @@ import com.google.inject.Provides; * @author Adrian Cole */ @Test(groups = "unit") -public abstract class BaseAWSEC2AsyncClientTest extends BaseAsyncClientTest { +public abstract class BaseAWSEC2ApiTest extends BaseAsyncApiTest { - @ConfiguresRestClient - protected static class StubAWSEC2RestClientModule extends AWSEC2RestClientModule { + @ConfiguresHttpApi + protected static class StubAWSEC2HttpApiModule extends AWSEC2HttpApiModule { @Override protected String provideTimeStamp(DateService dateService) { @@ -122,7 +122,7 @@ public abstract class BaseAWSEC2AsyncClientTest extends BaseAsyncClientTest { +@Test(groups = "unit", testName = "MonitoringApiTest") +public class MonitoringApiTest extends BaseAWSEC2ApiTest { public void testUnmonitorInstances() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(MonitoringAsyncClient.class, "unmonitorInstancesInRegion", String.class, String.class, + Invokable method = method(MonitoringApi.class, "unmonitorInstancesInRegion", String.class, String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "instance1", "instance2")); @@ -54,7 +54,7 @@ public class MonitoringAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(MonitoringAsyncClient.class, "monitorInstancesInRegion", String.class, String.class, + Invokable method = method(MonitoringApi.class, "monitorInstancesInRegion", String.class, String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "instance1", "instance2")); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java similarity index 83% rename from providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java rename to providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java index d7f6663df9..b39813e5aa 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.collect.Lists.newArrayList; @@ -31,7 +31,7 @@ import java.util.SortedSet; import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.AWSEC2ApiMetadata; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.domain.PlacementGroup; import org.jclouds.aws.ec2.domain.PlacementGroup.State; import org.jclouds.aws.ec2.predicates.PlacementGroupAvailable; @@ -57,19 +57,19 @@ import com.google.common.base.Throwables; import com.google.inject.Module; /** - * Tests behavior of {@code PlacementGroupClient} + * Tests behavior of {@code PlacementGroupApi} * * @author Adrian Cole */ -@Test(groups = "live", singleThreaded = true, testName = "PlacementGroupClientLiveTest") -public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveTest { +@Test(groups = "live", singleThreaded = true, testName = "PlacementGroupApiLiveTest") +public class PlacementGroupApiLiveTest extends BaseComputeServiceContextLiveTest { ArrayList supportedRegions = newArrayList(Region.US_EAST_1, Region.US_WEST_2, Region.EU_WEST_1); - public PlacementGroupClientLiveTest() { + public PlacementGroupApiLiveTest() { provider = "aws-ec2"; } - private AWSEC2Client client; + private AWSEC2Api client; private Predicate availableTester; private Predicate deletedTester; private PlacementGroup group; @@ -78,7 +78,7 @@ public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveT @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi(); + client = view.unwrapApi(AWSEC2Api.class);; availableTester = retry(new PlacementGroupAvailable(client), 60, 1, SECONDS); deletedTester = retry(new PlacementGroupDeleted(client), 60, 1, SECONDS); } @@ -86,12 +86,12 @@ public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveT @Test void testDescribe() { for (String region : supportedRegions) { - SortedSet allResults = newTreeSet(client.getPlacementGroupServices() + SortedSet allResults = newTreeSet(client.getPlacementGroupApi().get() .describePlacementGroupsInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { PlacementGroup group = allResults.last(); - SortedSet result = newTreeSet(client.getPlacementGroupServices() + SortedSet result = newTreeSet(client.getPlacementGroupApi().get() .describePlacementGroupsInRegion(region, group.getName())); assertNotNull(result); PlacementGroup compare = result.last(); @@ -99,10 +99,10 @@ public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveT } } - for (String region : client.getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { + for (String region : client.getAvailabilityZoneAndRegionApi().get().describeRegions().keySet()) { if (!supportedRegions.contains(region)) try { - client.getPlacementGroupServices().describePlacementGroupsInRegion(region); + client.getPlacementGroupApi().get().describePlacementGroupsInRegion(region); fail("should be unsupported for region: " + region); } catch (UnsupportedOperationException e) { } @@ -114,8 +114,8 @@ public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveT String groupName = PREFIX + "1"; for (String region : supportedRegions) { - client.getPlacementGroupServices().deletePlacementGroupInRegion(region, groupName); - client.getPlacementGroupServices().createPlacementGroupInRegion(region, groupName); + client.getPlacementGroupApi().get().deletePlacementGroupInRegion(region, groupName); + client.getPlacementGroupApi().get().createPlacementGroupInRegion(region, groupName); verifyPlacementGroup(region, groupName); } @@ -123,7 +123,7 @@ public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveT private void verifyPlacementGroup(String region, String groupName) { assert availableTester.apply(new PlacementGroup(region, groupName, "cluster", State.PENDING)) : group; - Set oneResult = client.getPlacementGroupServices().describePlacementGroupsInRegion(region, + Set oneResult = client.getPlacementGroupApi().get().describePlacementGroupsInRegion(region, groupName); assertNotNull(oneResult); assertEquals(oneResult.size(), 1); @@ -148,13 +148,13 @@ public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveT String group = PREFIX + "cccluster"; view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); // TODO make this not lookup an explicit region - client.getPlacementGroupServices().deletePlacementGroupInRegion(null, "jclouds#" + group + "#us-east-1"); + client.getPlacementGroupApi().get().deletePlacementGroupInRegion(null, "jclouds#" + group + "#us-east-1"); try { Set nodes = view.getComputeService().createNodesInGroup(group, 1, template); NodeMetadata node = getOnlyElement(nodes); - getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(null, + getOnlyElement(getOnlyElement(client.getInstanceApi().get().describeInstancesInRegion(null, node.getProviderId()))); } catch (RunNodesException e) { @@ -171,7 +171,7 @@ public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveT @AfterClass(groups = { "integration", "live" }) protected void tearDownContext() { if (group != null) { - client.getPlacementGroupServices().deletePlacementGroupInRegion(group.getRegion(), group.getName()); + client.getPlacementGroupApi().get().deletePlacementGroupInRegion(group.getRegion(), group.getName()); assert deletedTester.apply(group) : group; } super.tearDownContext(); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java similarity index 88% rename from providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupAsyncClientTest.java rename to providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java index 4f3eb18e79..69eb068ce6 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static org.jclouds.reflect.Reflection2.method; @@ -32,16 +32,16 @@ import org.testng.annotations.Test; import com.google.common.collect.Lists; import com.google.common.reflect.Invokable; /** - * Tests behavior of {@code PlacementGroupAsyncClient} + * Tests behavior of {@code PlacementGroupApi} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "PlacementGroupAsyncClientTest") -public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest { +@Test(groups = "unit", testName = "PlacementGroupApiTest") +public class PlacementGroupApiTest extends BaseAWSEC2ApiTest { public void testDeletePlacementGroup() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(PlacementGroupAsyncClient.class, "deletePlacementGroupInRegion", String.class, + Invokable method = method(PlacementGroupApi.class, "deletePlacementGroupInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name")); @@ -65,7 +65,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(PlacementGroupAsyncClient.class, "createPlacementGroupInRegion", String.class, + Invokable method = method(PlacementGroupApi.class, "createPlacementGroupInRegion", String.class, String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name", "cluster")); @@ -84,7 +84,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(PlacementGroupAsyncClient.class, "createPlacementGroupInRegion", String.class, + Invokable method = method(PlacementGroupApi.class, "createPlacementGroupInRegion", String.class, String.class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "name")); @@ -101,7 +101,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(PlacementGroupAsyncClient.class, "describePlacementGroupsInRegion", String.class, + Invokable method = method(PlacementGroupApi.class, "describePlacementGroupsInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); @@ -118,7 +118,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(PlacementGroupAsyncClient.class, "describePlacementGroupsInRegion", String.class, + Invokable method = method(PlacementGroupApi.class, "describePlacementGroupsInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "1", "2")); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java similarity index 84% rename from providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java rename to providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java index 3def6f6a40..522b577ef4 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static com.google.common.base.Predicates.in; import static com.google.common.collect.Iterables.getOnlyElement; @@ -32,7 +32,7 @@ import java.util.concurrent.TimeUnit; import org.jclouds.aws.domain.Region; import org.jclouds.aws.ec2.AWSEC2ApiMetadata; -import org.jclouds.aws.ec2.AWSEC2Client; +import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.LaunchSpecification; import org.jclouds.aws.ec2.domain.Spot; @@ -49,18 +49,18 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedSet; /** - * Tests behavior of {@code SpotInstanceClient} + * Tests behavior of {@code SpotInstanceApi} * * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTest { - public SpotInstanceClientLiveTest() { +public class SpotInstanceApiLiveTest extends BaseComputeServiceContextLiveTest { + public SpotInstanceApiLiveTest() { provider = "aws-ec2"; } private static final int SPOT_DELAY_SECONDS = 600; - private AWSEC2Client client; + private AWSEC2Api client; private Predicate activeTester; private Set requests; private AWSRunningInstance instance; @@ -70,19 +70,19 @@ public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTe @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = view.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi(); + client = view.unwrapApi(AWSEC2Api.class); activeTester = retry(new SpotInstanceRequestActive(client), SPOT_DELAY_SECONDS, 1, 1, SECONDS); } @Test void testDescribeSpotRequestsInRegion() { for (String region : Region.DEFAULT_REGIONS) { - SortedSet allResults = ImmutableSortedSet.copyOf(client.getSpotInstanceServices() + SortedSet allResults = ImmutableSortedSet.copyOf(client.getSpotInstanceApi().get() .describeSpotInstanceRequestsInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { SpotInstanceRequest request = allResults.last(); - SortedSet result = ImmutableSortedSet.copyOf(client.getSpotInstanceServices() + SortedSet result = ImmutableSortedSet.copyOf(client.getSpotInstanceApi().get() .describeSpotInstanceRequestsInRegion(region, request.getId())); assertNotNull(result); SpotInstanceRequest compare = result.last(); @@ -95,7 +95,7 @@ public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTe @Test void testDescribeSpotPriceHistoryInRegion() { for (String region : Region.DEFAULT_REGIONS) { - Set spots = client.getSpotInstanceServices().describeSpotPriceHistoryInRegion(region, from(new Date())); + Set spots = client.getSpotInstanceApi().get().describeSpotPriceHistoryInRegion(region, from(new Date())); assertNotNull(spots); assert spots.size() > 0; for (Spot spot : spots) { @@ -119,14 +119,14 @@ public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTe void testCreateSpotInstance() { String launchGroup = PREFIX + "1"; for (String region : Region.DEFAULT_REGIONS) - for (SpotInstanceRequest request : client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion( + for (SpotInstanceRequest request : client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion( region)) if (launchGroup.equals(request.getLaunchGroup())) - client.getSpotInstanceServices().cancelSpotInstanceRequestsInRegion(region, request.getId()); + client.getSpotInstanceApi().get().cancelSpotInstanceRequestsInRegion(region, request.getId()); start = System.currentTimeMillis(); - requests = client.getSpotInstanceServices().requestSpotInstancesInRegion( + requests = client.getSpotInstanceApi().get().requestSpotInstancesInRegion( "sa-east-1", 0.09f, 1, @@ -148,13 +148,13 @@ public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTe System.out.println(System.currentTimeMillis() - start); spot = refresh(request); assert spot.getInstanceId() != null : spot; - instance = getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(spot.getRegion(), + instance = getOnlyElement(getOnlyElement(client.getInstanceApi().get().describeInstancesInRegion(spot.getRegion(), spot.getInstanceId()))); assertEquals(instance.getSpotInstanceRequestId(), spot.getId()); } public SpotInstanceRequest refresh(SpotInstanceRequest request) { - return getOnlyElement(client.getSpotInstanceServices().describeSpotInstanceRequestsInRegion(request.getRegion(), + return getOnlyElement(client.getSpotInstanceApi().get().describeSpotInstanceRequestsInRegion(request.getRegion(), request.getId())); } @@ -165,11 +165,11 @@ public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTe protected void tearDownContext() { if (requests != null) { for (SpotInstanceRequest request : requests) - client.getSpotInstanceServices().cancelSpotInstanceRequestsInRegion(request.getRegion(), request.getId()); + client.getSpotInstanceApi().get().cancelSpotInstanceRequestsInRegion(request.getRegion(), request.getId()); // assert deletedTester.apply(request) : request; } if (instance != null) { - client.getInstanceServices().terminateInstancesInRegion(instance.getRegion(), instance.getId()); + client.getInstanceApi().get().terminateInstancesInRegion(instance.getRegion(), instance.getId()); } super.tearDownContext(); } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java similarity index 87% rename from providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java rename to providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java index ec7751aedd..f8276e3016 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceAsyncClientTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.aws.ec2.services; +package org.jclouds.aws.ec2.features; import static org.jclouds.reflect.Reflection2.method; @@ -33,16 +33,16 @@ import org.testng.annotations.Test; import com.google.common.collect.Lists; import com.google.common.reflect.Invokable; /** - * Tests behavior of {@code SpotInstanceAsyncClient} + * Tests behavior of {@code SpotInstanceApi} * * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "SpotInstanceAsyncClientTest") -public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest { +@Test(groups = "unit", testName = "SpotInstanceApiTest") +public class SpotInstanceApiTest extends BaseAWSEC2ApiTest { public void testCancelSpotInstanceRequests() throws SecurityException, NoSuchMethodException, IOException { - Invokable method = method(SpotInstanceAsyncClient.class, "cancelSpotInstanceRequestsInRegion", String.class, + Invokable method = method(SpotInstanceApi.class, "cancelSpotInstanceRequestsInRegion", String.class, String[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "id")); @@ -59,7 +59,7 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(SpotInstanceAsyncClient.class, "describeSpotPriceHistoryInRegion", String.class, + Invokable method = method(SpotInstanceApi.class, "describeSpotPriceHistoryInRegion", String.class, DescribeSpotPriceHistoryOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList((String) null)); @@ -79,7 +79,7 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest method = method(SpotInstanceAsyncClient.class, "describeSpotPriceHistoryInRegion", String.class, + Invokable method = method(SpotInstanceApi.class, "describeSpotPriceHistoryInRegion", String.class, DescribeSpotPriceHistoryOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, DescribeSpotPriceHistoryOptions.Builder.from(from) .to(to).productDescription("description").instanceType("m1.small"))); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java index de202ce25a..c16d8356f3 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java @@ -18,8 +18,8 @@ package org.jclouds.aws.ec2.features; import static org.jclouds.ec2.domain.Tag.ResourceType.SECURITY_GROUP; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.services.AWSSecurityGroupClient; +import org.jclouds.aws.ec2.AWSEC2Api; +import org.jclouds.aws.ec2.features.AWSSecurityGroupApi; import org.jclouds.ec2.features.internal.BaseTagApiLiveTest; import org.testng.annotations.Test; @@ -51,7 +51,7 @@ public class TagSecurityGroupLiveTest extends BaseTagApiLiveTest { securityGroupApi().deleteSecurityGroupInRegionById(null, resource.id); } - private AWSSecurityGroupClient securityGroupApi() { - return AWSEC2Client.class.cast(api).getSecurityGroupServices(); + private AWSSecurityGroupApi securityGroupApi() { + return AWSEC2Api.class.cast(api).getSecurityGroupApi().get(); } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java index a1204e6235..cd6b3b75d0 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java @@ -23,11 +23,12 @@ import static org.easymock.EasyMock.verify; import static org.jclouds.ssh.SshKeys.fingerprintPublicKey; import static org.testng.Assert.assertEquals; -import org.jclouds.aws.ec2.AWSEC2Client; -import org.jclouds.aws.ec2.services.AWSKeyPairClient; +import org.jclouds.aws.ec2.AWSEC2Api; +import org.jclouds.aws.ec2.features.AWSKeyPairApi; import org.jclouds.ec2.domain.KeyPair; import org.testng.annotations.Test; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; /** @@ -44,37 +45,37 @@ public class ImportOrReturnExistingKeypairTest { @Test public void testApply() { - AWSEC2Client client = createMock(AWSEC2Client.class); - AWSKeyPairClient keyClient = createMock(AWSKeyPairClient.class); + AWSEC2Api client = createMock(AWSEC2Api.class); + AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class); - expect(client.getKeyPairServices()).andReturn(keyClient).atLeastOnce(); + expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce(); - expect(keyClient.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andReturn(pair); + expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andReturn(pair); replay(client); - replay(keyClient); + replay(keyApi); ImportOrReturnExistingKeypair parser = new ImportOrReturnExistingKeypair(client); assertEquals(parser.importOrReturnExistingKeypair("region", "group", PUBLIC_KEY), pairWithFingerprint); verify(client); - verify(keyClient); + verify(keyApi); } @Test public void testApplyWithIllegalStateExceptionReturnsExistingKey() { - AWSEC2Client client = createMock(AWSEC2Client.class); - AWSKeyPairClient keyClient = createMock(AWSKeyPairClient.class); + AWSEC2Api client = createMock(AWSEC2Api.class); + AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class); - expect(client.getKeyPairServices()).andReturn(keyClient).atLeastOnce(); + expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce(); - expect(keyClient.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow( + expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow( new IllegalStateException()); - expect(keyClient.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.of(pair)); + expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet.of(pair)); replay(client); - replay(keyClient); + replay(keyApi); ImportOrReturnExistingKeypair parser = new ImportOrReturnExistingKeypair(client); @@ -82,33 +83,33 @@ public class ImportOrReturnExistingKeypairTest { assertEquals(parser.importOrReturnExistingKeypair("region", "group", PUBLIC_KEY), pairWithFingerprint); verify(client); - verify(keyClient); + verify(keyApi); } @Test public void testApplyWithIllegalStateExceptionRetriesWhenExistingKeyNotFound() { - AWSEC2Client client = createMock(AWSEC2Client.class); - AWSKeyPairClient keyClient = createMock(AWSKeyPairClient.class); + AWSEC2Api client = createMock(AWSEC2Api.class); + AWSKeyPairApi keyApi = createMock(AWSKeyPairApi.class); - expect(client.getKeyPairServices()).andReturn(keyClient).atLeastOnce(); + expect(client.getKeyPairApi()).andReturn((Optional) Optional.of(keyApi)).atLeastOnce(); - expect(keyClient.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow( + expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow( new IllegalStateException()); - expect(keyClient.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet. of()); - expect(keyClient.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow( + expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet. of()); + expect(keyApi.importKeyPairInRegion("region", "jclouds#group", PUBLIC_KEY)).andThrow( new IllegalStateException()); - expect(keyClient.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet. of(pair)); + expect(keyApi.describeKeyPairsInRegion("region", "jclouds#group")).andReturn(ImmutableSet. of(pair)); replay(client); - replay(keyClient); + replay(keyApi); ImportOrReturnExistingKeypair parser = new ImportOrReturnExistingKeypair(client); assertEquals(parser.importOrReturnExistingKeypair("region", "group", PUBLIC_KEY), pairWithFingerprint); verify(client); - verify(keyClient); + verify(keyApi); } }