From 764e0907f70761835ca5044d918cda1b84aa5a90 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 1 Apr 2012 18:43:31 -0700 Subject: [PATCH] Issue 657:ApiMetadata --- .../org/jclouds/atmos/AtmosApiMetadata.java | 67 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../jclouds/atmos/AtmosApiMetadataTest.java | 35 ++ .../atmos/ProvidersInPropertiesTest.java | 47 --- .../org/jclouds/byon/BYONApiMetadata.java | 67 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../org/jclouds/byon/BYONApiMetadataTest.java | 35 ++ .../cloudfiles/CloudFilesApiMetadata.java | 68 ++++ .../CloudFilesProviderMetadata.java | 69 ---- .../services/org.jclouds.apis.ApiMetadata | 1 + .../cloudfiles/CloudFilesApiMetadataTest.java | 35 ++ .../CloudLoadBalancersApiMetadata.java | 68 ++++ .../CloudLoadBalancersProviderMetadata.java | 69 ---- .../services/org.jclouds.apis.ApiMetadata | 1 + .../CloudLoadBalancersApiMetadataTest.java | 35 ++ .../cloudservers/CloudServersApiMetadata.java | 68 ++++ .../CloudServersProviderMetadata.java | 69 ---- .../services/org.jclouds.apis.ApiMetadata | 1 + .../CloudServersApiMetadataTest.java | 21 +- .../cloudsigma/CloudSigmaApiMetadata.java | 68 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../cloudsigma/CloudSigmaApiMetadataTest.java | 35 ++ .../cloudsigma/ProvidersInPropertiesTest.java | 47 --- .../cloudstack/CloudStackApiMetadata.java | 68 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../cloudstack/CloudStackApiMetadataTest.java | 35 ++ .../cloudwatch/CloudWatchApiMetadata.java | 67 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../cloudwatch/CloudWatchApiMetadataTest.java | 35 ++ .../deltacloud/DeltacloudApiMetadata.java | 68 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../deltacloud/DeltacloudApiMetadataTest.java | 35 ++ .../java/org/jclouds/ec2/EC2ApiMetadata.java | 75 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../org/jclouds/ec2/EC2ApiMetadataTest.java | 35 ++ .../elasticstack/ElasticStackApiMetadata.java | 68 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../ElasticStackApiMetadataTest.java | 21 +- .../ProvidersInPropertiesTest.java | 53 --- .../eucalyptus/EucalyptusApiMetadata.java | 60 +++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../eucalyptus/EucalyptusApiMetadataTest.java | 35 ++ .../filesystem/FilesystemApiMetadata.java | 67 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../filesystem/FilesystemApiMetadataTest.java | 35 ++ .../openstack/nova/NovaApiMetadata.java | 67 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../openstack/nova/NovaApiMetadataTest.java | 35 ++ .../openstack/nova/v1_1/NovaApiMetadata.java | 58 +++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../nova/v1_1/NovaApiMetadataTest.java | 17 + .../java/org/jclouds/s3/S3ApiMetadata.java | 75 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../org/jclouds/s3/S3ApiMetadataTest.java | 35 ++ .../openstack/swift/SwiftApiMetadata.java | 49 +++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../openstack/swift/SwiftApiMetadataTest.java | 17 + .../org/jclouds/vcloud/VCloudApiMetadata.java | 67 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../vcloud/ProvidersInPropertiesTest.java | 47 --- .../jclouds/vcloud/VCloudApiMetadataTest.java | 21 +- .../org/jclouds/walrus/WalrusApiMetadata.java | 60 +++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../jclouds/walrus/WalrusApiMetadataTest.java | 35 ++ .../blobstore/TransientApiMetadata.java | 67 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../blobstore/TransientApiMetadataTest.java | 20 +- .../jclouds/compute/stub/StubApiMetadata.java | 67 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../compute/stub/StubApiMetadataTest.java | 35 ++ .../java/org/jclouds/apis/ApiMetadata.java | 119 ++++++ .../java/org/jclouds/apis/ApiPredicates.java | 102 +++++ .../main/java/org/jclouds/apis/ApiType.java | 46 +++ core/src/main/java/org/jclouds/apis/Apis.java | 139 +++++++ .../org/jclouds/apis/BaseApiMetadata.java | 211 ++++++++++ .../providers/BaseProviderMetadata.java | 376 ++++++++++++------ .../jclouds/providers/ProviderMetadata.java | 161 ++++++-- .../jclouds/providers/ProviderPredicates.java | 85 +++- .../java/org/jclouds/providers/Providers.java | 107 +++-- .../test/java/org/jclouds/apis/ApisTest.java | 94 +++++ .../org/jclouds/apis/BaseApiMetadataTest.java | 62 +++ .../apis/JcloudsTestBlobStoreApiMetadata.java | 63 +++ .../apis/JcloudsTestComputeApiMetadata.java | 63 +++ ...loudsTestYetAnotherComputeApiMetadata.java | 64 +++ .../providers/BaseProviderMetadataTest.java | 25 +- .../JcloudsTestBlobStoreProviderMetadata.java | 89 ++--- .../JcloudsTestComputeProviderMetadata.java | 89 ++--- ...TestYetAnotherComputeProviderMetadata.java | 89 ++--- .../org/jclouds/providers/ProvidersTest.java | 87 +++- .../services/org.jclouds.apis.ApiMetadata | 3 + .../aws/elb/AWSELBProviderMetadata.java | 97 ++--- .../jclouds/aws/elb/AWSELBProviderTest.java | 4 +- .../java/org/jclouds/elb/ELBApiMetadata.java | 67 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../org/jclouds/elb/ELBApiMetadataTest.java | 35 ++ .../org/jclouds/glesys/GleSYSApiMetadata.java | 68 ++++ .../glesys/GleSYSProviderMetadata.java | 98 ++--- .../jclouds/glesys/GleSYSProviderTest.java | 3 +- .../vpdc/SavvisSymphonyVPDCApiMetadata.java | 50 +++ .../SavvisSymphonyVPDCProviderMetadata.java | 160 +++----- .../vpdc/SavvisSymphonyVPDCProviderTest.java | 6 +- .../v1_5/VCloudDirectorApiMetadata.java | 67 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../v1_5/VCloudDirectorApiMetadataTest.java | 35 ++ .../virtualbox/VirtualBoxApiMetadata.java | 67 ++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../virtualbox/VirtualBoxApiMetadataTest.java | 35 ++ .../AWSCloudWatchProviderMetadata.java | 97 ++--- .../cloudwatch/AWSCloudWatchProviderTest.java | 4 +- .../jclouds/aws/ec2/AWSEC2ApiMetadata.java | 60 +++ .../aws/ec2/AWSEC2ProviderMetadata.java | 97 ++--- .../jclouds/aws/ec2/AWSEC2ProviderTest.java | 3 +- .../org/jclouds/aws/s3/AWSS3ApiMetadata.java | 60 +++ .../jclouds/aws/s3/AWSS3ProviderMetadata.java | 98 ++--- .../org/jclouds/aws/s3/AWSS3ProviderTest.java | 3 +- .../azureblob/AzureBlobApiMetadata.java | 68 ++++ .../azureblob/AzureBlobProviderMetadata.java | 100 ++--- .../azureblob/AzureBlobProviderTest.java | 3 +- .../BluelockVCloudZone01ProviderMetadata.java | 98 ++--- .../BluelockVCloudZone01ProviderTest.java | 4 +- .../CloudFilesUKProviderMetadata.java | 70 ++-- .../cloudfiles/CloudFilesUKProviderTest.java | 4 +- .../CloudFilesUSProviderMetadata.java | 71 ++-- .../cloudfiles/CloudFilesUSProviderTest.java | 4 +- .../CloudLoadBalancersUKProviderMetadata.java | 71 ++-- .../CloudLoadBalancersUKProviderTest.java | 4 +- .../CloudLoadBalancersUSProviderMetadata.java | 73 ++-- .../CloudLoadBalancersUSProviderTest.java | 4 +- .../CloudOneStorageProviderMetadata.java | 90 ++--- .../CloudOneStorageProviderTest.java | 4 +- .../CloudServersUKProviderMetadata.java | 70 ++-- .../CloudServersUKProviderTest.java | 4 +- .../CloudServersUSProviderMetadata.java | 71 ++-- .../CloudServersUSProviderTest.java | 4 +- .../CloudSigmaLasVegasProviderMetadata.java | 99 ++--- .../CloudSigmaLasVegasProviderTest.java | 3 +- .../CloudSigmaZurichProviderMetadata.java | 97 ++--- .../CloudSigmaZurichProviderTest.java | 3 +- ...cHostsPeer1LosAngelesProviderMetadata.java | 100 ++--- ...asticHostsPeer1LosAngelesProviderTest.java | 4 +- ...HostsBlueSquareLondonProviderMetadata.java | 97 ++--- ...sticHostsBlueSquareLondonProviderTest.java | 4 +- ...asticHostsPeer1LondonProviderMetadata.java | 97 ++--- .../ElasticHostsPeer1LondonProviderTest.java | 4 +- ...cHostsPeer1SanAntonioProviderMetadata.java | 100 ++--- ...asticHostsPeer1SanAntonioProviderTest.java | 4 +- ...sticHostsPeer1TorontoProviderMetadata.java | 98 ++--- .../ElasticHostsPeer1TorontoProviderTest.java | 4 +- ...lyptusPartnerCloudEC2ProviderMetadata.java | 98 ++--- ...EucalyptusPartnerCloudEC2ProviderTest.java | 4 +- ...alyptusPartnerCloudS3ProviderMetadata.java | 98 ++--- .../EucalyptusPartnerCloudS3ProviderTest.java | 4 +- ...Go2CloudJohannesburg1ProviderMetadata.java | 89 ++--- .../Go2CloudJohannesburg1ProviderTest.java | 4 +- .../org/jclouds/gogrid/GoGridApiMetadata.java | 68 ++++ .../gogrid/GoGridProviderMetadata.java | 100 ++--- .../jclouds/gogrid/GoGridProviderTest.java | 3 +- ...ouseDataElementVCloudProviderMetadata.java | 98 ++--- ...eenHouseDataElementVCloudProviderTest.java | 4 +- .../compute/HPCloudComputeApiMetadata.java | 60 +++ .../HPCloudComputeProviderMetadata.java | 99 ++--- .../compute/HPCloudComputeProviderTest.java | 3 +- .../HPCloudObjectStorageApiMetadata.java | 49 +++ .../HPCloudObjectStorageProviderMetadata.java | 100 ++--- .../HPCloudObjectStorageProviderTest.java | 3 +- .../NinefoldComputeProviderMetadata.java | 97 ++--- .../compute/NinefoldComputeProviderTest.java | 4 +- .../NinefoldStorageProviderMetadata.java | 90 ++--- .../storage/NinefoldStorageProviderTest.java | 4 +- .../OpenHostingEast1ProviderMetadata.java | 94 ++--- .../OpenHostingEast1ProviderTest.java | 4 +- ...enHostingEast1TemplateBuilderLiveTest.java | 2 +- .../miro/RimuHostingApiMetadata.java | 67 ++++ .../miro/RimuHostingProviderMetadata.java | 97 ++--- .../miro/ProvidersInPropertiesTest.java | 47 --- .../miro/RimuHostingProviderTest.java | 3 +- .../ServerloveManchesterProviderMetadata.java | 98 ++--- .../ServerloveManchesterProviderTest.java | 4 +- .../SkaliCloudMalaysiaProviderMetadata.java | 99 ++--- .../SkaliCloudMalaysiaProviderTest.java | 4 +- .../slicehost/SlicehostApiMetadata.java | 67 ++++ .../slicehost/SlicehostProviderMetadata.java | 99 ++--- .../slicehost/SlicehostProviderTest.java | 3 +- .../softlayer/SoftLayerApiMetadata.java | 68 ++++ .../softlayer/SoftLayerProviderMetadata.java | 98 ++--- .../softlayer/SoftLayerProviderTest.java | 3 +- ...tratoGenVCloudMyCloudProviderMetadata.java | 98 ++--- .../StratoGenVCloudMyCloudProviderTest.java | 4 +- .../SynapticStorageProviderMetadata.java | 90 ++--- .../storage/SynapticStorageProviderTest.java | 4 +- .../ecloud/TerremarkECloudApiMetadata.java | 50 +++ .../TerremarkECloudProviderMetadata.java | 91 ++--- .../ecloud/TerremarkECloudProviderTest.java | 3 +- .../TerremarkVCloudExpressApiMetadata.java | 50 +++ ...erremarkVCloudExpressProviderMetadata.java | 90 ++--- .../TerremarkVCloudExpressProviderTest.java | 3 +- .../nova/TryStackNovaProviderMetadata.java | 99 ++--- .../nova/TryStackNovaProviderTest.java | 4 +- .../sdn/ProvidersInPropertiesTest.java | 47 --- .../mezeo/pcs/ProvidersInPropertiesTest.java | 47 --- .../smartcloud/ProvidersInPropertiesTest.java | 47 --- 201 files changed, 5898 insertions(+), 4040 deletions(-) create mode 100644 apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java create mode 100644 apis/atmos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/atmos/src/test/java/org/jclouds/atmos/AtmosApiMetadataTest.java delete mode 100644 apis/atmos/src/test/java/org/jclouds/atmos/ProvidersInPropertiesTest.java create mode 100644 apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java create mode 100644 apis/byon/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/byon/src/test/java/org/jclouds/byon/BYONApiMetadataTest.java create mode 100644 apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java delete mode 100644 apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesProviderMetadata.java create mode 100644 apis/cloudfiles/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java create mode 100644 apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java delete mode 100644 apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersProviderMetadata.java create mode 100644 apis/cloudloadbalancers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadataTest.java create mode 100644 apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java delete mode 100644 apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersProviderMetadata.java create mode 100644 apis/cloudservers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata rename sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/ProvidersInPropertiesTest.java => apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java (69%) create mode 100644 apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java create mode 100644 apis/cloudsigma/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java delete mode 100644 apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/ProvidersInPropertiesTest.java create mode 100644 apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java create mode 100644 apis/cloudstack/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/cloudstack/src/test/java/org/jclouds/cloudstack/CloudStackApiMetadataTest.java create mode 100644 apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java create mode 100644 apis/cloudwatch/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java create mode 100644 apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java create mode 100644 apis/deltacloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudApiMetadataTest.java create mode 100644 apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java create mode 100644 apis/ec2/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java create mode 100644 apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java create mode 100644 apis/elasticstack/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata rename providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/ProvidersInPropertiesTest.java => apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiMetadataTest.java (69%) delete mode 100644 apis/elasticstack/src/test/java/org/jclouds/elasticstack/ProvidersInPropertiesTest.java create mode 100644 apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java create mode 100644 apis/eucalyptus/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/EucalyptusApiMetadataTest.java create mode 100644 apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java create mode 100644 apis/filesystem/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemApiMetadataTest.java create mode 100644 apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java create mode 100644 apis/nova/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/nova/src/test/java/org/jclouds/openstack/nova/NovaApiMetadataTest.java create mode 100644 apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java create mode 100644 apis/openstack-nova/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadataTest.java create mode 100644 apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java create mode 100644 apis/s3/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java create mode 100644 apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java create mode 100644 apis/swift/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java create mode 100644 apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java create mode 100644 apis/vcloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata delete mode 100644 apis/vcloud/src/test/java/org/jclouds/vcloud/ProvidersInPropertiesTest.java rename providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/ProvidersInPropertiesTest.java => apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java (69%) create mode 100644 apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java create mode 100644 apis/walrus/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 apis/walrus/src/test/java/org/jclouds/walrus/WalrusApiMetadataTest.java create mode 100644 blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java create mode 100644 blobstore/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata rename demos/getpath/src/test/java/org/jclouds/blobstore/ProvidersInPropertiesTest.java => blobstore/src/test/java/org/jclouds/blobstore/TransientApiMetadataTest.java (64%) create mode 100644 compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java create mode 100644 compute/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 compute/src/test/java/org/jclouds/compute/stub/StubApiMetadataTest.java create mode 100644 core/src/main/java/org/jclouds/apis/ApiMetadata.java create mode 100644 core/src/main/java/org/jclouds/apis/ApiPredicates.java create mode 100644 core/src/main/java/org/jclouds/apis/ApiType.java create mode 100644 core/src/main/java/org/jclouds/apis/Apis.java create mode 100644 core/src/main/java/org/jclouds/apis/BaseApiMetadata.java create mode 100644 core/src/test/java/org/jclouds/apis/ApisTest.java create mode 100644 core/src/test/java/org/jclouds/apis/BaseApiMetadataTest.java create mode 100644 core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java create mode 100644 core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java create mode 100644 core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java create mode 100644 core/src/test/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java create mode 100644 labs/elb/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java create mode 100644 labs/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java create mode 100644 labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCApiMetadata.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java create mode 100644 labs/vcloud-director/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java create mode 100644 labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java create mode 100644 labs/virtualbox/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java create mode 100644 providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java create mode 100644 providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ApiMetadata.java create mode 100644 providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java create mode 100644 providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java create mode 100644 providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeApiMetadata.java create mode 100644 providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java create mode 100644 providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java delete mode 100644 providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/ProvidersInPropertiesTest.java create mode 100644 providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java create mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java create mode 100644 providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java create mode 100644 providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java delete mode 100644 sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/ProvidersInPropertiesTest.java delete mode 100644 sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/ProvidersInPropertiesTest.java delete mode 100644 sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/ProvidersInPropertiesTest.java diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java new file mode 100644 index 0000000000..20fe7cd5e3 --- /dev/null +++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java @@ -0,0 +1,67 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.atmos; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for EMC's Atmos API. + * + * @author Adrian Cole + */ +public class AtmosApiMetadata extends BaseApiMetadata { + + public AtmosApiMetadata() { + this(builder() + .id("atmos") + .type(ApiType.BLOBSTORE) + .name("EMC's Atmos API") + .identityName("Subtenant ID (UID)") + .credentialName("Shared Secret") + .documentation(URI.create("https://community.emc.com/docs/DOC-10508"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected AtmosApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public AtmosApiMetadata build() { + return new AtmosApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/apis/atmos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/atmos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..3cc11413c4 --- /dev/null +++ b/apis/atmos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.atmos.AtmosApiMetadata \ No newline at end of file diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosApiMetadataTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosApiMetadataTest.java new file mode 100644 index 0000000000..9f5f407922 --- /dev/null +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.atmos; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "AtmosApiMetadataTest") +public class AtmosApiMetadataTest extends BaseApiMetadataTest { + + public AtmosApiMetadataTest() { + super(new AtmosApiMetadata(), ApiType.BLOBSTORE); + } +} diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/ProvidersInPropertiesTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/ProvidersInPropertiesTest.java deleted file mode 100644 index 6f21731226..0000000000 --- a/apis/atmos/src/test/java/org/jclouds/atmos/ProvidersInPropertiesTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.atmos; - -import org.jclouds.blobstore.util.BlobStoreUtils; -import org.jclouds.rest.Providers; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - * - */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "atmos") : providers; - } - - @Test - public void testSupportedBlobStoreProviders() { - Iterable providers = BlobStoreUtils.getSupportedProviders(); - assert Iterables.contains(providers, "atmos") : providers; - } - -} diff --git a/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java b/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java new file mode 100644 index 0000000000..b818a6ef33 --- /dev/null +++ b/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java @@ -0,0 +1,67 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.byon; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for jclouds BYON API + * + * @author Adrian Cole + */ +public class BYONApiMetadata extends BaseApiMetadata { + + public BYONApiMetadata() { + this(builder() + .id("byon") + .type(ApiType.COMPUTE) + .name("Bring Your Own Node (BYON) API") + .identityName("Unused") + .documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected BYONApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public BYONApiMetadata build() { + return new BYONApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/apis/byon/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/byon/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..28169081a1 --- /dev/null +++ b/apis/byon/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.byon.BYONApiMetadata \ No newline at end of file diff --git a/apis/byon/src/test/java/org/jclouds/byon/BYONApiMetadataTest.java b/apis/byon/src/test/java/org/jclouds/byon/BYONApiMetadataTest.java new file mode 100644 index 0000000000..6265ff3c0e --- /dev/null +++ b/apis/byon/src/test/java/org/jclouds/byon/BYONApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.byon; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "BYONApiMetadataTest") +public class BYONApiMetadataTest extends BaseApiMetadataTest { + + public BYONApiMetadataTest() { + super(new BYONApiMetadata(), ApiType.COMPUTE); + } +} diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java new file mode 100644 index 0000000000..654c040c04 --- /dev/null +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.cloudfiles; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for Rackspace Cloud Files API + * + * @author Dan Lo Bianco + */ +public class CloudFilesApiMetadata extends BaseApiMetadata { + + public CloudFilesApiMetadata() { + this(builder() + .id("cloudfiles") + .type(ApiType.BLOBSTORE) + .name("Rackspace Cloud Files API") + .identityName("Username") + .credentialName("API Key") + .documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudFilesApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public CloudFilesApiMetadata build() { + return new CloudFilesApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesProviderMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesProviderMetadata.java deleted file mode 100644 index 6fcc489901..0000000000 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesProviderMetadata.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudfiles; - -import java.net.URI; - -import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -/** - * Common implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Files - * - * @author Dan Lo Bianco - */ -public abstract class CloudFilesProviderMetadata extends BaseProviderMetadata { - - public CloudFilesProviderMetadata() { - super(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.BLOBSTORE_TYPE; - } - - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Username"; - } - - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "API Key"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html"); - } - -} \ No newline at end of file diff --git a/apis/cloudfiles/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/cloudfiles/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..4ae761171e --- /dev/null +++ b/apis/cloudfiles/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.cloudfiles.CloudFilesApiMetadata \ No newline at end of file diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java new file mode 100644 index 0000000000..2672d7e980 --- /dev/null +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.cloudfiles; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "CloudFilesApiMetadataTest") +public class CloudFilesApiMetadataTest extends BaseApiMetadataTest { + + public CloudFilesApiMetadataTest() { + super(new CloudFilesApiMetadata(), ApiType.BLOBSTORE); + } +} diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java new file mode 100644 index 0000000000..4885acb21d --- /dev/null +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.cloudloadbalancers; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for Rackspace Cloud Load Balancers API + * + * @author Dan Lo Bianco + */ +public class CloudLoadBalancersApiMetadata extends BaseApiMetadata { + + public CloudLoadBalancersApiMetadata() { + this(builder() + .id("cloudloadbalancers") + .type(ApiType.LOADBALANCER) + .name("Rackspace Cloud Load Balancers API") + .identityName("Username") + .credentialName("API Key") + .documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudLoadBalancersApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public CloudLoadBalancersApiMetadata build() { + return new CloudLoadBalancersApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersProviderMetadata.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersProviderMetadata.java deleted file mode 100644 index 700cb849cc..0000000000 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersProviderMetadata.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudloadbalancers; - -import java.net.URI; - -import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -/** - * Common implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud LoadBalancers. - * - * @author Dan Lo Bianco - */ -public abstract class CloudLoadBalancersProviderMetadata extends BaseProviderMetadata { - - public CloudLoadBalancersProviderMetadata() { - super(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.LOADBALANCER_TYPE; - } - - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Username"; - } - - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "API Key"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html"); - } - -} \ No newline at end of file diff --git a/apis/cloudloadbalancers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/cloudloadbalancers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..26850b8960 --- /dev/null +++ b/apis/cloudloadbalancers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata \ No newline at end of file diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadataTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadataTest.java new file mode 100644 index 0000000000..77aa57b660 --- /dev/null +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.cloudloadbalancers; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "CloudLoadBalancersApiMetadataTest") +public class CloudLoadBalancersApiMetadataTest extends BaseApiMetadataTest { + + public CloudLoadBalancersApiMetadataTest() { + super(new CloudLoadBalancersApiMetadata(), ApiType.LOADBALANCER); + } +} diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java new file mode 100644 index 0000000000..c41c0a1aba --- /dev/null +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.cloudservers; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for Rackspace Cloud Servers API + * + * @author Adrian Cole + */ +public class CloudServersApiMetadata extends BaseApiMetadata { + + public CloudServersApiMetadata() { + this(builder() + .id("cloudservers") + .type(ApiType.COMPUTE) + .name("Rackspace Cloud Servers API") + .identityName("Username") + .credentialName("API Key") + .documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudServersApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public CloudServersApiMetadata build() { + return new CloudServersApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersProviderMetadata.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersProviderMetadata.java deleted file mode 100644 index fde4fead7b..0000000000 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersProviderMetadata.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudservers; - -import java.net.URI; - -import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -/** -* Common implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Servers. -* -* @author Dan Lo Bianco -*/ -public abstract class CloudServersProviderMetadata extends BaseProviderMetadata { - - public CloudServersProviderMetadata() { - super(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; - } - - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Username"; - } - - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "API Key"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html"); - } - -} \ No newline at end of file diff --git a/apis/cloudservers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/cloudservers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..417ed21eaf --- /dev/null +++ b/apis/cloudservers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.cloudservers.CloudServersApiMetadata \ No newline at end of file diff --git a/sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/ProvidersInPropertiesTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java similarity index 69% rename from sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/ProvidersInPropertiesTest.java rename to apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java index ace0f456e2..f4d822af98 100644 --- a/sandbox-providers/aws-simpledb/src/test/java/org/jclouds/aws/simpledb/ProvidersInPropertiesTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java @@ -16,25 +16,20 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.aws.simpledb; +package org.jclouds.cloudservers; -import org.jclouds.rest.Providers; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; import org.testng.annotations.Test; -import com.google.common.collect.Iterables; - /** * * @author Adrian Cole - * */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "aws-simpledb") : providers; - } +@Test(groups = "unit", testName = "CloudServersApiMetadataTest") +public class CloudServersApiMetadataTest extends BaseApiMetadataTest { + public CloudServersApiMetadataTest() { + super(new CloudServersApiMetadata(), ApiType.COMPUTE); + } } diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java new file mode 100644 index 0000000000..7d9a7f992e --- /dev/null +++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.cloudsigma; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for the Cloud Sigma API + * + * @author Adrian Cole + */ +public class CloudSigmaApiMetadata extends BaseApiMetadata { + + public CloudSigmaApiMetadata() { + this(builder() + .id("cloudsigma") + .type(ApiType.COMPUTE) + .name("CloudSigma API") + .identityName("Email") + .credentialName("Password") + .documentation(URI.create("http://cloudsigma.com/en/platform-details/the-api"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudSigmaApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public CloudSigmaApiMetadata build() { + return new CloudSigmaApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/apis/cloudsigma/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/cloudsigma/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..768b1027f2 --- /dev/null +++ b/apis/cloudsigma/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.cloudsigma.CloudSigmaApiMetadata \ No newline at end of file diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java new file mode 100644 index 0000000000..f5a9898fd0 --- /dev/null +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.cloudsigma; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "CloudSigmaApiMetadataTest") +public class CloudSigmaApiMetadataTest extends BaseApiMetadataTest { + + public CloudSigmaApiMetadataTest() { + super(new CloudSigmaApiMetadata(), ApiType.COMPUTE); + } +} diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/ProvidersInPropertiesTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/ProvidersInPropertiesTest.java deleted file mode 100644 index 0a93dc1625..0000000000 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/ProvidersInPropertiesTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.cloudsigma; - -import org.jclouds.compute.util.ComputeServiceUtils; -import org.jclouds.rest.Providers; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - * - */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "cloudsigma") : providers; - } - - @Test - public void testSupportedComputeServiceProviders() { - Iterable providers = ComputeServiceUtils.getSupportedProviders(); - assert Iterables.contains(providers, "cloudsigma") : providers; - } - -} diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java new file mode 100644 index 0000000000..d1b30a7e45 --- /dev/null +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.cloudstack; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for Citrix CloudStack API + * + * @author Adrian Cole + */ +public class CloudStackApiMetadata extends BaseApiMetadata { + + public CloudStackApiMetadata() { + this(builder() + .id("cloudstack") + .type(ApiType.COMPUTE) + .name("Citrix CloudStack API") + .identityName("API Key") + .credentialName("Secret Key") + .documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudStackApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public CloudStackApiMetadata build() { + return new CloudStackApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/apis/cloudstack/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/cloudstack/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..ad45dcefd0 --- /dev/null +++ b/apis/cloudstack/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.cloudstack.CloudStackApiMetadata \ No newline at end of file diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/CloudStackApiMetadataTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/CloudStackApiMetadataTest.java new file mode 100644 index 0000000000..d2d5676dad --- /dev/null +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/CloudStackApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.cloudstack; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "CloudStackApiMetadataTest") +public class CloudStackApiMetadataTest extends BaseApiMetadataTest { + + public CloudStackApiMetadataTest() { + super(new CloudStackApiMetadata(), ApiType.COMPUTE); + } +} diff --git a/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java new file mode 100644 index 0000000000..70a8190377 --- /dev/null +++ b/apis/cloudwatch/src/main/java/org/jclouds/cloudwatch/CloudWatchApiMetadata.java @@ -0,0 +1,67 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.cloudwatch; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for Amazon's CloudWatch api. + * + * @author Adrian Cole + */ +public class CloudWatchApiMetadata extends BaseApiMetadata { + + public CloudWatchApiMetadata() { + this(builder() + .id("cloudwatch") + .type(ApiType.MONITOR) + .name("Amazon CloudWatch Api") + .identityName("Access Key ID") + .credentialName("Secret Access Key") + .documentation(URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudWatchApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public CloudWatchApiMetadata build() { + return new CloudWatchApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/apis/cloudwatch/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/cloudwatch/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..de872be08a --- /dev/null +++ b/apis/cloudwatch/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.cloudwatch.CloudWatchApiMetadata \ No newline at end of file diff --git a/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java new file mode 100644 index 0000000000..e1a72cdba6 --- /dev/null +++ b/apis/cloudwatch/src/test/java/org/jclouds/cloudwatch/CloudWatchApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.cloudwatch; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "CloudWatchApiMetadataTest") +public class CloudWatchApiMetadataTest extends BaseApiMetadataTest { + + public CloudWatchApiMetadataTest() { + super(new CloudWatchApiMetadata(), ApiType.MONITOR); + } +} diff --git a/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java new file mode 100644 index 0000000000..ff12e02b9f --- /dev/null +++ b/apis/deltacloud/src/main/java/org/jclouds/deltacloud/DeltacloudApiMetadata.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.deltacloud; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for Apache Deltacloud API + * + * @author Adrian Cole + */ +public class DeltacloudApiMetadata extends BaseApiMetadata { + + public DeltacloudApiMetadata() { + this(builder() + .id("deltacloud") + .type(ApiType.COMPUTE) + .name("Apache Deltacloud API") + .identityName("Username") + .credentialName("Password") + .documentation(URI.create("http://deltacloud.apache.org/api.html"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected DeltacloudApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public DeltacloudApiMetadata build() { + return new DeltacloudApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/apis/deltacloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/deltacloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..834ff5d1aa --- /dev/null +++ b/apis/deltacloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.deltacloud.DeltacloudApiMetadata \ No newline at end of file diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudApiMetadataTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudApiMetadataTest.java new file mode 100644 index 0000000000..2dd950d963 --- /dev/null +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.deltacloud; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "DeltacloudApiMetadataTest") +public class DeltacloudApiMetadataTest extends BaseApiMetadataTest { + + public DeltacloudApiMetadataTest() { + super(new DeltacloudApiMetadata(), ApiType.COMPUTE); + } +} diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java b/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java new file mode 100644 index 0000000000..6e5120ab3d --- /dev/null +++ b/apis/ec2/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java @@ -0,0 +1,75 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.ec2; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for Amazon's EC2 api. + * + * @author Adrian Cole + */ +public class EC2ApiMetadata extends BaseApiMetadata { + + public EC2ApiMetadata() { + this(builder() + .id("ec2") + .type(ApiType.COMPUTE) + .name("Amazon Elastic Compute Cloud (EC2) API") + .identityName("Access Key ID") + .credentialName("Secret Access Key") + .documentation(URI.create("http://docs.amazonwebservices.com/AWSEC2/latest/APIReference"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected EC2ApiMetadata(EC2ApiMetadataBuilder builder) { + super(builder); + } + + public static class EC2ApiMetadataBuilder> extends Builder { + + @Override + public EC2ApiMetadata build() { + return new EC2ApiMetadata(this); + } + } + + private static class EC2ConcreteBuilder extends EC2ApiMetadataBuilder { + + @Override + public EC2ApiMetadata build() { + return new EC2ApiMetadata(this); + } + } + + private static EC2ConcreteBuilder builder() { + return new EC2ConcreteBuilder(); + } + + @Override + public EC2ApiMetadataBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/apis/ec2/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/ec2/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..dce15a1be9 --- /dev/null +++ b/apis/ec2/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.ec2.EC2ApiMetadata \ No newline at end of file diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java new file mode 100644 index 0000000000..14f62cdc91 --- /dev/null +++ b/apis/ec2/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.ec2; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "EC2ApiMetadataTest") +public class EC2ApiMetadataTest extends BaseApiMetadataTest { + + public EC2ApiMetadataTest() { + super(new EC2ApiMetadata(), ApiType.COMPUTE); + } +} diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java new file mode 100644 index 0000000000..bdc2d7fd0b --- /dev/null +++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.elasticstack; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for the ElasticStack API + * + * @author Adrian Cole + */ +public class ElasticStackApiMetadata extends BaseApiMetadata { + + public ElasticStackApiMetadata() { + this(builder() + .id("elasticstack") + .type(ApiType.COMPUTE) + .name("ElasticStack API") + .identityName("UUID") + .credentialName("Secret API key") + .documentation(URI.create("http://www.elasticstack.com/cloud-platform/api"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected ElasticStackApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public ElasticStackApiMetadata build() { + return new ElasticStackApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/apis/elasticstack/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/elasticstack/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..562d32947b --- /dev/null +++ b/apis/elasticstack/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.elasticstack.ElasticStackApiMetadata \ No newline at end of file diff --git a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/ProvidersInPropertiesTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiMetadataTest.java similarity index 69% rename from providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/ProvidersInPropertiesTest.java rename to apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiMetadataTest.java index c0d29966c2..8d80a68503 100644 --- a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/ProvidersInPropertiesTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiMetadataTest.java @@ -16,25 +16,20 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.cloudonestorage; +package org.jclouds.elasticstack; -import org.jclouds.rest.Providers; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; import org.testng.annotations.Test; -import com.google.common.collect.Iterables; - /** * * @author Adrian Cole - * */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "cloudonestorage") : providers; - } +@Test(groups = "unit", testName = "ElasticStackApiMetadataTest") +public class ElasticStackApiMetadataTest extends BaseApiMetadataTest { + public ElasticStackApiMetadataTest() { + super(new ElasticStackApiMetadata(), ApiType.COMPUTE); + } } diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ProvidersInPropertiesTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ProvidersInPropertiesTest.java deleted file mode 100644 index 782a0572c7..0000000000 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ProvidersInPropertiesTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.elasticstack; - -import org.jclouds.compute.util.ComputeServiceUtils; -import org.jclouds.rest.Providers; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - * - */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "elasticstack") : providers; - assert Iterables.contains(providers, "elastichosts-lon-p") : providers; - assert Iterables.contains(providers, "elastichosts-lon-b") : providers; - assert Iterables.contains(providers, "elastichosts-sat-p") : providers; - } - - @Test - public void testSupportedComputeServiceProviders() { - Iterable providers = ComputeServiceUtils.getSupportedProviders(); - assert Iterables.contains(providers, "elasticstack") : providers; - assert Iterables.contains(providers, "elastichosts-lon-p") : providers; - assert Iterables.contains(providers, "elastichosts-lon-b") : providers; - assert Iterables.contains(providers, "elastichosts-sat-p") : providers; - } - -} diff --git a/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java b/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java new file mode 100644 index 0000000000..c8e8877108 --- /dev/null +++ b/apis/eucalyptus/src/main/java/org/jclouds/eucalyptus/EucalyptusApiMetadata.java @@ -0,0 +1,60 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.eucalyptus; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.ec2.EC2ApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for the Eucalyptus (EC2 clone) api. + * + * @author Adrian Cole + */ +public class EucalyptusApiMetadata extends EC2ApiMetadata { + + public EucalyptusApiMetadata() { + this(builder().fromApiMetadata(new EC2ApiMetadata()) + .id("eucalyptus") + .name("Eucalyptus (EC2 clone) API")); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected EucalyptusApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends EC2ApiMetadataBuilder { + + @Override + public EucalyptusApiMetadata build() { + return new EucalyptusApiMetadata(this); + } + } + + private static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/apis/eucalyptus/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/eucalyptus/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..2475f3ff9d --- /dev/null +++ b/apis/eucalyptus/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.eucalyptus.EucalyptusApiMetadata \ No newline at end of file diff --git a/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/EucalyptusApiMetadataTest.java b/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/EucalyptusApiMetadataTest.java new file mode 100644 index 0000000000..7473d8a3e6 --- /dev/null +++ b/apis/eucalyptus/src/test/java/org/jclouds/eucalyptus/EucalyptusApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.eucalyptus; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "EucalyptusApiMetadataTest") +public class EucalyptusApiMetadataTest extends BaseApiMetadataTest { + + public EucalyptusApiMetadataTest() { + super(new EucalyptusApiMetadata(), ApiType.COMPUTE); + } +} diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java new file mode 100644 index 0000000000..99d51e6402 --- /dev/null +++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/FilesystemApiMetadata.java @@ -0,0 +1,67 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.filesystem; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for jclouds Filesystem-based BlobStore + * + * @author Adrian Cole + */ +public class FilesystemApiMetadata extends BaseApiMetadata { + + public FilesystemApiMetadata() { + this(builder() + .id("filesystem") + .type(ApiType.BLOBSTORE) + .name("Filesystem-based BlobStore") + .identityName("Unused") + .documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected FilesystemApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public FilesystemApiMetadata build() { + return new FilesystemApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/apis/filesystem/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/filesystem/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..9219cb2ff6 --- /dev/null +++ b/apis/filesystem/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.filesystem.FilesystemApiMetadata \ No newline at end of file diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemApiMetadataTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemApiMetadataTest.java new file mode 100644 index 0000000000..e5619df33a --- /dev/null +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.filesystem; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "FilesystemApiMetadataTest") +public class FilesystemApiMetadataTest extends BaseApiMetadataTest { + + public FilesystemApiMetadataTest() { + super(new FilesystemApiMetadata(), ApiType.BLOBSTORE); + } +} diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java new file mode 100644 index 0000000000..ef27f4770e --- /dev/null +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaApiMetadata.java @@ -0,0 +1,67 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.openstack.nova; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for OpenStack Nova Pre-Diablo + * + * @author Adrian Cole + */ +public class NovaApiMetadata extends BaseApiMetadata { + + public NovaApiMetadata() { + this(builder() + .id("nova") + .type(ApiType.COMPUTE) + .name("OpenStack Nova Pre-Diablo API") + .identityName("accessKey") + .credentialName("secretKey") + .documentation(URI.create("http://api.openstack.org/"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected NovaApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public NovaApiMetadata build() { + return new NovaApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/apis/nova/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/nova/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..0fa70d2cb5 --- /dev/null +++ b/apis/nova/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.openstack.nova.NovaApiMetadata \ No newline at end of file diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaApiMetadataTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaApiMetadataTest.java new file mode 100644 index 0000000000..448a1e04b2 --- /dev/null +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.openstack.nova; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "NovaApiMetadataTest") +public class NovaApiMetadataTest extends BaseApiMetadataTest { + + public NovaApiMetadataTest() { + super(new NovaApiMetadata(), ApiType.COMPUTE); + } +} diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java new file mode 100644 index 0000000000..3df8fa8925 --- /dev/null +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java @@ -0,0 +1,58 @@ +package org.jclouds.openstack.nova.v1_1; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for OpenStack Nova Diablo+ + * + * @author Adrian Cole + */ +public class NovaApiMetadata extends BaseApiMetadata { + + public NovaApiMetadata() { + this(builder() + .id("openstack-nova") + .type(ApiType.COMPUTE) + .name("OpenStack Nova Diablo+ API") + .identityName("tenantId:user") + .credentialName("password") + .documentation(URI.create("http://api.openstack.org/"))); + } + + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected NovaApiMetadata(NovaApiMetadataBuilder builder) { + super(builder); + } + + public static class NovaApiMetadataBuilder> extends Builder { + + @Override + public NovaApiMetadata build() { + return new NovaApiMetadata(this); + } + } + + private static class NovaConcreteBuilder extends NovaApiMetadataBuilder { + + @Override + public NovaApiMetadata build() { + return new NovaApiMetadata(this); + } + } + + private static NovaConcreteBuilder builder() { + return new NovaConcreteBuilder(); + } + + @Override + public NovaApiMetadataBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/apis/openstack-nova/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/openstack-nova/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..31eaaf812a --- /dev/null +++ b/apis/openstack-nova/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.openstack.nova.v1_1.NovaApiMetadata \ No newline at end of file diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadataTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadataTest.java new file mode 100644 index 0000000000..2057e42892 --- /dev/null +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadataTest.java @@ -0,0 +1,17 @@ +package org.jclouds.openstack.nova.v1_1; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "NovaApiMetadataTest") +public class NovaApiMetadataTest extends BaseApiMetadataTest { + + public NovaApiMetadataTest() { + super(new NovaApiMetadata(), ApiType.COMPUTE); + } +} diff --git a/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java b/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java new file mode 100644 index 0000000000..d6a30143a1 --- /dev/null +++ b/apis/s3/src/main/java/org/jclouds/s3/S3ApiMetadata.java @@ -0,0 +1,75 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.s3; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for Amazon's S3 api. + * + * @author Adrian Cole + */ +public class S3ApiMetadata extends BaseApiMetadata { + + public S3ApiMetadata() { + this(builder() + .id("s3") + .type(ApiType.BLOBSTORE) + .name("Amazon Simple Storage Service (S3) API") + .identityName("Access Key ID") + .credentialName("Secret Access Key") + .documentation(URI.create("http://docs.amazonwebservices.com/AmazonS3/latest/API"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected S3ApiMetadata(S3ApiMetadataBuilder builder) { + super(builder); + } + + public static class S3ApiMetadataBuilder> extends Builder { + + @Override + public S3ApiMetadata build() { + return new S3ApiMetadata(this); + } + } + + private static class S3ConcreteBuilder extends S3ApiMetadataBuilder { + + @Override + public S3ApiMetadata build() { + return new S3ApiMetadata(this); + } + } + + private static S3ConcreteBuilder builder() { + return new S3ConcreteBuilder(); + } + + @Override + public S3ApiMetadataBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/apis/s3/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/s3/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..e206c63617 --- /dev/null +++ b/apis/s3/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.s3.S3ApiMetadata \ No newline at end of file diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java new file mode 100644 index 0000000000..b18deec218 --- /dev/null +++ b/apis/s3/src/test/java/org/jclouds/s3/S3ApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.s3; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "S3ApiMetadataTest") +public class S3ApiMetadataTest extends BaseApiMetadataTest { + + public S3ApiMetadataTest() { + super(new S3ApiMetadata(), ApiType.BLOBSTORE); + } +} diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java new file mode 100644 index 0000000000..665b84e9f6 --- /dev/null +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java @@ -0,0 +1,49 @@ +package org.jclouds.openstack.swift; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for OpenStack Swift Pre-Diablo + * + * @author Adrian Cole + */ +public class SwiftApiMetadata extends BaseApiMetadata { + + public SwiftApiMetadata() { + this(builder() + .id("swift") + .type(ApiType.BLOBSTORE) + .name("OpenStack Swift Pre-Diablo API") + .identityName("tenantId:user") + .credentialName("password") + .documentation(URI.create("http://api.openstack.org/"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected SwiftApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public SwiftApiMetadata build() { + return new SwiftApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/apis/swift/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/swift/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..884acc5457 --- /dev/null +++ b/apis/swift/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.openstack.swift.SwiftApiMetadata \ No newline at end of file diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java new file mode 100644 index 0000000000..299f16ea43 --- /dev/null +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftApiMetadataTest.java @@ -0,0 +1,17 @@ +package org.jclouds.openstack.swift; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "SwiftApiMetadataTest") +public class SwiftApiMetadataTest extends BaseApiMetadataTest { + + public SwiftApiMetadataTest() { + super(new SwiftApiMetadata(), ApiType.BLOBSTORE); + } +} diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java new file mode 100644 index 0000000000..8b00adb062 --- /dev/null +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java @@ -0,0 +1,67 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for VCloud 1.0 API + * + * @author Adrian Cole + */ +public class VCloudApiMetadata extends BaseApiMetadata { + + public VCloudApiMetadata() { + this(builder() + .id("vcloud") + .type(ApiType.COMPUTE) + .name("VCloud 1.0 API") + .identityName("User at Organization (user@org)") + .credentialName("Password") + .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected VCloudApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public VCloudApiMetadata build() { + return new VCloudApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/apis/vcloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/vcloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..d800a949a2 --- /dev/null +++ b/apis/vcloud/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.vcloud.VCloudApiMetadata \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/ProvidersInPropertiesTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/ProvidersInPropertiesTest.java deleted file mode 100644 index 771a700a88..0000000000 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/ProvidersInPropertiesTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.vcloud; - -import org.jclouds.compute.util.ComputeServiceUtils; -import org.jclouds.rest.Providers; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - * - */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "vcloud") : providers; - } - - @Test - public void testSupportedComputeServiceProviders() { - Iterable providers = ComputeServiceUtils.getSupportedProviders(); - assert Iterables.contains(providers, "vcloud") : providers; - } - -} diff --git a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/ProvidersInPropertiesTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java similarity index 69% rename from providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/ProvidersInPropertiesTest.java rename to apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java index 1d99bd3df3..338494962b 100644 --- a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/ProvidersInPropertiesTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java @@ -16,25 +16,20 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.synaptic.storage; +package org.jclouds.vcloud; -import org.jclouds.rest.Providers; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; import org.testng.annotations.Test; -import com.google.common.collect.Iterables; - /** * * @author Adrian Cole - * */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "synaptic-storage") : providers; - } +@Test(groups = "unit", testName = "VCloudApiMetadataTest") +public class VCloudApiMetadataTest extends BaseApiMetadataTest { + public VCloudApiMetadataTest() { + super(new VCloudApiMetadata(), ApiType.COMPUTE); + } } diff --git a/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java b/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java new file mode 100644 index 0000000000..50ac5ace9d --- /dev/null +++ b/apis/walrus/src/main/java/org/jclouds/walrus/WalrusApiMetadata.java @@ -0,0 +1,60 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.walrus; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.s3.S3ApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for the Walrus (S3 clone) api. + * + * @author Adrian Cole + */ +public class WalrusApiMetadata extends S3ApiMetadata { + + public WalrusApiMetadata() { + this(builder().fromApiMetadata(new S3ApiMetadata()) + .id("walrus") + .name("Walrus (S3 clone) API")); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected WalrusApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends S3ApiMetadataBuilder { + + @Override + public WalrusApiMetadata build() { + return new WalrusApiMetadata(this); + } + } + + private static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/apis/walrus/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/walrus/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..615ba3fec5 --- /dev/null +++ b/apis/walrus/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.walrus.WalrusApiMetadata \ No newline at end of file diff --git a/apis/walrus/src/test/java/org/jclouds/walrus/WalrusApiMetadataTest.java b/apis/walrus/src/test/java/org/jclouds/walrus/WalrusApiMetadataTest.java new file mode 100644 index 0000000000..ca5dbf801d --- /dev/null +++ b/apis/walrus/src/test/java/org/jclouds/walrus/WalrusApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.walrus; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "WalrusApiMetadataTest") +public class WalrusApiMetadataTest extends BaseApiMetadataTest { + + public WalrusApiMetadataTest() { + super(new WalrusApiMetadata(), ApiType.BLOBSTORE); + } +} diff --git a/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java b/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java new file mode 100644 index 0000000000..815114d2eb --- /dev/null +++ b/blobstore/src/main/java/org/jclouds/blobstore/TransientApiMetadata.java @@ -0,0 +1,67 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.blobstore; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for jclouds in-memory (Transient) API + * + * @author Adrian Cole + */ +public class TransientApiMetadata extends BaseApiMetadata { + + public TransientApiMetadata() { + this(builder() + .id("transient") + .type(ApiType.BLOBSTORE) + .name("in-memory (Transient) API") + .identityName("Unused") + .documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected TransientApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public TransientApiMetadata build() { + return new TransientApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/blobstore/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/blobstore/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..a5bb992fe4 --- /dev/null +++ b/blobstore/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.blobstore.TransientApiMetadata \ No newline at end of file diff --git a/demos/getpath/src/test/java/org/jclouds/blobstore/ProvidersInPropertiesTest.java b/blobstore/src/test/java/org/jclouds/blobstore/TransientApiMetadataTest.java similarity index 64% rename from demos/getpath/src/test/java/org/jclouds/blobstore/ProvidersInPropertiesTest.java rename to blobstore/src/test/java/org/jclouds/blobstore/TransientApiMetadataTest.java index 732bad21e7..98fa8767fa 100644 --- a/demos/getpath/src/test/java/org/jclouds/blobstore/ProvidersInPropertiesTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/TransientApiMetadataTest.java @@ -18,26 +18,18 @@ */ package org.jclouds.blobstore; -import org.jclouds.blobstore.util.BlobStoreUtils; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; import org.testng.annotations.Test; -import com.google.common.collect.Iterables; - /** * * @author Adrian Cole - * */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedBlobStoreProviders() { - Iterable providers = BlobStoreUtils.getSupportedProviders(); - assert Iterables.contains(providers, "s3") : providers; - assert Iterables.contains(providers, "azureblob") : providers; - assert Iterables.contains(providers, "cloudfiles") : providers; +@Test(groups = "unit", testName = "TransientApiMetadataTest") +public class TransientApiMetadataTest extends BaseApiMetadataTest { + public TransientApiMetadataTest() { + super(new TransientApiMetadata(), ApiType.BLOBSTORE); } - } diff --git a/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java b/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java new file mode 100644 index 0000000000..30b6ffcc6c --- /dev/null +++ b/compute/src/main/java/org/jclouds/compute/stub/StubApiMetadata.java @@ -0,0 +1,67 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.compute.stub; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for jclouds in-memory (Stub) API + * + * @author Adrian Cole + */ +public class StubApiMetadata extends BaseApiMetadata { + + public StubApiMetadata() { + this(builder() + .id("stub") + .type(ApiType.COMPUTE) + .name("in-memory (Stub) API") + .identityName("Unused") + .documentation(URI.create("http://www.jclouds.org/documentation/userguide/compute"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected StubApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public StubApiMetadata build() { + return new StubApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/compute/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/compute/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..542beaa856 --- /dev/null +++ b/compute/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.compute.stub.StubApiMetadata \ No newline at end of file diff --git a/compute/src/test/java/org/jclouds/compute/stub/StubApiMetadataTest.java b/compute/src/test/java/org/jclouds/compute/stub/StubApiMetadataTest.java new file mode 100644 index 0000000000..64690551e6 --- /dev/null +++ b/compute/src/test/java/org/jclouds/compute/stub/StubApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.compute.stub; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "StubApiMetadataTest") +public class StubApiMetadataTest extends BaseApiMetadataTest { + + public StubApiMetadataTest() { + super(new StubApiMetadata(), ApiType.COMPUTE); + } +} diff --git a/core/src/main/java/org/jclouds/apis/ApiMetadata.java b/core/src/main/java/org/jclouds/apis/ApiMetadata.java new file mode 100644 index 0000000000..2f00ada5f6 --- /dev/null +++ b/core/src/main/java/org/jclouds/apis/ApiMetadata.java @@ -0,0 +1,119 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.apis; + + +import java.net.URI; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.annotations.Beta; + + +/** + * The ApiMetadata interface allows jclouds to provide a plugin framework for + * gathering cloud api metadata. + * + * @author Jeremy Whitlock , Adrian Cole + * @since 1.5 + */ +@Beta +public interface ApiMetadata { + + public static interface Builder> { + /** + * @see ApiMetadata#getId() + */ + B id(String id); + + /** + * @see ApiMetadata#getName() + */ + B name(String name); + + /** + * @see ApiMetadata#getType() + */ + B type(ApiType type); + + /** + * @see ApiMetadata#getIdentityName() + */ + B identityName(String identityName); + + /** + * @see ApiMetadata#getCredentialName() + */ + B credentialName(@Nullable String credentialName); + + /** + * @see ApiMetadata#getDocumentation() + */ + B documentation(URI documentation); + + ApiMetadata build(); + + B fromApiMetadata(ApiMetadata in); + } + + /** + * @see Builder + */ + Builder toBuilder(); + + /** + * + * @return the api's unique identifier + */ + public String getId(); + + /** + * + * @return the name (display name) of the api + */ + public String getName(); + + /** + * + * @return the api's type + */ + public ApiType getType(); + + /** + * + * @return the name (display name) of an identity on this api (ex. user, + * email, account, apikey) + */ + public String getIdentityName(); + + /** + * + * @return the name (display name) of a credential on this api, or null if + * there is none (ex. password, secret, rsaKey) + */ + @Nullable + public String getCredentialName(); + + /** + * + * @return the url for the API documentation related to this service + */ + public URI getDocumentation(); + +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/ApiPredicates.java b/core/src/main/java/org/jclouds/apis/ApiPredicates.java new file mode 100644 index 0000000000..466de17e03 --- /dev/null +++ b/core/src/main/java/org/jclouds/apis/ApiPredicates.java @@ -0,0 +1,102 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.apis; + +import static com.google.common.base.Preconditions.checkNotNull; + +import org.jclouds.util.Preconditions2; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; + +/** + * Container for api filters (predicates). + * + * @author Jeremy Whitlock + */ +public class ApiPredicates { + + /** + * Returns all apis available to jclouds regardless of type. + * + * @return all available apis + */ + public static Predicate all() { + return Predicates. alwaysTrue(); + } + + /** + * Returns all apis with the given id. + * + * @param id + * the id of the api to return + * + * @return the apis with the given id + */ + public static Predicate id(final String id) { + Preconditions2.checkNotEmpty(id, "id must be defined"); + return new Predicate() { + /** + * {@inheritDoc} + */ + @Override + public boolean apply(ApiMetadata apiMetadata) { + return apiMetadata.getId().equals(id); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return "id(" + id + ")"; + } + }; + } + + /** + * Returns all apis with the given type. + * + * @param type + * the type of the api to return + * + * @return the apis with the given type + */ + public static Predicate type(final ApiType type) { + checkNotNull(type, "type must be defined"); + return new Predicate() { + /** + * {@inheritDoc} + */ + @Override + public boolean apply(ApiMetadata apiMetadata) { + return apiMetadata.getType().equals(type); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return "type(" + type + ")"; + } + }; + } + +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/ApiType.java b/core/src/main/java/org/jclouds/apis/ApiType.java new file mode 100644 index 0000000000..f923d4bec1 --- /dev/null +++ b/core/src/main/java/org/jclouds/apis/ApiType.java @@ -0,0 +1,46 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.apis; + +import static org.jclouds.util.Preconditions2.checkNotEmpty; + +import com.google.common.base.CaseFormat; + +/** + * + * @author Adrian Cole + */ +public enum ApiType { + + BLOBSTORE, COMPUTE, LOADBALANCER, TABLE, QUEUE, MONITOR, UNRECOGNIZED; + + @Override + public String toString() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); + } + + public static ApiType fromValue(String type) { + checkNotEmpty(type, "type must be defined"); + try { + return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, type)); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/Apis.java b/core/src/main/java/org/jclouds/apis/Apis.java new file mode 100644 index 0000000000..f2d6df4e83 --- /dev/null +++ b/core/src/main/java/org/jclouds/apis/Apis.java @@ -0,0 +1,139 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.apis; + +import static com.google.common.collect.Iterables.filter; +import static com.google.common.collect.Iterables.find; + +import java.util.NoSuchElementException; +import java.util.ServiceLoader; + +/** + * The Apis class provides static methods for accessing apis. + * + * @author Jeremy Whitlock + */ +public class Apis { + + /** + * Returns the apis located on the classpath via + * {@link java.util.ServiceLoader}. + * + * @return all available apis loaded from classpath via ServiceLoader + */ + private static Iterable fromServiceLoader() { + return ServiceLoader.load(ApiMetadata.class); + } + + /** + * Returns all available apis. + * + * @return all available apis + */ + public static Iterable all() { + return fromServiceLoader(); + } + + /** + * Returns the first api with the provided id + * + * @param id + * the id of the api to return + * + * @return the api with the given id + * + * @throws NoSuchElementException + * whenever there are no apis with the provided id + */ + public static ApiMetadata withId(String id) throws NoSuchElementException { + return find(all(), ApiPredicates.id(id)); + } + + /** + * Returns the apis that are of type + * {@link org.jclouds.apis.ApiMetadata#BLOBSTORE}. + * + * @return the blobstore apis + */ + public static Iterable allBlobStore() { + return filter(all(), ApiPredicates.type(ApiType.BLOBSTORE)); + } + + /** + * Returns the apis that are of type + * {@link org.jclouds.apis.ApiMetadata#COMPUTE}. + * + * @return the compute service apis + */ + public static Iterable allCompute() { + return filter(all(), ApiPredicates.type(ApiType.COMPUTE)); + } + + /** + * Returns the apis that are of type + * {@link org.jclouds.apis.ApiMetadata#QUEUE}. + * + * @return the queue service apis + */ + public static Iterable allQueue() { + return filter(all(), ApiPredicates.type(ApiType.QUEUE)); + } + + /** + * Returns the apis that are of type + * {@link org.jclouds.apis.ApiMetadata#TABLE}. + * + * @return the table service apis + */ + public static Iterable allTable() { + return filter(all(), ApiPredicates.type(ApiType.TABLE)); + } + + /** + * Returns the apis that are of type + * {@link org.jclouds.apis.ApiMetadata#LOADBALANCER}. + * + * @return the load balancer service apis + */ + public static Iterable allLoadBalancer() { + return filter(all(), ApiPredicates.type(ApiType.LOADBALANCER)); + } + + /** + * Returns the apis that are of type + * {@link org.jclouds.apis.ApiMetadata#MONITOR}. + * + * @return the load balancer service apis + */ + public static Iterable allMonitor() { + return filter(all(), ApiPredicates.type(ApiType.MONITOR)); + } + + /** + * Returns the apis that are of the provided type. + * + * @param type + * the type to apis to return + * + * @return the apis of the provided type + */ + public static Iterable ofType(ApiType type) { + return filter(all(), ApiPredicates.type(type)); + } +} diff --git a/core/src/main/java/org/jclouds/apis/BaseApiMetadata.java b/core/src/main/java/org/jclouds/apis/BaseApiMetadata.java new file mode 100644 index 0000000000..c60a7272ce --- /dev/null +++ b/core/src/main/java/org/jclouds/apis/BaseApiMetadata.java @@ -0,0 +1,211 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.apis; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; + +/** + * The BaseApiMetadata class is an abstraction of {@link ApiMetadata} to be + * extended by those implementing ApiMetadata. + * + * (Note: This class must be abstract to allow {@link java.util.ServiceLoader} + * to work properly. + * + * @author Jeremy Whitlock , Adrian Cole + */ +public abstract class BaseApiMetadata implements ApiMetadata { + + public static abstract class Builder> implements ApiMetadata.Builder { + protected String id; + protected String name; + protected ApiType type; + protected String identityName; + protected String credentialName; + protected URI documentation; + + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + + /** + * {@inheritDoc} + */ + @Override + public B id(String id) { + this.id = checkNotNull(id, "id"); + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public B name(String name) { + this.name = checkNotNull(name, "name"); + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public B type(ApiType type) { + this.type = checkNotNull(type, "type"); + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public B identityName(String identityName) { + this.identityName = checkNotNull(identityName, "identityName"); + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public B credentialName(@Nullable String credentialName) { + this.credentialName = credentialName; + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public B documentation(URI documentation) { + this.documentation = checkNotNull(documentation, "documentation"); + return self(); + } + + public B fromApiMetadata(ApiMetadata in) { + return id(in.getId()).type(in.getType()).name(in.getName()).identityName(in.getIdentityName()) + .credentialName(in.getCredentialName()); + } + } + + protected final String id; + protected final String name; + protected final ApiType type; + protected final String identityName; + protected final String credentialName; + protected final URI documentation; + + protected BaseApiMetadata(Builder builder) { + this.id = builder.id; + this.name = builder.name; + this.type = builder.type; + this.identityName = builder.identityName; + this.credentialName = builder.credentialName; + this.documentation = builder.documentation; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + // subclass equivalence is ok, since we don't know the classloader + // we'll get things from + if (o == null || !(o instanceof ApiMetadata)) + return false; + ApiMetadata that = ApiMetadata.class.cast(o); + return equal(this.getId(), that.getId()) && equal(this.getName(), that.getName()) + && equal(this.getType(), that.getType()) && equal(this.getIdentityName(), that.getIdentityName()) + && equal(this.getCredentialName(), that.getCredentialName()) + && equal(this.getDocumentation(), that.getDocumentation()); + } + + @Override + public int hashCode() { + return Objects + .hashCode(getId(), getName(), getType(), getIdentityName(), getCredentialName(), getDocumentation()); + } + + @Override + public String toString() { + return string().toString(); + } + + protected ToStringHelper string() { + return Objects.toStringHelper("").add("id", getId()).add("name", getName()).add("type", getType()) + .add("identityName", getIdentityName()).add("credentialName", getCredentialName()) + .add("documentation", getDocumentation()); + } + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return id; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return name; + } + + /** + * {@inheritDoc} + */ + @Override + public ApiType getType() { + return type; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return identityName; + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return credentialName; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getDocumentation() { + return documentation; + } + +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/providers/BaseProviderMetadata.java b/core/src/main/java/org/jclouds/providers/BaseProviderMetadata.java index ad6b77447d..f9c5765c38 100644 --- a/core/src/main/java/org/jclouds/providers/BaseProviderMetadata.java +++ b/core/src/main/java/org/jclouds/providers/BaseProviderMetadata.java @@ -18,151 +18,289 @@ */ package org.jclouds.providers; +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.addAll; +import static com.google.common.collect.Sets.newLinkedHashSet; + import java.net.URI; import java.util.Set; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; /** - * The BaseProviderMetadata class is an abstraction of {@link ProviderMetadata} to be extended by - * those implementing ProviderMetadata. + * The BaseProviderMetadata class is an abstraction of {@link ProviderMetadata} + * to be extended by those implementing ProviderMetadata. * - * (Note: This class must be abstract to allow {@link java.util.ServiceLoader} to work properly. + * (Note: This class must be abstract to allow {@link java.util.ServiceLoader} + * to work properly. * - * @author Jeremy Whitlock + * @author Adrian Cole */ public abstract class BaseProviderMetadata implements ProviderMetadata { - /** - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - URI console = getConsole(); - URI homepage = getHomepage(); - URI docs = getApiDocumentation(); - String id = getId(); - String name = getName(); - String identityName = getIdentityName(); - String credentialName = getCredentialName(); - String type = getType(); - Set linkedServices = getLinkedServices(); - Set iso3166Codes = getIso3166Codes(); + public static abstract class Builder> implements ProviderMetadata.Builder { + protected String id; + protected String name; + protected ApiMetadata api; + protected URI console; + protected URI homepage; + protected Set linkedServices = newLinkedHashSet(); + protected Set iso3166Codes = newLinkedHashSet(); - result = prime * result + ((console == null) ? 0 : console.hashCode()); - result = prime * result + ((homepage == null) ? 0 : homepage.hashCode()); - result = prime * result + ((docs == null) ? 0 : docs.hashCode()); - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((identityName == null) ? 0 : identityName.hashCode()); - result = prime * result + ((credentialName == null) ? 0 : credentialName.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((linkedServices == null) ? 0 : linkedServices.hashCode()); - result = prime * result + ((iso3166Codes == null) ? 0 : iso3166Codes.hashCode()); + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } - return result; + /** + * {@inheritDoc} + */ + @Override + public B id(String id) { + this.id = checkNotNull(id, "id"); + return linkedService(id); + } + + /** + * {@inheritDoc} + */ + @Override + public B name(String name) { + this.name = checkNotNull(name, "name"); + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public B api(ApiMetadata api) { + this.api = checkNotNull(api, "api"); + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public B console(@Nullable URI console) { + this.console = console; + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public B homepage(URI homepage) { + this.homepage = homepage; + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public B linkedServices(Iterable linkedServices) { + addAll(this.linkedServices, checkNotNull(linkedServices, "linkedServices")); + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public B linkedServices(String... linkedServices) { + return linkedServices(ImmutableSet.copyOf(checkNotNull(linkedServices, "linkedServices"))); + } + + /** + * {@inheritDoc} + */ + @Override + public B linkedService(String linkedService) { + this.linkedServices.add(checkNotNull(linkedService, "linkedService")); + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public B iso3166Codes(Iterable iso3166Codes) { + addAll(this.iso3166Codes, checkNotNull(iso3166Codes, "iso3166Codes")); + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public B iso3166Codes(String... iso3166Codes) { + return iso3166Codes(ImmutableSet.copyOf(checkNotNull(iso3166Codes, "iso3166Codes"))); + } + + /** + * {@inheritDoc} + */ + @Override + public B iso3166Code(String iso3166Code) { + this.iso3166Codes.add(checkNotNull(iso3166Code, "iso3166Code")); + return self(); + } + + /** + * {@inheritDoc} + */ + @Override + public B fromProviderMetadata(ProviderMetadata in) { + return id(in.getId()).name(in.getName()).api(in.getApi()).console(in.getConsole()).homepage(in.getHomepage()) + .linkedServices(in.getLinkedServices()).iso3166Codes(in.getIso3166Codes()); + } + } + + protected final String id; + protected final String name; + protected final ApiMetadata api; + protected final URI homepage; + protected final URI console; + protected final Set linkedServices; + protected final Set iso3166Codes; + + protected BaseProviderMetadata(Builder builder) { + this.id = builder.id; + this.name = builder.name; + this.api = builder.api; + this.console = builder.console; + this.homepage = builder.homepage; + this.linkedServices = ImmutableSet.copyOf(builder.linkedServices); + this.iso3166Codes = ImmutableSet.copyOf(builder.iso3166Codes); } - /** - * @see java.lang.Object#equals(java.lang.Object) - */ @Override - public boolean equals(Object obj) { - URI tConsole = getConsole(); - URI tHomepage = getHomepage(); - URI tDocs = getApiDocumentation(); - String tId = getId(); - String tName = getName(); - String tIdentityName = getIdentityName(); - String tCredentialName = getCredentialName(); - String tType = getType(); - Set tLinkedServices = getLinkedServices(); - Set tIso3166Codes = getIso3166Codes(); - - if (this == obj) + public boolean equals(Object o) { + if (this == o) return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) + // subclass equivalence is ok, since we don't know the classloader + // we'll get things from + if (o == null || !(o instanceof ProviderMetadata)) return false; + ProviderMetadata that = ProviderMetadata.class.cast(o); + return equal(this.getId(), that.getId()) && equal(this.getName(), that.getName()) + && equal(this.getApi(), that.getApi()) && equal(this.getConsole(), that.getConsole()) + && equal(this.getHomepage(), that.getHomepage()) + && equal(this.getLinkedServices(), that.getLinkedServices()) + && equal(this.getIso3166Codes(), that.getIso3166Codes()); + } - ProviderMetadata other = (ProviderMetadata) obj; - URI oConsole = other.getConsole(); - URI oHomepage = other.getHomepage(); - URI oDocs = other.getApiDocumentation(); - String oId = other.getId(); - String oName = other.getName(); - String oIdentityName = other.getIdentityName(); - String oCredentialName = other.getCredentialName(); - String oType = other.getType(); - Set oLinkedServices = other.getLinkedServices(); - Set oIso3166Codes = other.getIso3166Codes(); - - if (tConsole == null) { - if (oConsole != null) - return false; - } else if (!tConsole.equals(oConsole)) - return false; - if (tDocs == null) { - if (oDocs != null) - return false; - } else if (!tDocs.equals(oDocs)) - return false; - if (tHomepage == null) { - if (oHomepage != null) - return false; - } else if (!tHomepage.equals(oHomepage)) - return false; - if (tId == null) { - if (oId != null) - return false; - } else if (!tId.equals(oId)) - return false; - if (tName == null) { - if (oName != null) - return false; - } else if (!tName.equals(oName)) - return false; - if (tIdentityName == null) { - if (oIdentityName != null) - return false; - } else if (!tIdentityName.equals(oIdentityName)) - return false; - if (tCredentialName == null) { - if (oCredentialName != null) - return false; - } else if (!tCredentialName.equals(oCredentialName)) - return false; - if (tType == null) { - if (oType != null) - return false; - } else if (!tType.equals(oType)) - return false; - if (tLinkedServices == null) { - if (oLinkedServices != null) - return false; - } else if (!tLinkedServices.equals(oLinkedServices)) - return false; - if (tIso3166Codes == null) { - if (oIso3166Codes != null) - return false; - } else if (!tIso3166Codes.equals(oIso3166Codes)) - return false; - return true; + @Override + public int hashCode() { + return Objects.hashCode(getId(), getName(), getApi(), getConsole(), getHomepage(), getLinkedServices(), + getIso3166Codes()); } @Override public String toString() { - return "[id=" + getId() + ", type=" + getType() + ", name=" + getName() + ", identityName=" + getIdentityName() - + ", credentialName=" + getCredentialName() + ", homePage=" + getHomepage() + ", console=" - + getConsole() + ", apiDocs=" + getApiDocumentation() + ", linkedServices=" + getLinkedServices() + - ", iso3166Codes=" + getIso3166Codes() + "]"; + return string().toString(); } + public ToStringHelper string() { + return Objects.toStringHelper("").add("id", getId()).add("name", getName()).add("api", getApi()) + .add("console", getConsole()).add("homepage", getHomepage()).add("linkedServices", getLinkedServices()) + .add("iso3166Codes", getIso3166Codes()); + } + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return id; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return name; + } + + /** + * {@inheritDoc} + */ + @Override + public ApiMetadata getApi() { + return api; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getConsole() { + return console; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getHomepage() { + return homepage; + } + + /** + * {@inheritDoc} + */ @Override public Set getLinkedServices() { - return ImmutableSet.of(getId()); + return linkedServices; + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return iso3166Codes; + } + + /** + * {@inheritDoc} + */ + @Override + public String getType() { + return getApi().getType().toString(); + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentityName() { + return getApi().getIdentityName(); + } + + /** + * {@inheritDoc} + */ + @Override + public String getCredentialName() { + return getApi().getCredentialName(); + } + + /** + * {@inheritDoc} + */ + @Override + public URI getApiDocumentation() { + return getApi().getDocumentation(); } } diff --git a/core/src/main/java/org/jclouds/providers/ProviderMetadata.java b/core/src/main/java/org/jclouds/providers/ProviderMetadata.java index 3fec3088bc..8542fd0c63 100644 --- a/core/src/main/java/org/jclouds/providers/ProviderMetadata.java +++ b/core/src/main/java/org/jclouds/providers/ProviderMetadata.java @@ -21,35 +21,125 @@ package org.jclouds.providers; import java.net.URI; import java.util.Set; +import org.jclouds.apis.ApiMetadata; import org.jclouds.javax.annotation.Nullable; /** - * The ProviderMetadata interface allows jclouds to provide a plugin framework for gathering cloud - * provider metadata. + * The ProviderMetadata interface allows jclouds to provide a plugin framework + * for gathering cloud provider metadata. * * @author Jeremy Whitlock */ public interface ProviderMetadata { - + /** + * @see ApiMetadata#BLOBSTORE_TYPE + */ + @Deprecated public static final String BLOBSTORE_TYPE = "blobstore"; + /** + * @see ApiMetadata#COMPUTE_TYPE + */ + @Deprecated public static final String COMPUTE_TYPE = "compute"; + /** + * @see ApiMetadata#LOADBALANCER_TYPE + */ + @Deprecated public static final String LOADBALANCER_TYPE = "loadbalancer"; + /** + * @see ApiMetadata#TABLE_TYPE + */ + @Deprecated public static final String TABLE_TYPE = "table"; + /** + * @see ApiMetadata#QUEUE_TYPE + */ + @Deprecated public static final String QUEUE_TYPE = "queue"; + /** + * @see ApiMetadata#MONITOR_TYPE + */ + @Deprecated public static final String MONITOR_TYPE = "monitor"; + /** + * + * @author Adrian Cole + * @since 1.5 + */ + public static interface Builder> { + /** + * @see ProviderMetadata#getId() + */ + B id(String id); + + /** + * @see ProviderMetadata#getName() + */ + B name(String name); + + /** + * @see ProviderMetadata#getApi() + */ + B api(ApiMetadata api); + + /** + * @see ProviderMetadata#getConsole() + */ + B console(@Nullable URI console); + + /** + * @see ProviderMetadata#getHomepage() + */ + B homepage(@Nullable URI homepage); + + /** + * @see ProviderMetadata#getLinkedServices() + */ + B linkedServices(Iterable linkedServices); + + /** + * @see ProviderMetadata#getLinkedServices() + */ + B linkedServices(String... linkedServices); + + /** + * @see ProviderMetadata#getLinkedServices() + */ + B linkedService(String linkedService); + + /** + * @see ProviderMetadata#getIso3166Code() + */ + B iso3166Codes(Iterable iso3166Codes); + + /** + * @see ProviderMetadata#getIso3166Code() + */ + B iso3166Codes(String... iso3166Codes); + + /** + * @see ProviderMetadata#getIso3166Code() + */ + B iso3166Code(String iso3166Code); + + ProviderMetadata build(); + + B fromProviderMetadata(ProviderMetadata in); + } + + /** + * @see Builder + * @since 1.5 + */ + Builder toBuilder(); + /** * * @return the provider's unique identifier */ public String getId(); - /** - * - * @return the provider's type - */ - public String getType(); - /** * * @return the name (display name) of the provider @@ -58,18 +148,49 @@ public interface ProviderMetadata { /** * - * @return the name (display name) of an identity on this provider (ex. user, email, account, - * apikey) + * @see #getApi() + * @see ApiMetadata#getType */ + @Deprecated + public String getType(); + + /** + * + * @return the provider's api + * @since 1.5 + */ + public ApiMetadata getApi(); + + /** + * + * @see #getApi() + * @see ApiMetadata#getIdentityName + */ + @Deprecated public String getIdentityName(); /** * - * @return the name (display name) of a credential on this provider, or null if there is none - * (ex. password, secret, rsaKey) + * @see #getApi() + * @see ApiMetadata#getCredentialName + */ + @Deprecated + public String getCredentialName(); + + /** + * + * @see #getApi() + * @see ApiMetadata#getDocumentation + */ + @Deprecated + public URI getApiDocumentation(); + + /** + * + * @return the url for the provider's console, or null if one doesn't exist */ @Nullable - public String getCredentialName(); + public URI getConsole(); /** * @@ -77,18 +198,6 @@ public interface ProviderMetadata { */ public URI getHomepage(); - /** - * - * @return the url for the provider's console - */ - public URI getConsole(); - - /** - * - * @return the url for the API documentation related to this service - */ - public URI getApiDocumentation(); - /** * * @return all known services linked to the same account on this provider diff --git a/core/src/main/java/org/jclouds/providers/ProviderPredicates.java b/core/src/main/java/org/jclouds/providers/ProviderPredicates.java index 8df155cc15..cb3c0658c5 100644 --- a/core/src/main/java/org/jclouds/providers/ProviderPredicates.java +++ b/core/src/main/java/org/jclouds/providers/ProviderPredicates.java @@ -18,6 +18,8 @@ */ package org.jclouds.providers; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; import org.jclouds.util.Preconditions2; import com.google.common.base.Preconditions; @@ -26,14 +28,14 @@ import com.google.common.base.Predicates; /** * Container for provider filters (predicates). - * + * * @author Jeremy Whitlock */ public class ProviderPredicates { /** * Returns all providers available to jclouds regardless of type. - * + * * @return all available providers */ public static Predicate all() { @@ -42,10 +44,10 @@ public class ProviderPredicates { /** * Returns all providers with the given id. - * + * * @param id * the id of the provider to return - * + * * @return the providers with the given id */ public static Predicate id(final String id) { @@ -71,21 +73,21 @@ public class ProviderPredicates { /** * Returns all providers with the given type. - * + * * @param type * the type of the provider to return - * + * * @return the providers with the given type */ - public static Predicate type(final String type) { - Preconditions2.checkNotEmpty(type, "type must be defined"); + public static Predicate type(final ApiType type) { + Preconditions.checkNotNull(type, "type must be defined"); return new Predicate() { /** * {@inheritDoc} */ @Override public boolean apply(ProviderMetadata providerMetadata) { - return providerMetadata.getType().equals(type); + return providerMetadata.getApi().getType().equals(type); } /** @@ -99,10 +101,19 @@ public class ProviderPredicates { } /** - * Returns the providers that are bound to the same location as the given ISO 3166 code. + * @see #type(ApiMetadata) + */ + @Deprecated + public static Predicate type(final String type) { + return type(ApiType.fromValue(type)); + } + + /** + * Returns the providers that are bound to the same location as the given ISO + * 3166 code. * * @param isoCode - * the ISO 3166 code to filter providers by + * the ISO 3166 code to filter providers by * * @return the providers with the given ISO 3166 code */ @@ -129,10 +140,11 @@ public class ProviderPredicates { } /** - * Return all providers that have at least one ISO 3166 code in common with the given provider metadata. + * Return all providers that have at least one ISO 3166 code in common with + * the given provider metadata. * * @param refProviderMetadata - * the provider metadata to use to filter providers by + * the provider metadata to use to filter providers by * * @return the providers that have at least one ISO 3166 code in common */ @@ -146,10 +158,11 @@ public class ProviderPredicates { @Override public boolean apply(ProviderMetadata providerMetadata) { for (String refIso3166Code : refProviderMetadata.getIso3166Codes()) { - // Return only if the potential provider contains the same ISO 3166 code and the provider and + // Return only if the potential provider contains the same ISO + // 3166 code and the provider and // reference provider are not the same. - if (providerContainsIso3166Code(providerMetadata, refIso3166Code) && - !refProviderMetadata.equals(providerMetadata)) { + if (providerContainsIso3166Code(providerMetadata, refIso3166Code) + && !refProviderMetadata.equals(providerMetadata)) { return true; } } @@ -167,19 +180,20 @@ public class ProviderPredicates { } /** - * Returns whether or not the provided provider contains the ISO 3166 code provider or is within the same - * "global" region, like "US" would contain "US-*". + * Returns whether or not the provided provider contains the ISO 3166 code + * provider or is within the same "global" region, like "US" would contain + * "US-*". * * @param providerMetadata - * the provider metadata to search + * the provider metadata to search * @param iso3166Code - * the ISO 3166 code to search the provider metadata for + * the ISO 3166 code to search the provider metadata for * * @return the result */ private static boolean providerContainsIso3166Code(ProviderMetadata providerMetadata, String iso3166Code) { for (String availCode : providerMetadata.getIso3166Codes()) { - if(iso3166Code.indexOf('-') == -1) { + if (iso3166Code.indexOf('-') == -1) { if (availCode.startsWith(iso3166Code + "-")) { return true; } @@ -190,4 +204,33 @@ public class ProviderPredicates { return false; } + + /** + * Returns all providers with the given api. + * + * @param type + * the type of the provider to return + * + * @return the providers with the given api + */ + public static Predicate api(final ApiMetadata api) { + Preconditions.checkNotNull(api, "api must be defined"); + return new Predicate() { + /** + * {@inheritDoc} + */ + @Override + public boolean apply(ProviderMetadata providerMetadata) { + return providerMetadata.getApi().equals(api); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return "api(" + api + ")"; + } + }; + } } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/providers/Providers.java b/core/src/main/java/org/jclouds/providers/Providers.java index 8716fedd46..26d8b5d045 100644 --- a/core/src/main/java/org/jclouds/providers/Providers.java +++ b/core/src/main/java/org/jclouds/providers/Providers.java @@ -24,6 +24,9 @@ import static com.google.common.collect.Iterables.find; import java.util.NoSuchElementException; import java.util.ServiceLoader; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; + import com.google.common.base.Predicates; /** @@ -34,7 +37,8 @@ import com.google.common.base.Predicates; public class Providers { /** - * Returns the providers located on the classpath via {@link java.util.ServiceLoader}. + * Returns the providers located on the classpath via + * {@link java.util.ServiceLoader}. * * @return all available providers loaded from classpath via ServiceLoader */ @@ -68,52 +72,52 @@ public class Providers { /** * Returns the providers that are of type - * {@link org.jclouds.providers.ProviderMetadata#BLOBSTORE_TYPE}. + * {@link org.jclouds.providers.ProviderMetadata#BLOBSTORE}. * * @return the blobstore providers */ public static Iterable allBlobStore() { - return filter(all(), ProviderPredicates.type(ProviderMetadata.BLOBSTORE_TYPE)); + return filter(all(), ProviderPredicates.type(ApiType.BLOBSTORE)); } /** * Returns the providers that are of type - * {@link org.jclouds.providers.ProviderMetadata#COMPUTE_TYPE}. + * {@link org.jclouds.providers.ProviderMetadata#COMPUTE}. * * @return the compute service providers */ public static Iterable allCompute() { - return filter(all(), ProviderPredicates.type(ProviderMetadata.COMPUTE_TYPE)); + return filter(all(), ProviderPredicates.type(ApiType.COMPUTE)); } /** * Returns the providers that are of type - * {@link org.jclouds.providers.ProviderMetadata#QUEUE_TYPE}. + * {@link org.jclouds.providers.ProviderMetadata#QUEUE}. * * @return the queue service providers */ public static Iterable allQueue() { - return filter(all(), ProviderPredicates.type(ProviderMetadata.QUEUE_TYPE)); + return filter(all(), ProviderPredicates.type(ApiType.QUEUE)); } /** * Returns the providers that are of type - * {@link org.jclouds.providers.ProviderMetadata#TABLE_TYPE}. + * {@link org.jclouds.providers.ProviderMetadata#TABLE}. * * @return the table service providers */ public static Iterable allTable() { - return filter(all(), ProviderPredicates.type(ProviderMetadata.TABLE_TYPE)); + return filter(all(), ProviderPredicates.type(ApiType.TABLE)); } /** * Returns the providers that are of type - * {@link org.jclouds.providers.ProviderMetadata#LOADBALANCER_TYPE}. + * {@link org.jclouds.providers.ProviderMetadata#LOADBALANCER}. * * @return the load balancer service providers */ public static Iterable allLoadBalancer() { - return filter(all(), ProviderPredicates.type(ProviderMetadata.LOADBALANCER_TYPE)); + return filter(all(), ProviderPredicates.type(ApiType.LOADBALANCER)); } /** @@ -124,15 +128,36 @@ public class Providers { * * @return the providers of the provided type */ - public static Iterable ofType(String type) { + public static Iterable ofType(ApiType type) { return filter(all(), ProviderPredicates.type(type)); } /** - * Returns the providers that are bound to the same location as the given ISO 3166 code regardless of type. + * Returns the providers that are of the provided api. + * + * @param api + * the api to providers to return + * + * @return the providers of the provided api + */ + public static Iterable ofApi(ApiMetadata api) { + return filter(all(), ProviderPredicates.api(api)); + } + + /** + * @see #ofType(ApiMetadata) + */ + @Deprecated + public static Iterable ofType(String type) { + return ofType(ApiType.fromValue(type)); + } + + /** + * Returns the providers that are bound to the same location as the given ISO + * 3166 code regardless of type. * * @param isoCode - * the ISO 3166 code to filter providers by + * the ISO 3166 code to filter providers by * * @return the providers bound by the given ISO 3166 code */ @@ -141,25 +166,36 @@ public class Providers { } /** - * Returns the providers that are bound to the same location as the given ISO 3166 code and of the given type. + * Returns the providers that are bound to the same location as the given ISO + * 3166 code and of the given type. * * @param iso3166Code - * the ISO 3166 code to filter providers by + * the ISO 3166 code to filter providers by * @param type - * the type to filter providers by + * the type to filter providers by * - * @return the providers bound by the given ISO 3166 code and of the proper type + * @return the providers bound by the given ISO 3166 code and of the proper + * type */ - public static Iterable boundedByIso3166Code(String iso3166Code, String type) { - return filter(all(), Predicates.and(ProviderPredicates.boundedByIso3166Code(iso3166Code), - ProviderPredicates.type(type))); + public static Iterable boundedByIso3166Code(String iso3166Code, ApiType type) { + return filter(all(), + Predicates.and(ProviderPredicates.boundedByIso3166Code(iso3166Code), ProviderPredicates.type(type))); } /** - * Returns the providers that have at least one common ISO 3166 code in common regardless of type. + * @see #boundedByIso3166Code(String iso3166Code, ApiType) + */ + @Deprecated + public static Iterable boundedByIso3166Code(String iso3166Code, String type) { + return boundedByIso3166Code(iso3166Code, ApiType.fromValue(type)); + } + + /** + * Returns the providers that have at least one common ISO 3166 code in + * common regardless of type. * * @param providerMetadata - * the provider metadata to use to filter providers by + * the provider metadata to use to filter providers by * * @return the providers that share at least one common ISO 3166 code */ @@ -168,17 +204,28 @@ public class Providers { } /** - * Returns the providers that have at least one common ISO 3166 code and are of the given type. + * Returns the providers that have at least one common ISO 3166 code and are + * of the given type. * * @param providerMetadata - * the provider metadata to use to filter providers by + * the provider metadata to use to filter providers by * @param type - * the type to filter providers by + * the type to filter providers by * - * @return the providers that share at least one common ISO 3166 code and of the given type + * @return the providers that share at least one common ISO 3166 code and of + * the given type */ - public static Iterable collocatedWith(ProviderMetadata providerMetadata, String type) { - return filter(all(), Predicates.and(ProviderPredicates.intersectingIso3166Code(providerMetadata), - ProviderPredicates.type(type))); + public static Iterable collocatedWith(ProviderMetadata providerMetadata, ApiType type) { + return filter(all(), + Predicates.and(ProviderPredicates.intersectingIso3166Code(providerMetadata), ProviderPredicates.type(type))); } + + /** + * @see #collocatedWith(ProviderMetadata iso3166Code, ApiType) + */ + @Deprecated + public static Iterable collocatedWith(ProviderMetadata providerMetadata, String type) { + return collocatedWith(providerMetadata, ApiType.fromValue(type)); + } + } diff --git a/core/src/test/java/org/jclouds/apis/ApisTest.java b/core/src/test/java/org/jclouds/apis/ApisTest.java new file mode 100644 index 0000000000..9f945ed06c --- /dev/null +++ b/core/src/test/java/org/jclouds/apis/ApisTest.java @@ -0,0 +1,94 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.apis; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + +import java.util.NoSuchElementException; + +import org.testng.annotations.Test; + +/** + * The ApisTest tests the org.jclouds.apis.Apis class. + * + * @author Jeremy Whitlock + */ +@Test(groups = "unit", testName = "ApisTest") +public class ApisTest { + + private final ApiMetadata testBlobstoreApi = new JcloudsTestBlobStoreApiMetadata(); + private final ApiMetadata testComputeApi = new JcloudsTestComputeApiMetadata(); + private final ApiMetadata testYetAnotherComputeApi = new JcloudsTestYetAnotherComputeApiMetadata(); + + @Test + public void testWithId() { + ApiMetadata apiMetadata; + + try { + apiMetadata = Apis.withId("fake-id"); + fail("Looking for a api with an id that doesn't exist should " + "throw an exceptoin."); + } catch (NoSuchElementException nsee) { + ; // Expected + } + + apiMetadata = Apis.withId(testBlobstoreApi.getId()); + + assertEquals(testBlobstoreApi, apiMetadata); + } + + @Test + public void testOfType() { + Iterable apisMetadata = Apis.ofType(ApiType.BLOBSTORE); + + for (ApiMetadata apiMetadata : apisMetadata) { + assertEquals(testBlobstoreApi, apiMetadata); + } + + apisMetadata = Apis.ofType(ApiType.COMPUTE); + + for (ApiMetadata apiMetadata : apisMetadata) { + if (apiMetadata.getName().equals(testComputeApi.getName())) { + assertEquals(testComputeApi, apiMetadata); + } else { + assertEquals(testYetAnotherComputeApi, apiMetadata); + } + } + + apisMetadata = Apis.ofType(ApiType.UNRECOGNIZED); + + assertEquals(false, apisMetadata.iterator().hasNext()); + } + + @Test + public void testAll() { + Iterable apisMetadata = Apis.all(); + + for (ApiMetadata apiMetadata : apisMetadata) { + if (apiMetadata.getName().equals(testBlobstoreApi.getName())) { + assertEquals(testBlobstoreApi, apiMetadata); + } else if (apiMetadata.getName().equals(testComputeApi.getName())) { + assertEquals(testComputeApi, apiMetadata); + } else { + assertEquals(testYetAnotherComputeApi, apiMetadata); + } + } + } + +} diff --git a/core/src/test/java/org/jclouds/apis/BaseApiMetadataTest.java b/core/src/test/java/org/jclouds/apis/BaseApiMetadataTest.java new file mode 100644 index 0000000000..dc46bf8cea --- /dev/null +++ b/core/src/test/java/org/jclouds/apis/BaseApiMetadataTest.java @@ -0,0 +1,62 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.apis; + +import static org.testng.Assert.assertEquals; + +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; + +/** + * + * @author Jeremy Whitlock + */ +@Test(groups = "unit") +public abstract class BaseApiMetadataTest { + + private final ApiMetadata toTest; + private final ApiType expectedType; + + public BaseApiMetadataTest(ApiMetadata toTest, ApiType expectedType) { + this.toTest = toTest; + this.expectedType = expectedType; + } + + @Test + public void testWithId() { + ApiMetadata apiMetadata = Apis.withId(toTest.getId()); + + assertEquals(toTest, apiMetadata); + } + + // it is ok to have multiple services in the same classpath (ex. ec2 vs elb) + @Test + public void testOfTypeContains() { + ImmutableSet ofType = ImmutableSet.copyOf(Apis.ofType(expectedType)); + assert ofType.contains(toTest) : String.format("%s not found in %s", toTest, ofType); + } + + @Test + public void testAllContains() { + ImmutableSet all = ImmutableSet.copyOf(Apis.all()); + assert all.contains(toTest) : String.format("%s not found in %s", toTest, all); + } + +} \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java new file mode 100644 index 0000000000..7f1cffa226 --- /dev/null +++ b/core/src/test/java/org/jclouds/apis/JcloudsTestBlobStoreApiMetadata.java @@ -0,0 +1,63 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.apis; + +import java.net.URI; + +/** + * Implementation of @ link org.jclouds.types.ApiMetadata} for testing. + * + * @author Jeremy Whitlock , Adrian Cole + */ +public class JcloudsTestBlobStoreApiMetadata extends BaseApiMetadata { + + public JcloudsTestBlobStoreApiMetadata() { + this(builder() + .id("test-blobstore-api") + .type(ApiType.BLOBSTORE) + .name("Test Blobstore Api") + .identityName("user") + .credentialName("password") + .documentation(URI.create("http://jclouds.org/documentation"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected JcloudsTestBlobStoreApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public JcloudsTestBlobStoreApiMetadata build() { + return new JcloudsTestBlobStoreApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java new file mode 100644 index 0000000000..c21f86ccab --- /dev/null +++ b/core/src/test/java/org/jclouds/apis/JcloudsTestComputeApiMetadata.java @@ -0,0 +1,63 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.apis; + +import java.net.URI; + +/** + * Implementation of @ link org.jclouds.types.ApiMetadata} for testing. + * + * @author Jeremy Whitlock , Adrian Cole + */ +public class JcloudsTestComputeApiMetadata extends BaseApiMetadata { + + public JcloudsTestComputeApiMetadata() { + this(builder() + .id("test-compute-api") + .type(ApiType.COMPUTE) + .name("Test Compute Api") + .identityName("user") + .credentialName("password") + .documentation(URI.create("http://jclouds.org/documentation"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected JcloudsTestComputeApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public JcloudsTestComputeApiMetadata build() { + return new JcloudsTestComputeApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java b/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java new file mode 100644 index 0000000000..eb7c35e985 --- /dev/null +++ b/core/src/test/java/org/jclouds/apis/JcloudsTestYetAnotherComputeApiMetadata.java @@ -0,0 +1,64 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.apis; + +import java.net.URI; + +/** + * Implementation of @ link org.jclouds.types.ApiMetadata} for testing. + * + * @author Jeremy Whitlock + */ +public class JcloudsTestYetAnotherComputeApiMetadata extends BaseApiMetadata { + + public JcloudsTestYetAnotherComputeApiMetadata() { + this(builder() + .id("test-yet-another-compute-api") + .type(ApiType.COMPUTE) + .name("Test Yet Another Compute Api") + .identityName("user") + .credentialName("password") + .documentation(URI.create("http://jclouds.org/documentation"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected JcloudsTestYetAnotherComputeApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public JcloudsTestYetAnotherComputeApiMetadata build() { + return new JcloudsTestYetAnotherComputeApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/providers/BaseProviderMetadataTest.java b/core/src/test/java/org/jclouds/providers/BaseProviderMetadataTest.java index e3e773edeb..9c27af317f 100644 --- a/core/src/test/java/org/jclouds/providers/BaseProviderMetadataTest.java +++ b/core/src/test/java/org/jclouds/providers/BaseProviderMetadataTest.java @@ -18,10 +18,13 @@ */ package org.jclouds.providers; +import static com.google.common.base.Preconditions.checkNotNull; import static org.testng.Assert.assertEquals; -import java.util.Set; +import java.util.logging.Logger; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; @@ -33,15 +36,15 @@ import com.google.common.collect.Iterables; */ @Test(groups = "unit") public abstract class BaseProviderMetadataTest { - protected Set allTypes = ImmutableSet.of(ProviderMetadata.BLOBSTORE_TYPE, ProviderMetadata.COMPUTE_TYPE, - ProviderMetadata.LOADBALANCER_TYPE, ProviderMetadata.QUEUE_TYPE, ProviderMetadata.TABLE_TYPE); private final ProviderMetadata toTest; - private final String expectedType; + private final ApiType expectedType; + private final ApiMetadata expectedApi; - public BaseProviderMetadataTest(ProviderMetadata toTest, String expectedType) { - this.toTest = toTest; - this.expectedType = expectedType; + public BaseProviderMetadataTest(ProviderMetadata toTest, ApiMetadata expectedApi) { + this.toTest = checkNotNull(toTest, "toTest must be defined"); + this.expectedApi = checkNotNull(expectedApi, "expectedApi must be defined"); + this.expectedType = expectedApi.getType(); } @Test @@ -51,6 +54,14 @@ public abstract class BaseProviderMetadataTest { assertEquals(toTest, providerMetadata); assert providerMetadata.getLinkedServices().contains(toTest.getId()); } + + @Test + public void testOfApiContains() { + if (expectedApi == null) + Logger.getAnonymousLogger().warning("please update your test class"); + ImmutableSet ofApi = ImmutableSet.copyOf(Providers.ofApi(expectedApi)); + assert ofApi.contains(toTest) : String.format("%s not found in %s", toTest, ofApi); + } // it is ok to have multiple services in the same classpath (ex. ec2 vs elb) @Test diff --git a/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java b/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java index 471951e5f4..265079b3de 100644 --- a/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java +++ b/core/src/test/java/org/jclouds/providers/JcloudsTestBlobStoreProviderMetadata.java @@ -19,7 +19,8 @@ package org.jclouds.providers; import java.net.URI; -import java.util.Set; + +import org.jclouds.apis.JcloudsTestBlobStoreApiMetadata; import com.google.common.collect.ImmutableSet; @@ -30,76 +31,36 @@ import com.google.common.collect.ImmutableSet; */ public class JcloudsTestBlobStoreProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "test-blobstore-provider"; + public JcloudsTestBlobStoreProviderMetadata() { + this(builder() + .api(new JcloudsTestBlobStoreApiMetadata()) + .id("test-blobstore-api") + .name("Test Blobstore Provider") + .homepage(URI.create("http://jclouds.org")) + .console(URI.create("http://jclouds.org/console")) + .iso3166Codes(ImmutableSet.of("US-VA", "US-CA", "US-FL"))); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.BLOBSTORE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected JcloudsTestBlobStoreProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Test Blobstore Provider"; + private static class ConcreteBuilder extends Builder { + + @Override + public JcloudsTestBlobStoreProviderMetadata build() { + return new JcloudsTestBlobStoreProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "user"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "password"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://jclouds.org"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("http://jclouds.org/console"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://jclouds.org/documentation"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-VA", "US-CA", "US-FL"); - } - } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java b/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java index 5a370e4833..c7abbe46ce 100644 --- a/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java +++ b/core/src/test/java/org/jclouds/providers/JcloudsTestComputeProviderMetadata.java @@ -19,7 +19,8 @@ package org.jclouds.providers; import java.net.URI; -import java.util.Set; + +import org.jclouds.apis.JcloudsTestComputeApiMetadata; import com.google.common.collect.ImmutableSet; @@ -30,76 +31,36 @@ import com.google.common.collect.ImmutableSet; */ public class JcloudsTestComputeProviderMetadata extends BaseProviderMetadata { - /** - * {@ see org.jclouds.types.ProviderMetadata#getId()} - */ - @Override - public String getId() { - return "test-compute-provider"; + public JcloudsTestComputeProviderMetadata() { + this(builder() + .api(new JcloudsTestComputeApiMetadata()) + .id("test-compute-api") + .name("Test Compute Provider") + .homepage(URI.create("http://jclouds.org")) + .console(URI.create("http://jclouds.org/console")) + .iso3166Codes(ImmutableSet.of("US-VA", "US-CA"))); } - /** - * {@ see org.jclouds.types.ProviderMetadata#getType()} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected JcloudsTestComputeProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@ see org.jclouds.types.ProviderMetadata#getName()} - */ - @Override - public String getName() { - return "Test Compute Provider"; + private static class ConcreteBuilder extends Builder { + + @Override + public JcloudsTestComputeProviderMetadata build() { + return new JcloudsTestComputeProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "user"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "password"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@ see org.jclouds.types.ProviderMetadata#getHomepage()} - */ - @Override - public URI getHomepage() { - return URI.create("http://jclouds.org"); - } - - /** - * {@ see org.jclouds.types.ProviderMetadata#getConsole()} - */ - @Override - public URI getConsole() { - return URI.create("http://jclouds.org/console"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://jclouds.org/documentation"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-VA", "US-CA"); - } - } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java b/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java index 433b1ea5d5..3297b35840 100644 --- a/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java +++ b/core/src/test/java/org/jclouds/providers/JcloudsTestYetAnotherComputeProviderMetadata.java @@ -19,7 +19,8 @@ package org.jclouds.providers; import java.net.URI; -import java.util.Set; + +import org.jclouds.apis.JcloudsTestComputeApiMetadata; import com.google.common.collect.ImmutableSet; @@ -30,76 +31,36 @@ import com.google.common.collect.ImmutableSet; */ public class JcloudsTestYetAnotherComputeProviderMetadata extends BaseProviderMetadata { - /** - * {@ see org.jclouds.types.ProviderMetadata#getId()} - */ - @Override - public String getId() { - return "test-yet-another-compute-provider"; + public JcloudsTestYetAnotherComputeProviderMetadata() { + this(builder() + .api(new JcloudsTestComputeApiMetadata()) + .id("test-yet-another-compute-provider") + .name("Test Yet Another Compute Provider") + .homepage(URI.create("http://jclouds.org")) + .console(URI.create("http://jclouds.org/console")) + .iso3166Codes(ImmutableSet.of("JP-13"))); } - /** - * {@ see org.jclouds.types.ProviderMetadata#getType()} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected JcloudsTestYetAnotherComputeProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@ see org.jclouds.types.ProviderMetadata#getName()} - */ - @Override - public String getName() { - return "Test Yet Another Compute Provider"; + private static class ConcreteBuilder extends Builder { + + @Override + public JcloudsTestYetAnotherComputeProviderMetadata build() { + return new JcloudsTestYetAnotherComputeProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "user"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "password"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@ see org.jclouds.types.ProviderMetadata#getHomepage()} - */ - @Override - public URI getHomepage() { - return URI.create("http://jclouds.org"); - } - - /** - * {@ see org.jclouds.types.ProviderMetadata#getConsole()} - */ - @Override - public URI getConsole() { - return URI.create("http://jclouds.org/console"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://jclouds.org/documentation"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("JP-13"); - } - } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/providers/ProvidersTest.java b/core/src/test/java/org/jclouds/providers/ProvidersTest.java index b3b84a3c4b..0edf5d158f 100644 --- a/core/src/test/java/org/jclouds/providers/ProvidersTest.java +++ b/core/src/test/java/org/jclouds/providers/ProvidersTest.java @@ -23,16 +23,17 @@ import static org.testng.Assert.fail; import java.util.NoSuchElementException; +import org.jclouds.apis.ApiType; import org.testng.annotations.Test; import com.google.common.collect.Iterables; /** * The ProvidersTest tests the org.jclouds.providers.Providers class. - * + * * @author Jeremy Whitlock */ -@Test( groups = "unit" ) +@Test(groups = "unit", testName = "ProvidersTest") public class ProvidersTest { private final ProviderMetadata testBlobstoreProvider = new JcloudsTestBlobStoreProviderMetadata(); @@ -42,11 +43,10 @@ public class ProvidersTest { @Test public void testWithId() { ProviderMetadata providerMetadata; - + try { providerMetadata = Providers.withId("fake-id"); - fail("Looking for a provider with an id that doesn't exist should " + - "throw an exceptoin."); + fail("Looking for a provider with an id that doesn't exist should " + "throw an exceptoin."); } catch (NoSuchElementException nsee) { ; // Expected } @@ -58,6 +58,30 @@ public class ProvidersTest { @Test public void testOfType() { + Iterable providersMetadata = Providers.ofType(ApiType.BLOBSTORE); + + for (ProviderMetadata providerMetadata : providersMetadata) { + assertEquals(testBlobstoreProvider, providerMetadata); + } + + providersMetadata = Providers.ofType(ApiType.COMPUTE); + + for (ProviderMetadata providerMetadata : providersMetadata) { + if (providerMetadata.getName().equals(testComputeProvider.getName())) { + assertEquals(testComputeProvider, providerMetadata); + } else { + assertEquals(testYetAnotherComputeProvider, providerMetadata); + } + } + + providersMetadata = Providers.ofType(ApiType.UNRECOGNIZED); + + assertEquals(false, providersMetadata.iterator().hasNext()); + } + + @Test + @Deprecated + public void testOfTypeDeprecated() { Iterable providersMetadata = Providers.ofType(ProviderMetadata.BLOBSTORE_TYPE); for (ProviderMetadata providerMetadata : providersMetadata) { @@ -86,10 +110,10 @@ public class ProvidersTest { for (ProviderMetadata providerMetadata : providersMetadata) { if (providerMetadata.getName().equals(testBlobstoreProvider.getName())) { assertEquals(testBlobstoreProvider, providerMetadata); - } else if (providerMetadata.getName().equals(testComputeProvider.getName())){ + } else if (providerMetadata.getName().equals(testComputeProvider.getName())) { assertEquals(testComputeProvider, providerMetadata); } else { - assertEquals(testYetAnotherComputeProvider, providerMetadata); + assertEquals(testYetAnotherComputeProvider, providerMetadata); } } } @@ -104,6 +128,44 @@ public class ProvidersTest { assertEquals(Iterables.size(Providers.boundedByIso3166Code("JP")), 1); assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE")), 0); + // Test filtering by ISO 3166 code and type + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ApiType.BLOBSTORE)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ApiType.COMPUTE)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL", ApiType.BLOBSTORE)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL", ApiType.COMPUTE)), 0); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US", ApiType.BLOBSTORE)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US", ApiType.COMPUTE)), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE", ApiType.BLOBSTORE)), 0); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE", ApiType.COMPUTE)), 0); + } + + @Test + public void testCollocatedWith() { + // Test filtering by collocation alone + assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider)), 1); + assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider)), 1); + assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider)), 0); + + // Test filtering by collocation and type + assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, ApiType.BLOBSTORE)), 0); + assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, ApiType.COMPUTE)), 1); + assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ApiType.COMPUTE)), 0); + assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ApiType.BLOBSTORE)), 1); + assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ApiType.COMPUTE)), 0); + assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ApiType.BLOBSTORE)), 0); + } + + @Test + @Deprecated + public void testBoundedByIso3166CodeDeprecated() { + // Test filtering by ISO 3166 code alone + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA")), 2); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-FL")), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("US")), 2); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("JP-13")), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("JP")), 1); + assertEquals(Iterables.size(Providers.boundedByIso3166Code("FAKE-CODE")), 0); + // Test filtering by ISO 3166 code and type assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ProviderMetadata.BLOBSTORE_TYPE)), 1); assertEquals(Iterables.size(Providers.boundedByIso3166Code("US-CA", ProviderMetadata.COMPUTE_TYPE)), 1); @@ -116,7 +178,8 @@ public class ProvidersTest { } @Test - public void testCollocatedWith() { + @Deprecated + public void testCollocatedWithDeprecated() { // Test filtering by collocation alone assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider)), 1); assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider)), 1); @@ -127,9 +190,9 @@ public class ProvidersTest { assertEquals(Iterables.size(Providers.collocatedWith(testBlobstoreProvider, ProviderMetadata.COMPUTE_TYPE)), 1); assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ProviderMetadata.COMPUTE_TYPE)), 0); assertEquals(Iterables.size(Providers.collocatedWith(testComputeProvider, ProviderMetadata.BLOBSTORE_TYPE)), 1); - assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, - ProviderMetadata.COMPUTE_TYPE)), 0); - assertEquals(Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, - ProviderMetadata.BLOBSTORE_TYPE)), 0); + assertEquals( + Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ProviderMetadata.COMPUTE_TYPE)), 0); + assertEquals( + Iterables.size(Providers.collocatedWith(testYetAnotherComputeProvider, ProviderMetadata.BLOBSTORE_TYPE)), 0); } } diff --git a/core/src/test/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/core/src/test/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..5a98023e24 --- /dev/null +++ b/core/src/test/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1,3 @@ +org.jclouds.apis.JcloudsTestBlobStoreApiMetadata +org.jclouds.apis.JcloudsTestComputeApiMetadata +org.jclouds.apis.JcloudsTestYetAnotherComputeApiMetadata diff --git a/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java b/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java index c916065c8d..1c33e610a5 100644 --- a/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java +++ b/labs/aws-elb/src/main/java/org/jclouds/aws/elb/AWSELBProviderMetadata.java @@ -19,12 +19,9 @@ package org.jclouds.aws.elb; import java.net.URI; -import java.util.Set; +import org.jclouds.elb.ELBApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's Elastic Load Balancing @@ -34,82 +31,38 @@ import com.google.common.collect.ImmutableSet; */ public class AWSELBProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "aws-elb"; + public AWSELBProviderMetadata() { + this(builder() + .id("aws-elb") + .name("Amazon Elastic Load Balancing") + .api(new ELBApiMetadata()) + .homepage(URI.create("http://aws.amazon.com/elasticloadbalancing")) + .console(URI.create("https://console.aws.amazon.com/ec2/home")) + .linkedServices("aws-ec2","aws-elb", "aws-elb", "aws-s3", "aws-simpledb") + .iso3166Codes("US-VA", "US-CA", "BR-SP", "US-OR", "IE", "SG", "JP-13")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.LOADBALANCER_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected AWSELBProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Amazon Elastic Load Balancing"; + private static class ConcreteBuilder extends Builder { + + @Override + public AWSELBProviderMetadata build() { + return new AWSELBProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Access Key ID"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret Access Key"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://aws.amazon.com/elasticloadbalancing"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://console.aws.amazon.com/ec2/home"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("aws-s3", "aws-ec2", "aws-elb", "aws-simpledb"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-VA", "US-CA", "US-OR", "BR-SP", "IE", "SG", "JP-13"); - } } \ No newline at end of file diff --git a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java index f9b4403c9e..7c56d557ac 100644 --- a/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java +++ b/labs/aws-elb/src/test/java/org/jclouds/aws/elb/AWSELBProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.aws.elb; +import org.jclouds.elb.ELBApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -31,6 +31,6 @@ import org.testng.annotations.Test; public class AWSELBProviderTest extends BaseProviderMetadataTest { public AWSELBProviderTest() { - super(new AWSELBProviderMetadata(), ProviderMetadata.LOADBALANCER_TYPE); + super(new AWSELBProviderMetadata(), new ELBApiMetadata()); } } \ No newline at end of file diff --git a/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java b/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java new file mode 100644 index 0000000000..f0397a41a3 --- /dev/null +++ b/labs/elb/src/main/java/org/jclouds/elb/ELBApiMetadata.java @@ -0,0 +1,67 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.elb; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for Amazon's Elastic Load Balancing api. + * + * @author Adrian Cole + */ +public class ELBApiMetadata extends BaseApiMetadata { + + public ELBApiMetadata() { + this(builder() + .id("elb") + .type(ApiType.LOADBALANCER) + .name("Amazon Elastic Load Balancing Api") + .identityName("Access Key ID") + .credentialName("Secret Access Key") + .documentation(URI.create("http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected ELBApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public ELBApiMetadata build() { + return new ELBApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/labs/elb/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/elb/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..612af6e1c7 --- /dev/null +++ b/labs/elb/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.elb.ELBApiMetadata \ No newline at end of file diff --git a/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java b/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java new file mode 100644 index 0000000000..011d2017a1 --- /dev/null +++ b/labs/elb/src/test/java/org/jclouds/elb/ELBApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.elb; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "ELBApiMetadataTest") +public class ELBApiMetadataTest extends BaseApiMetadataTest { + + public ELBApiMetadataTest() { + super(new ELBApiMetadata(), ApiType.LOADBALANCER); + } +} diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java new file mode 100644 index 0000000000..be731d4992 --- /dev/null +++ b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.glesys; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for GleSYS API + * + * @author Adrian Cole + */ +public class GleSYSApiMetadata extends BaseApiMetadata { + + public GleSYSApiMetadata() { + this(builder() + .id("glesys") + .type(ApiType.COMPUTE) + .name("GleSYS API") + .identityName("Username") + .credentialName("API Key") + .documentation(URI.create("https://customer.glesys.com/api.php"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected GleSYSApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public GleSYSApiMetadata build() { + return new GleSYSApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java index e8eb3b6c31..3d5da78f02 100644 --- a/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java +++ b/labs/glesys/src/main/java/org/jclouds/glesys/GleSYSProviderMetadata.java @@ -19,97 +19,47 @@ package org.jclouds.glesys; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** - * Implementation of {@ link org.jclouds.types.ProviderMetadata} for GleSYS. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for GleSYS. * * @author Adrian Cole */ public class GleSYSProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "glesys"; + public GleSYSProviderMetadata() { + this(builder() + .id("glesys") + .name("GleSYS") + .api(new GleSYSApiMetadata()) + .homepage(URI.create("http://www.glesys.com")) + .console(URI.create("https://customer.glesys.com/cloud.php")) + .iso3166Codes("NL-NH","SE-N","US-NY","SE-AB")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected GleSYSProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "GleSYS"; + private static class ConcreteBuilder extends Builder { + + @Override + public GleSYSProviderMetadata build() { + return new GleSYSProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Username"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "API Key"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.glesys.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://customer.glesys.com/cloud.php"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("https://customer.glesys.com/api.php"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("glesys"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("NL-NH","SE-N","US-NY","SE-AB"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/GleSYSProviderTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/GleSYSProviderTest.java index 0b20c7a081..b8a5751814 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/GleSYSProviderTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/GleSYSProviderTest.java @@ -19,7 +19,6 @@ package org.jclouds.glesys; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +29,6 @@ import org.testng.annotations.Test; public class GleSYSProviderTest extends BaseProviderMetadataTest { public GleSYSProviderTest() { - super(new GleSYSProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new GleSYSProviderMetadata(), new GleSYSApiMetadata()); } } diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCApiMetadata.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCApiMetadata.java new file mode 100644 index 0000000000..718387b1af --- /dev/null +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCApiMetadata.java @@ -0,0 +1,50 @@ +package org.jclouds.savvis.vpdc; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for the Savvis Symphony VPDC API + * + * @author Adrian Cole + */ +public class SavvisSymphonyVPDCApiMetadata extends BaseApiMetadata { + + public SavvisSymphonyVPDCApiMetadata() { + this(builder() + .id("savvis-symphonyvpdc") + .type(ApiType.COMPUTE) + .name("Savvis Symphony VPDC API") + .identityName("Username") + .credentialName("Password") + .documentation(URI.create("https://api.savvis.net/doc/spec/api/index.html"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected SavvisSymphonyVPDCApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public SavvisSymphonyVPDCApiMetadata build() { + return new SavvisSymphonyVPDCApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderMetadata.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderMetadata.java index b651672560..35319e9195 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderMetadata.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderMetadata.java @@ -18,13 +18,9 @@ */ package org.jclouds.savvis.vpdc; -import com.google.common.collect.ImmutableSet; - import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Savvis Symphony VPDC services. @@ -32,110 +28,72 @@ import org.jclouds.providers.ProviderMetadata; * @author Kedar Dave */ public class SavvisSymphonyVPDCProviderMetadata extends BaseProviderMetadata { - - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "savvis-symphonyvpdc"; - } - - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; - } - - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Savvis Symphony VPDC"; - } - - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "username"; - } - - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "password"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.savvis.com/en-US/infrastructure-services/Cloud/Pages/SavvisSymphonyVPDC.aspx"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://www.savvisstation.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("https://api.savvis.net/doc/spec/api/index.html"); - } - - /** + public SavvisSymphonyVPDCProviderMetadata() { + this(builder() + .id("savvis-symphonyvpdc") + .name("Savvis Symphony VPDC") + .api(new SavvisSymphonyVPDCApiMetadata()) + .homepage(URI.create("https://api.savvis.net/doc/spec/api/index.html")) + .console(URI.create("https://www.savvisstation.com")) + /** * {@inheritDoc} * list of data centers from savvisstation colocation guide * https://www.savvisstation.com/DocumentViewer?GUID=a95f0387-cbfe-43eb-b25b-4f2b0f68498f&sessionid=SavvisCCC%3ac9a8984b9655b01916be587e5204b2cf * Once we have confirmation from Savvis as to what data centers are used for vpdc deployments, * iso codes for those will be entered here * - * City Code - * Lithia Springs, GA AT1 - * Waltham, MA BO1 - * Waltham, MA BO2 - * Waltham, MA B03 - * Elk Grove Village, IL CH3 - * Chicago, IL CH4 - * Sterling, VA DC2 - * Sterling, VA DC3 - * Sterling, VA DC4 Phase I - * Sterling, VA DC4 Phase II - * Fort Worth, TX DL1 - * Fort Worth, TX DL2 - * El Segundo, CA LA1 - * Jersey City, NJ NJ1 - * Weehawken, NJ NJ2 - * Piscataway, NJ NJ3 - * Piscataway, NJ 2nd floor NJ3 - * Weehawken, NJ NJ2X - * Irvine, CA OC2 - * Santa Clara, CA SC4 - * Santa Clara, CA SC5 - * Santa Clara, CA SC8 - * Santa Clara, CA SC9 - * Tukwila, WA 1st floor SE2 - * Montreal, Canada MR1 - * Toronto, Canada TR1 - * Vancouver, Canada VC1 + * City Code + * Lithia Springs, GA AT1 + * Waltham, MA BO1 + * Waltham, MA BO2 + * Waltham, MA B03 + * Elk Grove Village, IL CH3 + * Chicago, IL CH4 + * Sterling, VA DC2 + * Sterling, VA DC3 + * Sterling, VA DC4 Phase I + * Sterling, VA DC4 Phase II + * Fort Worth, TX DL1 + * Fort Worth, TX DL2 + * El Segundo, CA LA1 + * Jersey City, NJ NJ1 + * Weehawken, NJ NJ2 + * Piscataway, NJ NJ3 + * Piscataway, NJ 2nd floor NJ3 + * Weehawken, NJ NJ2X + * Irvine, CA OC2 + * Santa Clara, CA SC4 + * Santa Clara, CA SC5 + * Santa Clara, CA SC8 + * Santa Clara, CA SC9 + * Tukwila, WA 1st floor SE2 + * Montreal, Canada MR1 + * Toronto, Canada TR1 + * Vancouver, Canada VC1 */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of(""); + .iso3166Codes("US", "CA")); } + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected SavvisSymphonyVPDCProviderMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public SavvisSymphonyVPDCProviderMetadata build() { + return new SavvisSymphonyVPDCProviderMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); + } } \ No newline at end of file diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderTest.java index eac50a6541..9bbca2f6a3 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/SavvisSymphonyVPDCProviderTest.java @@ -19,11 +19,11 @@ package org.jclouds.savvis.vpdc; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** - * The SavvisSymphonyVPDCProviderTest tests the org.jclouds.savvis.vpdc.SavvisSymphonyVPDCProviderMetadata class. + * The SavvisSymphonyVPDCProviderTest tests the + * org.jclouds.savvis.vpdc.SavvisSymphonyVPDCProviderMetadata class. * * @author Kedar Dave */ @@ -31,6 +31,6 @@ import org.testng.annotations.Test; public class SavvisSymphonyVPDCProviderTest extends BaseProviderMetadataTest { public SavvisSymphonyVPDCProviderTest() { - super(new SavvisSymphonyVPDCProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new SavvisSymphonyVPDCProviderMetadata(), new SavvisSymphonyVPDCApiMetadata()); } } \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java new file mode 100644 index 0000000000..293275c8c4 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadata.java @@ -0,0 +1,67 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for VCloud Director 1.5 API + * + * @author Adrian Cole + */ +public class VCloudDirectorApiMetadata extends BaseApiMetadata { + + public VCloudDirectorApiMetadata() { + this(builder() + .id("vcloud-director") + .type(ApiType.COMPUTE) + .name("VCloud Director 1.5 API") + .identityName("User at Organization (user@org)") + .credentialName("Password") + .documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected VCloudDirectorApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public VCloudDirectorApiMetadata build() { + return new VCloudDirectorApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/vcloud-director/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..262e987611 --- /dev/null +++ b/labs/vcloud-director/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata \ No newline at end of file diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java new file mode 100644 index 0000000000..5bd3bcd411 --- /dev/null +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "VCloudDirectorApiMetadataTest") +public class VCloudDirectorApiMetadataTest extends BaseApiMetadataTest { + + public VCloudDirectorApiMetadataTest() { + super(new VCloudDirectorApiMetadata(), ApiType.COMPUTE); + } +} diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java new file mode 100644 index 0000000000..5c7a800a3c --- /dev/null +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/VirtualBoxApiMetadata.java @@ -0,0 +1,67 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.virtualbox; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for VirtualBox API + * + * @author Adrian Cole + */ +public class VirtualBoxApiMetadata extends BaseApiMetadata { + + public VirtualBoxApiMetadata() { + this(builder() + .id("virtualbox") + .type(ApiType.COMPUTE) + .name("VirtualBox API") + .identityName("User") + .credentialName("Password") + .documentation(URI.create("https://www.virtualbox.org/sdkref/index.html"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected VirtualBoxApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public VirtualBoxApiMetadata build() { + return new VirtualBoxApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/labs/virtualbox/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/virtualbox/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..6eeabb66e7 --- /dev/null +++ b/labs/virtualbox/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.virtualbox.VirtualBoxApiMetadata \ No newline at end of file diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java new file mode 100644 index 0000000000..4880ed4d7b --- /dev/null +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/VirtualBoxApiMetadataTest.java @@ -0,0 +1,35 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.virtualbox; + +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "VirtualBoxApiMetadataTest") +public class VirtualBoxApiMetadataTest extends BaseApiMetadataTest { + + public VirtualBoxApiMetadataTest() { + super(new VirtualBoxApiMetadata(), ApiType.COMPUTE); + } +} diff --git a/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java b/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java index d07c5b6e6d..32031a90fe 100644 --- a/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java +++ b/providers/aws-cloudwatch/src/main/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderMetadata.java @@ -19,12 +19,9 @@ package org.jclouds.aws.cloudwatch; import java.net.URI; -import java.util.Set; +import org.jclouds.cloudwatch.CloudWatchApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of @ link org.jclouds.types.ProviderMetadata} for Amazon's CloudWatch @@ -34,82 +31,38 @@ import com.google.common.collect.ImmutableSet; */ public class AWSCloudWatchProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "aws-cloudwatch"; + public AWSCloudWatchProviderMetadata() { + this(builder() + .id("aws-cloudwatch") + .name("Amazon CloudWatch") + .api(new CloudWatchApiMetadata()) + .homepage(URI.create("http://aws.amazon.com/cloudwatch")) + .console(URI.create("https://console.aws.amazon.com/cloudwatch/home")) + .linkedServices("aws-ec2","aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb") + .iso3166Codes("US-VA", "US-CA", "BR-SP", "US-OR", "IE", "SG", "JP-13")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.MONITOR_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected AWSCloudWatchProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Amazon CloudWatch"; + private static class ConcreteBuilder extends Builder { + + @Override + public AWSCloudWatchProviderMetadata build() { + return new AWSCloudWatchProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Access Key ID"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret Access Key"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://aws.amazon.com/cloudwatch"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://console.aws.amazon.com/cloudwatch/home"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("aws-s3", "aws-ec2", "aws-cloudwatch", "aws-simpledb"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-VA", "US-CA", "BR-SP", "US-OR", "IE", "SG", "JP-13"); - } } diff --git a/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java b/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java index 83fb1f3883..77882b1624 100644 --- a/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java +++ b/providers/aws-cloudwatch/src/test/java/org/jclouds/aws/cloudwatch/AWSCloudWatchProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.aws.cloudwatch; +import org.jclouds.cloudwatch.CloudWatchApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -31,6 +31,6 @@ import org.testng.annotations.Test; public class AWSCloudWatchProviderTest extends BaseProviderMetadataTest { public AWSCloudWatchProviderTest() { - super(new AWSCloudWatchProviderMetadata(), ProviderMetadata.MONITOR_TYPE); + super(new AWSCloudWatchProviderMetadata(), new CloudWatchApiMetadata()); } } 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 new file mode 100644 index 0000000000..04cf5b3de4 --- /dev/null +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java @@ -0,0 +1,60 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.aws.ec2; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.ec2.EC2ApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for the Amazon-specific EC2 API + * + * @author Adrian Cole + */ +public class AWSEC2ApiMetadata extends EC2ApiMetadata { + + public AWSEC2ApiMetadata() { + this(builder().fromApiMetadata(new EC2ApiMetadata()) + .id("aws-ec2") + .name("Amazon-specific EC2 API")); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected AWSEC2ApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends EC2ApiMetadataBuilder { + + @Override + public AWSEC2ApiMetadata build() { + return new AWSEC2ApiMetadata(this); + } + } + + private static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java index b77d829f0b..945c4188a1 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java @@ -19,12 +19,8 @@ package org.jclouds.aws.ec2; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@ link org.jclouds.types.ProviderMetadata} for Amazon's @@ -34,83 +30,38 @@ import com.google.common.collect.ImmutableSet; */ public class AWSEC2ProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "aws-ec2"; + public AWSEC2ProviderMetadata() { + this(builder() + .id("aws-ec2") + .name("Amazon Elastic Compute Cloud (EC2)") + .api(new AWSEC2ApiMetadata()) + .homepage(URI.create("http://aws.amazon.com/ec2")) + .console(URI.create("https://console.aws.amazon.com/ec2/home")) + .linkedServices("aws-ec2","aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb") + .iso3166Codes("US-VA", "US-CA", "US-OR", "BR-SP", "IE", "SG", "JP-13")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected AWSEC2ProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Amazon Elastic Compute Cloud (EC2)"; + private static class ConcreteBuilder extends Builder { + + @Override + public AWSEC2ProviderMetadata build() { + return new AWSEC2ProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Access Key ID"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret Access Key"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://aws.amazon.com/ec2/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://console.aws.amazon.com/ec2/home"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://docs.amazonwebservices.com/AWSEC2/latest/APIReference"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("aws-s3", "aws-ec2", "aws-elb", "aws-simpledb"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-VA", "US-CA", "US-OR", "BR-SP", "IE", "SG", "JP-13"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } \ No newline at end of file diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java index 61ecca37a6..5276ad391e 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java @@ -19,7 +19,6 @@ package org.jclouds.aws.ec2; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -31,6 +30,6 @@ import org.testng.annotations.Test; public class AWSEC2ProviderTest extends BaseProviderMetadataTest { public AWSEC2ProviderTest() { - super(new AWSEC2ProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new AWSEC2ProviderMetadata(), new AWSEC2ApiMetadata()); } } \ No newline at end of file diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ApiMetadata.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ApiMetadata.java new file mode 100644 index 0000000000..0b53e4bea9 --- /dev/null +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ApiMetadata.java @@ -0,0 +1,60 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.aws.s3; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.s3.S3ApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for the Amazon-specific S3 API + * + * @author Adrian Cole + */ +public class AWSS3ApiMetadata extends S3ApiMetadata { + + public AWSS3ApiMetadata() { + this(builder().fromApiMetadata(new S3ApiMetadata()) + .id("aws-s3") + .name("Amazon-specific S3 API")); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected AWSS3ApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends S3ApiMetadataBuilder { + + @Override + public AWSS3ApiMetadata build() { + return new AWSS3ApiMetadata(this); + } + } + + private static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java index 57c8a7dfea..a6b758bd36 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/AWSS3ProviderMetadata.java @@ -19,12 +19,8 @@ package org.jclouds.aws.s3; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.providers.ProviderMetadata} for Amazon's Simple Storage Service @@ -34,84 +30,38 @@ import com.google.common.collect.ImmutableSet; */ public class AWSS3ProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "aws-s3"; + public AWSS3ProviderMetadata() { + this(builder() + .id("aws-s3") + .name("Amazon Simple Storage Service (S3)") + .api(new AWSS3ApiMetadata()) + .homepage(URI.create("http://aws.amazon.com/s3")) + .console(URI.create("https://console.aws.amazon.com/s3/home")) + .linkedServices("aws-ec2","aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb") + .iso3166Codes("US", "US-CA", "US-OR", "BR-SP", "IE", "SG", "JP-13")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.BLOBSTORE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected AWSS3ProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Amazon Simple Storage Service (S3)"; + private static class ConcreteBuilder extends Builder { + + @Override + public AWSS3ProviderMetadata build() { + return new AWSS3ProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Access Key ID"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret Access Key"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://aws.amazon.com/s3/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://console.aws.amazon.com/s3/home"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://docs.amazonwebservices.com/AmazonS3/latest/API"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("aws-s3", "aws-ec2", "aws-elb", "aws-simpledb"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US", "US-CA", "US-OR", "BR-SP", "IE", "SG", "JP-13"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } \ No newline at end of file diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ProviderTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ProviderTest.java index 39350787f9..a4fb7bf309 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ProviderTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ProviderTest.java @@ -19,7 +19,6 @@ package org.jclouds.aws.s3; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -31,7 +30,7 @@ import org.testng.annotations.Test; public class AWSS3ProviderTest extends BaseProviderMetadataTest { public AWSS3ProviderTest() { - super(new AWSS3ProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + super(new AWSS3ProviderMetadata(), new AWSS3ApiMetadata()); } } \ No newline at end of file diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java new file mode 100644 index 0000000000..3c2e3bd5f2 --- /dev/null +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobApiMetadata.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.azureblob; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for Microsoft Azure Blob Service API + * + * @author Adrian Cole + */ +public class AzureBlobApiMetadata extends BaseApiMetadata { + + public AzureBlobApiMetadata() { + this(builder() + .id("azureblob") + .type(ApiType.BLOBSTORE) + .name("Microsoft Azure Blob Service API") + .identityName("Account Name") + .credentialName("Access Key") + .documentation(URI.create("http://msdn.microsoft.com/en-us/library/dd135733.aspx"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected AzureBlobApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public AzureBlobApiMetadata build() { + return new AzureBlobApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java index 8838e280c7..c57e8beb53 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobProviderMetadata.java @@ -19,12 +19,8 @@ package org.jclouds.azureblob; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Microsoft Azure Blob Service. @@ -32,85 +28,37 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ public class AzureBlobProviderMetadata extends BaseProviderMetadata { - - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "azureblob"; + public AzureBlobProviderMetadata() { + this(builder() + .id("azureblob") + .name("Microsoft Azure Blob Service") + .api(new AzureBlobApiMetadata()) + .homepage(URI.create("http://www.microsoft.com/windowsazure/storage/")) + .console(URI.create("https://windows.azure.com/default.aspx")) + .linkedServices("azureblob", "azurequeue", "azuretable") + .iso3166Codes("US-TX","US-IL","IE-D","SG","NL-NH","HK")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.BLOBSTORE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected AzureBlobProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Microsoft Azure Blob Service"; + private static class ConcreteBuilder extends Builder { + + @Override + public AzureBlobProviderMetadata build() { + return new AzureBlobProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Account Name"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Access Key"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.microsoft.com/windowsazure/storage/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://windows.azure.com/default.aspx"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://msdn.microsoft.com/en-us/library/dd135733.aspx"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("azureblob", "azurequeue", "azuretable"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-TX","US-IL","IE-D","SG","NL-NH","HK"); - } - } \ No newline at end of file diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobProviderTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobProviderTest.java index 71c07ab6c2..d37a651909 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobProviderTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobProviderTest.java @@ -19,7 +19,6 @@ package org.jclouds.azureblob; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +29,6 @@ import org.testng.annotations.Test; public class AzureBlobProviderTest extends BaseProviderMetadataTest { public AzureBlobProviderTest() { - super(new AzureBlobProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + super(new AzureBlobProviderMetadata(), new AzureBlobApiMetadata()); } } \ No newline at end of file diff --git a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java b/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java index 5124d84ee4..ad88c48042 100644 --- a/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java +++ b/providers/bluelock-vcloud-zone01/src/main/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderMetadata.java @@ -19,12 +19,9 @@ package org.jclouds.bluelock.vcloud.zone01; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; +import org.jclouds.vcloud.VCloudApiMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Bluelock vCloud Zone 1. @@ -33,84 +30,37 @@ import com.google.common.collect.ImmutableSet; */ public class BluelockVCloudZone01ProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "bluelock-vcloud-zone01"; + public BluelockVCloudZone01ProviderMetadata() { + this(builder() + .id("bluelock-vcloud-zone01") + .name("Bluelock vCloud Zone 1") + .api(new VCloudApiMetadata()) + .homepage(URI.create("http://www.bluelock.com/bluelock-cloud-hosting")) + .console(URI.create("https://zone01.bluelock.com/cloud/org/YOUR_ORG_HERE")) + .iso3166Codes("US-IN")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected BluelockVCloudZone01ProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Bluelock vCloud Zone 1"; + private static class ConcreteBuilder extends Builder { + + @Override + public BluelockVCloudZone01ProviderMetadata build() { + return new BluelockVCloudZone01ProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "User at Organization (user@org)"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Password"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.bluelock.com/bluelock-cloud-hosting"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://zone01.bluelock.com/cloud/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("bluelock-vcloud-zone01"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-IN"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } diff --git a/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderTest.java b/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderTest.java index b0f8f318a4..589c13500e 100644 --- a/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderTest.java +++ b/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/BluelockVCloudZone01ProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.bluelock.vcloud.zone01; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; +import org.jclouds.vcloud.VCloudApiMetadata; import org.testng.annotations.Test; /** @@ -30,6 +30,6 @@ import org.testng.annotations.Test; public class BluelockVCloudZone01ProviderTest extends BaseProviderMetadataTest { public BluelockVCloudZone01ProviderTest() { - super(new BluelockVCloudZone01ProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new BluelockVCloudZone01ProviderMetadata(), new VCloudApiMetadata()); } } diff --git a/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java b/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java index 1068fc6ce2..f50f10a9cc 100644 --- a/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java +++ b/providers/cloudfiles-uk/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderMetadata.java @@ -19,65 +19,49 @@ package org.jclouds.rackspace.cloudfiles; import java.net.URI; -import java.util.Set; -import org.jclouds.cloudfiles.CloudFilesProviderMetadata; - -import com.google.common.collect.ImmutableSet; +import org.jclouds.cloudfiles.CloudFilesApiMetadata; +import org.jclouds.providers.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Files in UK. * * @author Adrian Cole */ -public class CloudFilesUKProviderMetadata extends CloudFilesProviderMetadata { +public class CloudFilesUKProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "cloudfiles-uk"; + public CloudFilesUKProviderMetadata() { + this(builder() + .id("cloudfiles-uk") + .name("Rackspace Cloud Files UK") + .api(new CloudFilesApiMetadata()) + .homepage(URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-files")) + .console(URI.create("https://lon.manage.rackspacecloud.com")) + .linkedServices("cloudfiles-uk", "cloudservers-uk", "cloudloadbalancers-uk") + .iso3166Codes("GB-SLG")); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Rackspace Cloud Files UK"; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudFilesUKProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-files"); + private static class ConcreteBuilder extends Builder { + + @Override + public CloudFilesUKProviderMetadata build() { + return new CloudFilesUKProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://lon.manage.rackspacecloud.com"); + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("cloudfiles-uk", "cloudservers-uk", "cloudloadbalancers-uk"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("GB-SLG"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } \ No newline at end of file diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderTest.java index be2ed86ad6..b8b2b83f11 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.rackspace.cloudfiles; +import org.jclouds.cloudfiles.CloudFilesApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +30,6 @@ import org.testng.annotations.Test; public class CloudFilesUKProviderTest extends BaseProviderMetadataTest { public CloudFilesUKProviderTest() { - super(new CloudFilesUKProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + super(new CloudFilesUKProviderMetadata(), new CloudFilesApiMetadata()); } } \ No newline at end of file diff --git a/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java b/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java index e4833ddf43..c30dad5cdb 100644 --- a/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java +++ b/providers/cloudfiles-us/src/main/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderMetadata.java @@ -19,11 +19,9 @@ package org.jclouds.rackspace.cloudfiles; import java.net.URI; -import java.util.Set; -import org.jclouds.cloudfiles.CloudFilesProviderMetadata; - -import com.google.common.collect.ImmutableSet; +import org.jclouds.cloudfiles.CloudFilesApiMetadata; +import org.jclouds.providers.BaseProviderMetadata; /** @@ -31,54 +29,39 @@ import com.google.common.collect.ImmutableSet; * * @author Adrian Cole */ -public class CloudFilesUSProviderMetadata extends CloudFilesProviderMetadata { +public class CloudFilesUSProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "cloudfiles-us"; + public CloudFilesUSProviderMetadata() { + this(builder() + .id("cloudfiles-us") + .name("Rackspace Cloud Files US") + .api(new CloudFilesApiMetadata()) + .homepage(URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/files")) + .console(URI.create("https://manage.rackspacecloud.com")) + .linkedServices("cloudfiles-us", "cloudservers-us", "cloudloadbalancers-us") + .iso3166Codes("US-IL","US-TX")); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Rackspace Cloud Files US"; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudFilesUSProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/files"); + private static class ConcreteBuilder extends Builder { + + @Override + public CloudFilesUSProviderMetadata build() { + return new CloudFilesUSProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://manage.rackspacecloud.com"); + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("cloudfiles-us", "cloudservers-us", "cloudloadbalancers-us"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-IL","US-TX"); - } - } \ No newline at end of file diff --git a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderTest.java b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderTest.java index bb2c4cb0e7..54c8da6584 100644 --- a/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderTest.java +++ b/providers/cloudfiles-us/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUSProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.rackspace.cloudfiles; +import org.jclouds.cloudfiles.CloudFilesApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +30,6 @@ import org.testng.annotations.Test; public class CloudFilesUSProviderTest extends BaseProviderMetadataTest { public CloudFilesUSProviderTest() { - super(new CloudFilesUSProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + super(new CloudFilesUSProviderMetadata(), new CloudFilesApiMetadata()); } } \ No newline at end of file diff --git a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java index 7143076db6..6069979007 100644 --- a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java +++ b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java @@ -19,65 +19,48 @@ package org.jclouds.rackspace.cloudloadbalancers; import java.net.URI; -import java.util.Set; -import org.jclouds.cloudloadbalancers.CloudLoadBalancersProviderMetadata; - -import com.google.common.collect.ImmutableSet; +import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata; +import org.jclouds.providers.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud LoadBalancers in UK. * * @author Dan Lo Bianco */ -public class CloudLoadBalancersUKProviderMetadata extends CloudLoadBalancersProviderMetadata { +public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "cloudloadbalancers-uk"; + public CloudLoadBalancersUKProviderMetadata() { + this(builder() + .id("cloudloadbalancers-uk") + .name("Rackspace Cloud Load Balancers UK") + .api(new CloudLoadBalancersApiMetadata()) + .homepage(URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-load-balancers")) + .console(URI.create("https://lon.manage.rackspacecloud.com")) + .linkedServices("cloudloadbalancers-uk", "cloudservers-uk", "cloudfiles-uk") + .iso3166Codes("GB-SLG")); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Rackspace Cloud Load Balancers UK"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-load-balancers/"); + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudLoadBalancersUKProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://lon.manage.rackspacecloud.com"); + private static class ConcreteBuilder extends Builder { + + @Override + public CloudLoadBalancersUKProviderMetadata build() { + return new CloudLoadBalancersUKProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("cloudfiles-uk", "cloudservers-uk", "cloudloadbalancers-uk"); + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("GB-SLG"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - } \ No newline at end of file diff --git a/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderTest.java b/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderTest.java index 6d303f464a..ec189cfdd6 100644 --- a/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderTest.java +++ b/providers/cloudloadbalancers-uk/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.rackspace.cloudloadbalancers; +import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +30,6 @@ import org.testng.annotations.Test; public class CloudLoadBalancersUKProviderTest extends BaseProviderMetadataTest { public CloudLoadBalancersUKProviderTest() { - super(new CloudLoadBalancersUKProviderMetadata(), ProviderMetadata.LOADBALANCER_TYPE); + super(new CloudLoadBalancersUKProviderMetadata(), new CloudLoadBalancersApiMetadata()); } } \ No newline at end of file diff --git a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java index 1b266aab75..4249495ec9 100644 --- a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java +++ b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java @@ -19,65 +19,48 @@ package org.jclouds.rackspace.cloudloadbalancers; import java.net.URI; -import java.util.Set; -import org.jclouds.cloudloadbalancers.CloudLoadBalancersProviderMetadata; - -import com.google.common.collect.ImmutableSet; +import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata; +import org.jclouds.providers.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud LoadBalancers in US. * * @author Adrian Cole */ -public class CloudLoadBalancersUSProviderMetadata extends CloudLoadBalancersProviderMetadata { +public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "cloudloadbalancers-us"; + public CloudLoadBalancersUSProviderMetadata() { + this(builder() + .id("cloudloadbalancers-us") + .name("Rackspace Cloud Load Balancers US") + .api(new CloudLoadBalancersApiMetadata()) + .homepage(URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/loadbalancers")) + .console(URI.create("https://manage.rackspacecloud.com")) + .linkedServices("cloudloadbalancers-us", "cloudservers-us", "cloudfiles-us") + .iso3166Codes("US-IL","US-TX")); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Rackspace Cloud Load Balancers US"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/loadbalancers"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://manage.rackspacecloud.com"); + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudLoadBalancersUSProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("cloudfiles-us", "cloudservers-us", "cloudloadbalancers-us"); + private static class ConcreteBuilder extends Builder { + + @Override + public CloudLoadBalancersUSProviderMetadata build() { + return new CloudLoadBalancersUSProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-IL","US-TX"); + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); + } } \ No newline at end of file diff --git a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderTest.java b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderTest.java index 9c28808057..7fdf7435f4 100644 --- a/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderTest.java +++ b/providers/cloudloadbalancers-us/src/test/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.rackspace.cloudloadbalancers; +import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +30,6 @@ import org.testng.annotations.Test; public class CloudLoadBalancersUSProviderTest extends BaseProviderMetadataTest { public CloudLoadBalancersUSProviderTest() { - super(new CloudLoadBalancersUSProviderMetadata(), ProviderMetadata.LOADBALANCER_TYPE); + super(new CloudLoadBalancersUSProviderMetadata(), new CloudLoadBalancersApiMetadata()); } } \ No newline at end of file diff --git a/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java b/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java index 4704760290..01c6e552ea 100644 --- a/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java +++ b/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java @@ -19,12 +19,10 @@ package org.jclouds.cloudonestorage; import java.net.URI; -import java.util.Set; +import org.jclouds.atmos.AtmosApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import com.google.common.collect.ImmutableSet; - /** * Implementation of {@ link org.jclouds.types.ProviderMetadata} for PEER1's * CloudOne Storage provider. @@ -33,76 +31,36 @@ import com.google.common.collect.ImmutableSet; */ public class CloudOneStorageProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "cloudonestorage"; + public CloudOneStorageProviderMetadata() { + this(builder() + .id("cloudonestorage") + .name("PEER1 CloudOne Storage") + .api(new AtmosApiMetadata()) + .homepage(URI.create("http://www.peer1.com/hosting/cloudone-storage.php")) + .console(URI.create("https://mypeer1.com/")) + .iso3166Codes("US-GA", "US-TX")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return BLOBSTORE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudOneStorageProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "PEER1 CloudOne Storage"; + private static class ConcreteBuilder extends Builder { + + @Override + public CloudOneStorageProviderMetadata build() { + return new CloudOneStorageProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Subtenant ID (UID)"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Shared Secret"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.peer1.com/hosting/cloudone-storage.php"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://mypeer1.com/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://www.peer1.com/sites/default/files/pdf/Atmos_System_Management_API_Guide_1.3.0A.pdf"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-GA", "US-TX"); - } - } diff --git a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/CloudOneStorageProviderTest.java b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/CloudOneStorageProviderTest.java index 30e5372c79..0b1a45be58 100644 --- a/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/CloudOneStorageProviderTest.java +++ b/providers/cloudonestorage/src/test/java/org/jclouds/cloudonestorage/CloudOneStorageProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.cloudonestorage; +import org.jclouds.atmos.AtmosApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -31,7 +31,7 @@ import org.testng.annotations.Test; public class CloudOneStorageProviderTest extends BaseProviderMetadataTest { public CloudOneStorageProviderTest() { - super(new CloudOneStorageProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + super(new CloudOneStorageProviderMetadata(), new AtmosApiMetadata()); } } \ No newline at end of file diff --git a/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java b/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java index 978b0f6aec..a2dee8abc8 100644 --- a/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java +++ b/providers/cloudservers-uk/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderMetadata.java @@ -19,65 +19,49 @@ package org.jclouds.rackspace.cloudservers; import java.net.URI; -import java.util.Set; -import org.jclouds.cloudservers.CloudServersProviderMetadata; - -import com.google.common.collect.ImmutableSet; +import org.jclouds.cloudservers.CloudServersApiMetadata; +import org.jclouds.providers.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Cloud Servers in UK. * * @author Adrian Cole */ -public class CloudServersUKProviderMetadata extends CloudServersProviderMetadata { +public class CloudServersUKProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "cloudservers-uk"; + public CloudServersUKProviderMetadata() { + this(builder() + .id("cloudservers-uk") + .name("Rackspace Cloud Servers UK") + .api(new CloudServersApiMetadata()) + .homepage(URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-servers")) + .console(URI.create("https://lon.manage.rackspacecloud.com")) + .linkedServices("cloudloadbalancers-uk", "cloudservers-uk", "cloudfiles-uk") + .iso3166Codes("GB-SLG")); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Rackspace Cloud Servers UK"; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudServersUKProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.rackspace.co.uk/cloud-hosting/cloud-products/cloud-servers"); + private static class ConcreteBuilder extends Builder { + + @Override + public CloudServersUKProviderMetadata build() { + return new CloudServersUKProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://lon.manage.rackspacecloud.com"); + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("cloudfiles-uk", "cloudservers-uk", "cloudloadbalancers-uk"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("GB-SLG"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } \ No newline at end of file diff --git a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderTest.java b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderTest.java index 602c82f2db..e0011cc6e1 100644 --- a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderTest.java +++ b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUKProviderTest.java @@ -35,8 +35,8 @@ */ package org.jclouds.rackspace.cloudservers; +import org.jclouds.cloudservers.CloudServersApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -47,6 +47,6 @@ import org.testng.annotations.Test; public class CloudServersUKProviderTest extends BaseProviderMetadataTest { public CloudServersUKProviderTest() { - super(new CloudServersUKProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new CloudServersUKProviderMetadata(), new CloudServersApiMetadata()); } } \ No newline at end of file diff --git a/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java b/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java index 2ae4c622ab..698f96f954 100644 --- a/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java +++ b/providers/cloudservers-us/src/main/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderMetadata.java @@ -19,11 +19,9 @@ package org.jclouds.rackspace.cloudservers; import java.net.URI; -import java.util.Set; -import org.jclouds.cloudservers.CloudServersProviderMetadata; - -import com.google.common.collect.ImmutableSet; +import org.jclouds.cloudservers.CloudServersApiMetadata; +import org.jclouds.providers.BaseProviderMetadata; /** @@ -31,54 +29,39 @@ import com.google.common.collect.ImmutableSet; * * @author Adrian Cole */ -public class CloudServersUSProviderMetadata extends CloudServersProviderMetadata { +public class CloudServersUSProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "cloudservers-us"; + public CloudServersUSProviderMetadata() { + this(builder() + .id("cloudservers-us") + .name("Rackspace Cloud Servers US") + .api(new CloudServersApiMetadata()) + .homepage(URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/servers")) + .console(URI.create("https://manage.rackspacecloud.com")) + .linkedServices("cloudloadbalancers-us", "cloudservers-us", "cloudfiles-us") + .iso3166Codes("US-IL", "US-TX")); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Rackspace Cloud Servers US"; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudServersUSProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.rackspace.com/cloud/cloud_hosting_products/servers"); + private static class ConcreteBuilder extends Builder { + + @Override + public CloudServersUSProviderMetadata build() { + return new CloudServersUSProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://manage.rackspacecloud.com"); + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("cloudfiles-us", "cloudservers-us", "cloudloadbalancers-us"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-IL", "US-TX"); - } - } \ No newline at end of file diff --git a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderTest.java b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderTest.java index 71da624538..6f4ec86df6 100644 --- a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderTest.java +++ b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/CloudServersUSProviderTest.java @@ -35,8 +35,8 @@ */ package org.jclouds.rackspace.cloudservers; +import org.jclouds.cloudservers.CloudServersApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -47,6 +47,6 @@ import org.testng.annotations.Test; public class CloudServersUSProviderTest extends BaseProviderMetadataTest { public CloudServersUSProviderTest() { - super(new CloudServersUSProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new CloudServersUSProviderMetadata(), new CloudServersApiMetadata()); } } \ No newline at end of file diff --git a/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java b/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java index b2e7509a06..12970c054d 100644 --- a/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java +++ b/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java @@ -19,97 +19,46 @@ package org.jclouds.cloudsigma; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for CloudSigma LasVegas. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for CloudSigma Las Vegas. * * @author Adrian Cole */ public class CloudSigmaLasVegasProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "cloudsigma-lvs"; + public CloudSigmaLasVegasProviderMetadata() { + this(builder() + .id("cloudsigma-lvs") + .name("CloudSigma Las Vegas") + .api(new CloudSigmaApiMetadata()) + .homepage(URI.create("http://www.cloudsigma.com/en/our-cloud/features")) + .console(URI.create("https://gui.lvs.cloudsigma.com/")) + .iso3166Codes("US-NV")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudSigmaLasVegasProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "CloudSigma LasVegas"; + private static class ConcreteBuilder extends Builder { + + @Override + public CloudSigmaLasVegasProviderMetadata build() { + return new CloudSigmaLasVegasProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Email"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Password"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.cloudsigma.com/en/our-cloud/features"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://gui.lvs.cloudsigma.com/"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://cloudsigma.com/en/platform-details/the-api"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("cloudsigma-lvs"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-LV"); - } - } diff --git a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderTest.java b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderTest.java index 55aea80ce1..0afe6d819f 100644 --- a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderTest.java +++ b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderTest.java @@ -19,7 +19,6 @@ package org.jclouds.cloudsigma; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +29,6 @@ import org.testng.annotations.Test; public class CloudSigmaLasVegasProviderTest extends BaseProviderMetadataTest { public CloudSigmaLasVegasProviderTest() { - super(new CloudSigmaLasVegasProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new CloudSigmaLasVegasProviderMetadata(), new CloudSigmaApiMetadata()); } } diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java index f4ee3f11c8..483f22eabd 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java @@ -19,12 +19,8 @@ package org.jclouds.cloudsigma; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for CloudSigma Zurich. @@ -33,83 +29,36 @@ import com.google.common.collect.ImmutableSet; */ public class CloudSigmaZurichProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "cloudsigma-zrh"; + public CloudSigmaZurichProviderMetadata() { + this(builder() + .id("cloudsigma-zrh") + .name("CloudSigma Zurich") + .api(new CloudSigmaApiMetadata()) + .homepage(URI.create("http://www.cloudsigma.com/en/our-cloud/features")) + .console(URI.create("https://gui.zrh.cloudsigma.com/")) + .iso3166Codes("CH-ZH")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected CloudSigmaZurichProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "CloudSigma Zurich"; + private static class ConcreteBuilder extends Builder { + + @Override + public CloudSigmaZurichProviderMetadata build() { + return new CloudSigmaZurichProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Email"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Password"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.cloudsigma.com/en/our-cloud/features"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://gui.zrh.cloudsigma.com/"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://cloudsigma.com/en/platform-details/the-api"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("cloudsigma-zrh"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("CH-ZH"); - } - } diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java index 7e6d13cd29..2e9d1d8180 100644 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderTest.java @@ -19,7 +19,6 @@ package org.jclouds.cloudsigma; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +29,6 @@ import org.testng.annotations.Test; public class CloudSigmaZurichProviderTest extends BaseProviderMetadataTest { public CloudSigmaZurichProviderTest() { - super(new CloudSigmaZurichProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new CloudSigmaZurichProviderMetadata(), new CloudSigmaApiMetadata()); } } diff --git a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java index 0f08edcd26..ec5cdd1a42 100644 --- a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java +++ b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java @@ -19,97 +19,47 @@ package org.jclouds.elastichosts; import java.net.URI; -import java.util.Set; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts Toronto Peer 1. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts Los Angeles Peer 1. * * @author Adrian Cole */ public class ElasticHostsPeer1LosAngelesProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "elastichosts-lax-p"; + public ElasticHostsPeer1LosAngelesProviderMetadata() { + this(builder() + .id("elastichosts-lax-p") + .name("ElasticHosts Los Angeles Peer 1") + .api(new ElasticStackApiMetadata()) + .homepage(URI.create("https://lax-p.elastichosts.com")) + .console(URI.create("https://lax-p.elastichosts.com/accounts")) + .iso3166Codes("US-CA")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected ElasticHostsPeer1LosAngelesProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "ElasticHosts Los Angeles Peer 1"; + private static class ConcreteBuilder extends Builder { + + @Override + public ElasticHostsPeer1LosAngelesProviderMetadata build() { + return new ElasticHostsPeer1LosAngelesProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "UUID"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret API key"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("https://lax-p.elastichosts.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://lax-p.elastichosts.com/accounts"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://www.elastichosts.com/cloud-hosting/api"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("elastichosts-lax-p"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-CA"); - } - } diff --git a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderTest.java b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderTest.java index f5a34fc642..bc8e76310a 100644 --- a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderTest.java +++ b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.elastichosts; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +30,6 @@ import org.testng.annotations.Test; public class ElasticHostsPeer1LosAngelesProviderTest extends BaseProviderMetadataTest { public ElasticHostsPeer1LosAngelesProviderTest() { - super(new ElasticHostsPeer1LosAngelesProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new ElasticHostsPeer1LosAngelesProviderMetadata(), new ElasticStackApiMetadata()); } } diff --git a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java index ca6c702052..dcf1e4a97f 100644 --- a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java +++ b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java @@ -19,12 +19,9 @@ package org.jclouds.elastichosts; import java.net.URI; -import java.util.Set; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts London BlueSquare. @@ -33,83 +30,37 @@ import com.google.common.collect.ImmutableSet; */ public class ElasticHostsBlueSquareLondonProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "elastichosts-lon-b"; + public ElasticHostsBlueSquareLondonProviderMetadata() { + this(builder() + .id("elastichosts-lon-b") + .name("ElasticHosts Los Angeles BlueSquare") + .api(new ElasticStackApiMetadata()) + .homepage(URI.create("https://lon-b.elastichosts.com")) + .console(URI.create("https://lon-b.elastichosts.com/accounts")) + .iso3166Codes("GB-LND")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected ElasticHostsBlueSquareLondonProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "ElasticHosts London BlueSquare"; + private static class ConcreteBuilder extends Builder { + + @Override + public ElasticHostsBlueSquareLondonProviderMetadata build() { + return new ElasticHostsBlueSquareLondonProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "UUID"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret API Key"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("https://lon-b.elastichosts.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://lon-b.elastichosts.com/accounts"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://www.elastichosts.com/cloud-hosting/api"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("elastichosts-lon-b"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("GB-LND"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } diff --git a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java index 2e7f7b4cf5..b339d08d62 100644 --- a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java +++ b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.elastichosts; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +30,6 @@ import org.testng.annotations.Test; public class ElasticHostsBlueSquareLondonProviderTest extends BaseProviderMetadataTest { public ElasticHostsBlueSquareLondonProviderTest() { - super(new ElasticHostsBlueSquareLondonProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new ElasticHostsBlueSquareLondonProviderMetadata(), new ElasticStackApiMetadata()); } } diff --git a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java index c98bf03eb3..c68185e919 100644 --- a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java +++ b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java @@ -19,12 +19,9 @@ package org.jclouds.elastichosts; import java.net.URI; -import java.util.Set; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts London Peer 1. @@ -33,83 +30,37 @@ import com.google.common.collect.ImmutableSet; */ public class ElasticHostsPeer1LondonProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "elastichosts-lon-p"; + public ElasticHostsPeer1LondonProviderMetadata() { + this(builder() + .id("elastichosts-lon-p") + .name("ElasticHosts Los Angeles Peer 1") + .api(new ElasticStackApiMetadata()) + .homepage(URI.create("https://lon-p.elastichosts.com")) + .console(URI.create("https://lon-p.elastichosts.com/accounts")) + .iso3166Codes("GB-LND")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected ElasticHostsPeer1LondonProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "ElasticHosts London Peer 1"; + private static class ConcreteBuilder extends Builder { + + @Override + public ElasticHostsPeer1LondonProviderMetadata build() { + return new ElasticHostsPeer1LondonProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "UUID"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret API Key"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("https://lon-p.elastichosts.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://lon-p.elastichosts.com/accounts"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://www.elastichosts.com/cloud-hosting/api"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("elastichosts-lon-p"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("GB-LND"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } diff --git a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java index 5ab9481a66..7763951a1e 100644 --- a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java +++ b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.elastichosts; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +30,6 @@ import org.testng.annotations.Test; public class ElasticHostsPeer1LondonProviderTest extends BaseProviderMetadataTest { public ElasticHostsPeer1LondonProviderTest() { - super(new ElasticHostsPeer1LondonProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new ElasticHostsPeer1LondonProviderMetadata(), new ElasticStackApiMetadata()); } } diff --git a/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java b/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java index 1f84bc3c47..3643598ebf 100644 --- a/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java +++ b/providers/elastichosts-sat-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderMetadata.java @@ -1,6 +1,6 @@ /** * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file + * contribusat license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. jclouds licenses this file * to you under the Apache License, Version 2.0 (the @@ -19,12 +19,9 @@ package org.jclouds.elastichosts; import java.net.URI; -import java.util.Set; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts San Antonio Peer 1. @@ -33,83 +30,36 @@ import com.google.common.collect.ImmutableSet; */ public class ElasticHostsPeer1SanAntonioProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "elastichosts-sat-p"; + public ElasticHostsPeer1SanAntonioProviderMetadata() { + this(builder() + .id("elastichosts-sat-p") + .name("ElasticHosts San Antonio Peer 1") + .api(new ElasticStackApiMetadata()) + .homepage(URI.create("https://sat-p.elastichosts.com")) + .console(URI.create("https://sat-p.elastichosts.com/accounts")) + .iso3166Codes("US-TX")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected ElasticHostsPeer1SanAntonioProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "ElasticHosts San Antonio Peer 1"; + private static class ConcreteBuilder extends Builder { + + @Override + public ElasticHostsPeer1SanAntonioProviderMetadata build() { + return new ElasticHostsPeer1SanAntonioProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "UUID"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret API key"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("https://sat-p.elastichosts.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://sat-p.elastichosts.com/accounts"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://www.elastichosts.com/cloud-hosting/api"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("elastichosts-sat-p"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-TX"); - } - } \ No newline at end of file diff --git a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderTest.java b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderTest.java index 25f94ea97a..9c6cae4531 100644 --- a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderTest.java +++ b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.elastichosts; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +30,6 @@ import org.testng.annotations.Test; public class ElasticHostsPeer1SanAntonioProviderTest extends BaseProviderMetadataTest { public ElasticHostsPeer1SanAntonioProviderTest() { - super(new ElasticHostsPeer1SanAntonioProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new ElasticHostsPeer1SanAntonioProviderMetadata(), new ElasticStackApiMetadata()); } } \ No newline at end of file diff --git a/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java b/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java index 9a0000f47b..921c42f40d 100644 --- a/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java +++ b/providers/elastichosts-tor-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderMetadata.java @@ -19,12 +19,9 @@ package org.jclouds.elastichosts; import java.net.URI; -import java.util.Set; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts Toronto Peer 1. @@ -33,83 +30,36 @@ import com.google.common.collect.ImmutableSet; */ public class ElasticHostsPeer1TorontoProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "elastichosts-tor-p"; + public ElasticHostsPeer1TorontoProviderMetadata() { + this(builder() + .id("elastichosts-tor-p") + .name("ElasticHosts Toronto Peer 1") + .api(new ElasticStackApiMetadata()) + .homepage(URI.create("https://tor-p.elastichosts.com")) + .console(URI.create("https://tor-p.elastichosts.com/accounts")) + .iso3166Codes("CA-ON")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected ElasticHostsPeer1TorontoProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "ElasticHosts Toronto Peer 1"; + private static class ConcreteBuilder extends Builder { + + @Override + public ElasticHostsPeer1TorontoProviderMetadata build() { + return new ElasticHostsPeer1TorontoProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "UUID"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret API key"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("https://tor-p.elastichosts.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://tor-p.elastichosts.com/accounts"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://www.elastichosts.com/cloud-hosting/api"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("elastichosts-tor-p"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("CA-ON"); - } - } \ No newline at end of file diff --git a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderTest.java b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderTest.java index 2254d878f5..9164406b60 100644 --- a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderTest.java +++ b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.elastichosts; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +30,6 @@ import org.testng.annotations.Test; public class ElasticHostsPeer1TorontoProviderTest extends BaseProviderMetadataTest { public ElasticHostsPeer1TorontoProviderTest() { - super(new ElasticHostsPeer1TorontoProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new ElasticHostsPeer1TorontoProviderMetadata(), new ElasticStackApiMetadata()); } } \ No newline at end of file diff --git a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java index f40b42dd08..ebac17f28f 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java +++ b/providers/eucalyptus-partnercloud-ec2/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderMetadata.java @@ -19,12 +19,10 @@ package org.jclouds.epc; import java.net.URI; -import java.util.Set; +import org.jclouds.eucalyptus.EucalyptusApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import com.google.common.collect.ImmutableSet; - /** * Implementation of {@ link org.jclouds.types.ProviderMetadata} for Eucalpytus' * Partner Cloud EC2 provider. @@ -33,84 +31,38 @@ import com.google.common.collect.ImmutableSet; */ public class EucalyptusPartnerCloudEC2ProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "eucalyptus-partnercloud-ec2"; + public EucalyptusPartnerCloudEC2ProviderMetadata() { + this(builder() + .id("eucalyptus-partnercloud-ec2") + .name("Eucalyptus Partner Cloud (EC2)") + .api(new EucalyptusApiMetadata()) + .homepage(URI.create("http://www.eucalyptus.com/partners")) + .console(URI.create("https://partnercloud.eucalyptus.com:8443")) + .linkedServices("eucalyptus-partnercloud-ec2", "eucalyptus-partnercloud-s3") + .iso3166Codes("US-CA")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected EucalyptusPartnerCloudEC2ProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Eucalyptus Partner Cloud (EC2)"; + private static class ConcreteBuilder extends Builder { + + @Override + public EucalyptusPartnerCloudEC2ProviderMetadata build() { + return new EucalyptusPartnerCloudEC2ProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Username"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Password"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.eucalyptus.com/partners"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://partnercloud.eucalyptus.com:8443"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://open.eucalyptus.com/wiki/IntroducingEucalyptus_v2.0"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("eucalyptus-partnercloud-ec2", "eucalyptus-partnercloud-s3"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-CA"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } diff --git a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderTest.java b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderTest.java index c740e09b68..54292a806b 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderTest.java +++ b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudEC2ProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.epc; +import org.jclouds.eucalyptus.EucalyptusApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -31,7 +31,7 @@ import org.testng.annotations.Test; public class EucalyptusPartnerCloudEC2ProviderTest extends BaseProviderMetadataTest { public EucalyptusPartnerCloudEC2ProviderTest() { - super(new EucalyptusPartnerCloudEC2ProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new EucalyptusPartnerCloudEC2ProviderMetadata(), new EucalyptusApiMetadata()); } } \ No newline at end of file diff --git a/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java b/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java index ba0b1c7df5..9afe679fd5 100644 --- a/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java +++ b/providers/eucalyptus-partnercloud-s3/src/main/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderMetadata.java @@ -19,11 +19,9 @@ package org.jclouds.epc; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; - -import com.google.common.collect.ImmutableSet; +import org.jclouds.walrus.WalrusApiMetadata; /** * Implementation of {@ link org.jclouds.types.ProviderMetadata} for Eucalpytus' @@ -33,84 +31,38 @@ import com.google.common.collect.ImmutableSet; */ public class EucalyptusPartnerCloudS3ProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "eucalyptus-partnercloud-s3"; + public EucalyptusPartnerCloudS3ProviderMetadata() { + this(builder() + .id("eucalyptus-partnercloud-s3") + .name("Eucalyptus Partner Cloud (S3)") + .api(new WalrusApiMetadata()) + .homepage(URI.create("http://www.eucalyptus.com/partners")) + .console(URI.create("https://partnercloud.eucalyptus.com:8443")) + .linkedServices("eucalyptus-partnercloud-s3", "eucalyptus-partnercloud-s3") + .iso3166Codes("US-CA")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return BLOBSTORE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected EucalyptusPartnerCloudS3ProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Eucalyptus Partner Cloud (S3)"; + private static class ConcreteBuilder extends Builder { + + @Override + public EucalyptusPartnerCloudS3ProviderMetadata build() { + return new EucalyptusPartnerCloudS3ProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Username"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Password"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.eucalyptus.com/partners"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://partnercloud.eucalyptus.com:8443"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://open.eucalyptus.com/wiki/IntroducingEucalyptus_v2.0"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("eucalyptus-partnercloud-ec2", "eucalyptus-partnercloud-s3"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-CA"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } diff --git a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderTest.java b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderTest.java index ec22eaa74d..cfdabb7d1c 100644 --- a/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderTest.java +++ b/providers/eucalyptus-partnercloud-s3/src/test/java/org/jclouds/epc/EucalyptusPartnerCloudS3ProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.epc; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; +import org.jclouds.walrus.WalrusApiMetadata; import org.testng.annotations.Test; /** @@ -31,7 +31,7 @@ import org.testng.annotations.Test; public class EucalyptusPartnerCloudS3ProviderTest extends BaseProviderMetadataTest { public EucalyptusPartnerCloudS3ProviderTest() { - super(new EucalyptusPartnerCloudS3ProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + super(new EucalyptusPartnerCloudS3ProviderMetadata(), new WalrusApiMetadata()); } } \ No newline at end of file diff --git a/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java b/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java index 4afca17c06..90e28f6e3c 100644 --- a/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java +++ b/providers/go2cloud-jhb1/src/main/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderMetadata.java @@ -19,12 +19,10 @@ package org.jclouds.go2cloud; import java.net.URI; -import java.util.Set; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import com.google.common.collect.ImmutableSet; - /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Go2Cloud's * Johannesburg1 provider. @@ -33,76 +31,37 @@ import com.google.common.collect.ImmutableSet; */ public class Go2CloudJohannesburg1ProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "go2cloud-jhb1"; + public Go2CloudJohannesburg1ProviderMetadata() { + this(builder() + .id("go2cloud-jhb1") + .name("Go2Cloud Johannesburg1") + .api(new ElasticStackApiMetadata()) + .homepage(URI.create("https://jhb1.go2cloud.co.za")) + .console(URI.create("https://jhb1.go2cloud.co.za/accounts")) + .iso3166Codes("ZA-GP")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected Go2CloudJohannesburg1ProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Go2Cloud Johannesburg1"; + private static class ConcreteBuilder extends Builder { + + @Override + public Go2CloudJohannesburg1ProviderMetadata build() { + return new Go2CloudJohannesburg1ProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "User UUID"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret API Key"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://jhb1.go2cloud.co.za/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("http://jhb1.go2cloud.co.za/accounts"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://www.go2cloud.co.za/Home/QuickStart"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("ZA-GP"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } diff --git a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderTest.java b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderTest.java index 7d5959f889..22a49cb308 100644 --- a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderTest.java +++ b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.go2cloud; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -31,7 +31,7 @@ import org.testng.annotations.Test; public class Go2CloudJohannesburg1ProviderTest extends BaseProviderMetadataTest { public Go2CloudJohannesburg1ProviderTest() { - super(new Go2CloudJohannesburg1ProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new Go2CloudJohannesburg1ProviderMetadata(), new ElasticStackApiMetadata()); } } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java new file mode 100644 index 0000000000..e209e90e5d --- /dev/null +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.gogrid; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for the GoGrid API + * + * @author Adrian Cole + */ +public class GoGridApiMetadata extends BaseApiMetadata { + + public GoGridApiMetadata() { + this(builder() + .id("gogrid") + .type(ApiType.COMPUTE) + .name("GoGrid API") + .identityName("API Key") + .credentialName("Shared Secret") + .documentation(URI.create("https://wiki.gogrid.com/wiki/index.php/API"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected GoGridApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public GoGridApiMetadata build() { + return new GoGridApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java index 1d74d7c0ca..8221241ea5 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridProviderMetadata.java @@ -19,98 +19,46 @@ package org.jclouds.gogrid; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** - * Implementation of @ link org.jclouds.types.ProviderMetadata} for GoGrid. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for GoGrid. * * @author Adrian Cole */ public class GoGridProviderMetadata extends BaseProviderMetadata { - - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "gogrid"; + public GoGridProviderMetadata() { + this(builder() + .id("gogrid") + .name("GoGrid") + .api(new GoGridApiMetadata()) + .homepage(URI.create("http://www.gogrid.com")) + .console(URI.create("https://my.gogrid.com/gogrid")) + .iso3166Codes("US-CA", "US-VA", "BR-SP")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected GoGridProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "GoGrid"; + private static class ConcreteBuilder extends Builder { + + @Override + public GoGridProviderMetadata build() { + return new GoGridProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "API Key"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Shared Secret"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.gogrid.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://my.gogrid.com/gogrid"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("https://wiki.gogrid.com/wiki/index.php/API"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("gogrid"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-CA", "US-VA", "BR-SP"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } \ No newline at end of file diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridProviderTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridProviderTest.java index 120e8ac98d..2fb9140c3a 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridProviderTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridProviderTest.java @@ -19,7 +19,6 @@ package org.jclouds.gogrid; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +29,6 @@ import org.testng.annotations.Test; public class GoGridProviderTest extends BaseProviderMetadataTest { public GoGridProviderTest() { - super(new GoGridProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new GoGridProviderMetadata(), new GoGridApiMetadata()); } } \ No newline at end of file diff --git a/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java index 6c088f055c..a06f740ecc 100644 --- a/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java +++ b/providers/greenhousedata-element-vcloud/src/main/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderMetadata.java @@ -19,12 +19,9 @@ package org.jclouds.greenhousedata.element.vcloud; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; +import org.jclouds.vcloud.VCloudApiMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Green House Data Element vCloud @@ -33,84 +30,37 @@ import com.google.common.collect.ImmutableSet; */ public class GreenHouseDataElementVCloudProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "greenhousedata-element-vcloud"; + public GreenHouseDataElementVCloudProviderMetadata() { + this(builder() + .id("greenhousedata-element-vcloud") + .name("Green House Data Element vCloud") + .api(new VCloudApiMetadata()) + .homepage(URI.create("http://www.greenhousedata.com/element-cloud-hosting/vcloud-services/")) + .console(URI.create("https://mycloud.greenhousedata.com/cloud/org/YOUR_ORG_HERE")) + .iso3166Codes("US-WY")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected GreenHouseDataElementVCloudProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Green House Data Element vCloud"; + private static class ConcreteBuilder extends Builder { + + @Override + public GreenHouseDataElementVCloudProviderMetadata build() { + return new GreenHouseDataElementVCloudProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "User at Organization (user@org)"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Password"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.greenhousedata.com/element-cloud-hosting/vcloud-services/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://mycloud.greenhousedata.com/cloud/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://www.greenhousedata.com/element-cloud-hosting/vcloud-services/"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("greenhousedata-element-vcloud"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-WY"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } diff --git a/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java index 02f784a062..b72914a0dc 100644 --- a/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java +++ b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/GreenHouseDataElementVCloudProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.greenhousedata.element.vcloud; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; +import org.jclouds.vcloud.VCloudApiMetadata; import org.testng.annotations.Test; /** @@ -30,6 +30,6 @@ import org.testng.annotations.Test; public class GreenHouseDataElementVCloudProviderTest extends BaseProviderMetadataTest { public GreenHouseDataElementVCloudProviderTest() { - super(new GreenHouseDataElementVCloudProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new GreenHouseDataElementVCloudProviderMetadata(), new VCloudApiMetadata()); } } diff --git a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeApiMetadata.java b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeApiMetadata.java new file mode 100644 index 0000000000..05596e2e9e --- /dev/null +++ b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeApiMetadata.java @@ -0,0 +1,60 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.hpcloud.compute; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for the Amazon-specific Nova API + * + * @author Adrian Cole + */ +public class HPCloudComputeApiMetadata extends NovaApiMetadata { + + public HPCloudComputeApiMetadata() { + this(builder().fromApiMetadata(new NovaApiMetadata()) + .identityName("tenantId:accessKey") + .credentialName("secretKey")); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected HPCloudComputeApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends NovaApiMetadataBuilder { + + @Override + public HPCloudComputeApiMetadata build() { + return new HPCloudComputeApiMetadata(this); + } + } + + private static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java index 4084ccabea..5287499f88 100644 --- a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java +++ b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java @@ -19,12 +19,8 @@ package org.jclouds.hpcloud.compute; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** @@ -34,84 +30,37 @@ import com.google.common.collect.ImmutableSet; */ public class HPCloudComputeProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "hpcloud-compute"; + public HPCloudComputeProviderMetadata() { + this(builder() + .id("hpcloud-compute") + .name("HP Cloud Compute Services") + .api(new HPCloudComputeApiMetadata()) + .homepage(URI.create("http://hpcloud.com")) + .console(URI.create("https://manage.hpcloud.com/compute")) + .linkedServices("hpcloud-compute", "hpcloud-objectstorage") + .iso3166Codes("US-NV")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected HPCloudComputeProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "tenantId:accessKey"; + private static class ConcreteBuilder extends Builder { + + @Override + public HPCloudComputeProviderMetadata build() { + return new HPCloudComputeProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret Key"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "HP Cloud Compute Services"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://hpcloud.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://manage.hpcloud.com/compute"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("TODO"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("hpcloud-compute", "hpcloud-objectstorage"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-NV"); - } - } diff --git a/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderTest.java b/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderTest.java index 783b8d65ba..670349b9ae 100644 --- a/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderTest.java +++ b/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderTest.java @@ -36,7 +36,6 @@ package org.jclouds.hpcloud.compute; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -47,6 +46,6 @@ import org.testng.annotations.Test; public class HPCloudComputeProviderTest extends BaseProviderMetadataTest { public HPCloudComputeProviderTest() { - super(new HPCloudComputeProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new HPCloudComputeProviderMetadata(), new HPCloudComputeApiMetadata()); } } diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java new file mode 100644 index 0000000000..2278c43d1d --- /dev/null +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageApiMetadata.java @@ -0,0 +1,49 @@ +package org.jclouds.hpcloud.objectstorage; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for HP Cloud Object Storage API + * + * @author Adrian Cole + */ +public class HPCloudObjectStorageApiMetadata extends BaseApiMetadata { + + public HPCloudObjectStorageApiMetadata() { + this(builder() + .id("hpcloud-objectstorage") + .type(ApiType.BLOBSTORE) + .name("HP Cloud Services Object Storage API") + .identityName("tenantId:accessKey") + .credentialName("secretKey") + .documentation(URI.create("https://build.hpcloud.com/object-storage/api"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected HPCloudObjectStorageApiMetadata(ConcreteBuilder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public HPCloudObjectStorageApiMetadata build() { + return new HPCloudObjectStorageApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } +} \ No newline at end of file diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java index 6693af3f47..a41c592de8 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderMetadata.java @@ -19,12 +19,8 @@ package org.jclouds.hpcloud.objectstorage; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.providers.ProviderMetadata} for HP Cloud Services Object Storage @@ -33,84 +29,38 @@ import com.google.common.collect.ImmutableSet; */ public class HPCloudObjectStorageProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "hpcloud-objectstorage"; + public HPCloudObjectStorageProviderMetadata() { + this(builder() + .id("hpcloud-objectstorage") + .name("HP Cloud Services Object Storage") + .api(new HPCloudObjectStorageApiMetadata()) + .homepage(URI.create("http://hpcloud.com")) + .console(URI.create("https://manage.hpcloud.com/objects/us-west")) + .linkedServices("hpcloud-compute", "hpcloud-objectstorage") + .iso3166Codes("US-NV")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.BLOBSTORE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected HPCloudObjectStorageProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "HP Cloud Services Object Storage"; - } - - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "email:tenantId"; + private static class ConcreteBuilder extends Builder { + + @Override + public HPCloudObjectStorageProviderMetadata build() { + return new HPCloudObjectStorageProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "API Key"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://hpcloud.com"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://manage.hpcloud.com/objects/us-west"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("TODO"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("hpcloud-compute", "hpcloud-objectstorage"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-NV"); - } - -} +} \ No newline at end of file diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderTest.java index b552bd06e4..2ec0636ca6 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderTest.java @@ -19,7 +19,6 @@ package org.jclouds.hpcloud.objectstorage; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -31,7 +30,7 @@ import org.testng.annotations.Test; public class HPCloudObjectStorageProviderTest extends BaseProviderMetadataTest { public HPCloudObjectStorageProviderTest() { - super(new HPCloudObjectStorageProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + super(new HPCloudObjectStorageProviderMetadata(), new HPCloudObjectStorageApiMetadata()); } } diff --git a/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java b/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java index c7cbc4ecd8..06b8a77b71 100644 --- a/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java +++ b/providers/ninefold-compute/src/main/java/org/jclouds/ninefold/compute/NinefoldComputeProviderMetadata.java @@ -19,12 +19,10 @@ package org.jclouds.ninefold.compute; import java.net.URI; -import java.util.Set; +import org.jclouds.cloudstack.CloudStackApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import com.google.common.collect.ImmutableSet; - /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Ninefold * Compute. @@ -33,83 +31,36 @@ import com.google.common.collect.ImmutableSet; */ public class NinefoldComputeProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "ninefold-compute"; + public NinefoldComputeProviderMetadata() { + this(builder() + .id("ninefold-compute") + .name("Ninefold Compute") + .api(new CloudStackApiMetadata()) + .homepage(URI.create("http://ninefold.com/virtual-servers/")) + .console(URI.create("https://ninefold.com/portal/portal/login")) + .iso3166Codes("AU-NSW")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected NinefoldComputeProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Ninefold Compute"; + private static class ConcreteBuilder extends Builder { + + @Override + public NinefoldComputeProviderMetadata build() { + return new NinefoldComputeProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "API Key"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret Key"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://ninefold.com/virtual-servers/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://ninefold.com/portal/portal/login"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("https://ninefold.com/support/display/SPT/Cloud+Compute"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("AU-NSW"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of(getId(), "ninefold-storage"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } diff --git a/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/NinefoldComputeProviderTest.java b/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/NinefoldComputeProviderTest.java index a7bd1c6670..0aec023a22 100644 --- a/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/NinefoldComputeProviderTest.java +++ b/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/NinefoldComputeProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.ninefold.compute; +import org.jclouds.cloudstack.CloudStackApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -31,7 +31,7 @@ import org.testng.annotations.Test; public class NinefoldComputeProviderTest extends BaseProviderMetadataTest { public NinefoldComputeProviderTest() { - super(new NinefoldComputeProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new NinefoldComputeProviderMetadata(), new CloudStackApiMetadata()); } } diff --git a/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java b/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java index 5658f5be07..14e40a6f8f 100644 --- a/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java +++ b/providers/ninefold-storage/src/main/java/org/jclouds/ninefold/storage/NinefoldStorageProviderMetadata.java @@ -19,12 +19,10 @@ package org.jclouds.ninefold.storage; import java.net.URI; -import java.util.Set; +import org.jclouds.atmos.AtmosApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import com.google.common.collect.ImmutableSet; - /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Ninefold's * Storage provider. @@ -33,76 +31,36 @@ import com.google.common.collect.ImmutableSet; */ public class NinefoldStorageProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "ninefold-storage"; + public NinefoldStorageProviderMetadata() { + this(builder() + .id("ninefold-storage") + .name("Ninefold Storage") + .api(new AtmosApiMetadata()) + .homepage(URI.create("http://ninefold.com/cloud-storage/")) + .console(URI.create("https://ninefold.com/portal/")) + .iso3166Codes("AU-NSW")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return BLOBSTORE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected NinefoldStorageProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Ninefold Storage"; + private static class ConcreteBuilder extends Builder { + + @Override + public NinefoldStorageProviderMetadata build() { + return new NinefoldStorageProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Subtenant ID (UID)"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Shared Secret"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://ninefold.com/cloud-storage/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://ninefold.com/portal/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("https://ninefold.com/support/display/SPT/API+Documentation"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("AU-NSW"); - } - } diff --git a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/NinefoldStorageProviderTest.java b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/NinefoldStorageProviderTest.java index 2e8164c36b..499648c11b 100644 --- a/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/NinefoldStorageProviderTest.java +++ b/providers/ninefold-storage/src/test/java/org/jclouds/ninefold/storage/NinefoldStorageProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.ninefold.storage; +import org.jclouds.atmos.AtmosApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -31,7 +31,7 @@ import org.testng.annotations.Test; public class NinefoldStorageProviderTest extends BaseProviderMetadataTest { public NinefoldStorageProviderTest() { - super(new NinefoldStorageProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + super(new NinefoldStorageProviderMetadata(), new AtmosApiMetadata()); } } \ No newline at end of file diff --git a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java b/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java index fabc13cb88..6944d07aff 100644 --- a/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java +++ b/providers/openhosting-east1/src/main/java/org/jclouds/openhosting/OpenHostingEast1ProviderMetadata.java @@ -19,90 +19,48 @@ package org.jclouds.openhosting; import java.net.URI; -import java.util.Set; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import com.google.common.collect.ImmutableSet; - /** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for OpenHosting's - * East1 provider. + * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts London Peer 1. * - * @author Jeremy Whitlock + * @author Adrian Cole */ public class OpenHostingEast1ProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "openhosting-east1"; + public OpenHostingEast1ProviderMetadata() { + this(builder() + .id("openhosting-east1") + .name("OpenHosting East1") + .api(new ElasticStackApiMetadata()) + .homepage(URI.create("https://east1.openhosting.com")) + .console(URI.create("https://east1.openhosting.com/accounts")) + .iso3166Codes("US-VA")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected OpenHostingEast1ProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "OpenHosting East1"; + private static class ConcreteBuilder extends Builder { + + @Override + public OpenHostingEast1ProviderMetadata build() { + return new OpenHostingEast1ProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "User UUID"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret API Key"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("https://east1.openhosting.com/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://east1.openhosting.com/accounts/login"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://www.openhosting.com/support/api/"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-FL"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } diff --git a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ProviderTest.java b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ProviderTest.java index 15cbca4e05..7caa1d9564 100644 --- a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ProviderTest.java +++ b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.openhosting; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -31,7 +31,7 @@ import org.testng.annotations.Test; public class OpenHostingEast1ProviderTest extends BaseProviderMetadataTest { public OpenHostingEast1ProviderTest() { - super(new OpenHostingEast1ProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new OpenHostingEast1ProviderMetadata(), new ElasticStackApiMetadata()); } } \ No newline at end of file diff --git a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java index c403ca4591..96e00c3b5b 100644 --- a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java +++ b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java @@ -80,6 +80,6 @@ public class OpenHostingEast1TemplateBuilderLiveTest extends BaseTemplateBuilder @Override protected Set getIso3166Codes() { - return ImmutableSet. of("US-FL"); + return ImmutableSet. of("US-VA"); } } diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java new file mode 100644 index 0000000000..795afc54ab --- /dev/null +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingApiMetadata.java @@ -0,0 +1,67 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.rimuhosting.miro; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for RimuHosting API + * + * @author Adrian Cole + */ +public class RimuHostingApiMetadata extends BaseApiMetadata { + + public RimuHostingApiMetadata() { + this(builder() + .id("rimuhosting") + .type(ApiType.COMPUTE) + .name("RimuHosting API") + .identityName("API Key") + .documentation(URI.create("http://apidocs.rimuhosting.com"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected RimuHostingApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public RimuHostingApiMetadata build() { + return new RimuHostingApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java index 7c62d4c890..b037c50830 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingProviderMetadata.java @@ -19,12 +19,8 @@ package org.jclouds.rimuhosting.miro; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for RimuHosting. @@ -32,84 +28,37 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ public class RimuHostingProviderMetadata extends BaseProviderMetadata { - - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "rimuhosting"; + public RimuHostingProviderMetadata() { + this(builder() + .id("rimuhosting") + .name("RimuHosting") + .api(new RimuHostingApiMetadata()) + .homepage(URI.create("http://www.rimuhosting.com")) + .console(URI.create("https://rimuhosting.com/cp")) + .iso3166Codes("NZ-AUK", "US-TX", "AU-NSW", "GB-LND")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected RimuHostingProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "RimuHosting"; + private static class ConcreteBuilder extends Builder { + + @Override + public RimuHostingProviderMetadata build() { + return new RimuHostingProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "UUID"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret API Key"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://rimuhosting.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://rimuhosting.com/cp"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://apidocs.rimuhosting.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("rimuhosting"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("NZ-AUK", "US-TX", "AU-NSW", "GB-LND"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/ProvidersInPropertiesTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/ProvidersInPropertiesTest.java deleted file mode 100644 index 701f725e57..0000000000 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/ProvidersInPropertiesTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.rimuhosting.miro; - -import org.jclouds.compute.util.ComputeServiceUtils; -import org.jclouds.rest.Providers; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - * - */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "rimuhosting") : providers; - } - - @Test - public void testSupportedComputeServiceProviders() { - Iterable providers = ComputeServiceUtils.getSupportedProviders(); - assert Iterables.contains(providers, "rimuhosting") : providers; - } - -} diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingProviderTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingProviderTest.java index c85de52441..de1ad2dd48 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingProviderTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingProviderTest.java @@ -19,7 +19,6 @@ package org.jclouds.rimuhosting.miro; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +29,6 @@ import org.testng.annotations.Test; public class RimuHostingProviderTest extends BaseProviderMetadataTest { public RimuHostingProviderTest() { - super(new RimuHostingProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new RimuHostingProviderMetadata(), new RimuHostingApiMetadata()); } } diff --git a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java index d92ef04d27..d1b2230206 100644 --- a/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java +++ b/providers/serverlove-z1-man/src/main/java/org/jclouds/serverlove/ServerloveManchesterProviderMetadata.java @@ -19,12 +19,9 @@ package org.jclouds.serverlove; import java.net.URI; -import java.util.Set; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Serverlove Manchester. @@ -33,83 +30,36 @@ import com.google.common.collect.ImmutableSet; */ public class ServerloveManchesterProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "serverlove-z1-man"; + public ServerloveManchesterProviderMetadata() { + this(builder() + .id("serverlove-z1-man") + .name("Serverlove Manchester") + .api(new ElasticStackApiMetadata()) + .homepage(URI.create("http://www.serverlove.com")) + .console(URI.create("http://www.serverlove.com/accounts")) + .iso3166Codes("GB-MAN")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected ServerloveManchesterProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Serverlove Manchester"; + private static class ConcreteBuilder extends Builder { + + @Override + public ServerloveManchesterProviderMetadata build() { + return new ServerloveManchesterProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "UUID"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret API Key"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.serverlove.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("http://www.serverlove.com/login"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://www.serverlove.com/cloud-server-faqs/api-questions"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("serverlove-z1-man"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("GB-MAN"); - } - } diff --git a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterProviderTest.java b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterProviderTest.java index 6a6bd4a4d9..9ad8d824e2 100644 --- a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterProviderTest.java +++ b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.serverlove; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +30,6 @@ import org.testng.annotations.Test; public class ServerloveManchesterProviderTest extends BaseProviderMetadataTest { public ServerloveManchesterProviderTest() { - super(new ServerloveManchesterProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new ServerloveManchesterProviderMetadata(), new ElasticStackApiMetadata()); } } diff --git a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java index 34563dc11f..d6a80aaee3 100644 --- a/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java +++ b/providers/skalicloud-sdg-my/src/main/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderMetadata.java @@ -19,97 +19,48 @@ package org.jclouds.skalicloud; import java.net.URI; -import java.util.Set; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for SkaliCloud Malaysia. * * @author Adrian Cole */ -public class SkaliCloudMalaysiaProviderMetadata extends BaseProviderMetadata { +public class SkaliCloudMalaysiaProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "skalicloud-sdg-my"; + public SkaliCloudMalaysiaProviderMetadata() { + this(builder() + .id("skalicloud-sdg-my") + .name("SkaliCloud Malaysia") + .api(new ElasticStackApiMetadata()) + .homepage(URI.create("http://sdg-my.skalicloud.com")) + .console(URI.create("http://sdg-my.skalicloud.com/accounts")) + .iso3166Codes("MY-10")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected SkaliCloudMalaysiaProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "SkaliCloud Malaysia"; + private static class ConcreteBuilder extends Builder { + + @Override + public SkaliCloudMalaysiaProviderMetadata build() { + return new SkaliCloudMalaysiaProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "UUID"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Secret API Key"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.skalicloud.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("http://sdg-my.skalicloud.com"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://www.skalicloud.com/cloud-api"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("skalicloud-sdg-my"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("MY-10"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } diff --git a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderTest.java b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderTest.java index 1ed3761056..a45034b500 100644 --- a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderTest.java +++ b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.skalicloud; +import org.jclouds.elasticstack.ElasticStackApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +30,6 @@ import org.testng.annotations.Test; public class SkaliCloudMalaysiaProviderTest extends BaseProviderMetadataTest { public SkaliCloudMalaysiaProviderTest() { - super(new SkaliCloudMalaysiaProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new SkaliCloudMalaysiaProviderMetadata(), new ElasticStackApiMetadata()); } } diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java new file mode 100644 index 0000000000..7193e51134 --- /dev/null +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostApiMetadata.java @@ -0,0 +1,67 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.slicehost; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for Slicehost API + * + * @author Adrian Cole + */ +public class SlicehostApiMetadata extends BaseApiMetadata { + + public SlicehostApiMetadata() { + this(builder() + .id("slicehost") + .type(ApiType.COMPUTE) + .name("Slicehost API") + .identityName("API password") + .documentation(URI.create("http://articles.slicehost.com/api"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected SlicehostApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public SlicehostApiMetadata build() { + return new SlicehostApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java index 34eb381545..e315e8af3f 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/SlicehostProviderMetadata.java @@ -19,12 +19,8 @@ package org.jclouds.slicehost; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Slicehost @@ -32,85 +28,36 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ public class SlicehostProviderMetadata extends BaseProviderMetadata { - - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "slicehost"; + public SlicehostProviderMetadata() { + this(builder() + .id("slicehost") + .name("Slicehost") + .api(new SlicehostApiMetadata()) + .homepage(URI.create("http://www.slicehost.com")) + .console(URI.create("https://manage.slicehost.com/")) + .iso3166Codes("US-IL", "US-TX", "US-MO")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected SlicehostProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Slicehost"; + private static class ConcreteBuilder extends Builder { + + @Override + public SlicehostProviderMetadata build() { + return new SlicehostProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "API password"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return null; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.slicehost.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://manage.slicehost.com/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://articles.slicehost.com/api"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("slicehost"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-IL", "US-TX", "US-MO"); - } - } \ No newline at end of file diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostProviderTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostProviderTest.java index 66ace2733e..44fe33bed2 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostProviderTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostProviderTest.java @@ -19,7 +19,6 @@ package org.jclouds.slicehost; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +29,6 @@ import org.testng.annotations.Test; public class SlicehostProviderTest extends BaseProviderMetadataTest { public SlicehostProviderTest() { - super(new SlicehostProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new SlicehostProviderMetadata(), new SlicehostApiMetadata()); } } \ No newline at end of file diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java new file mode 100644 index 0000000000..9650629c0e --- /dev/null +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerApiMetadata.java @@ -0,0 +1,68 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.softlayer; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for SoftLayer API + * + * @author Adrian Cole + */ +public class SoftLayerApiMetadata extends BaseApiMetadata { + + public SoftLayerApiMetadata() { + this(builder() + .id("softlayer") + .type(ApiType.COMPUTE) + .name("SoftLayer API") + .identityName("API Username") + .credentialName("API Key") + .documentation(URI.create("http://sldn.softlayer.com/article/REST"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected SoftLayerApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public SoftLayerApiMetadata build() { + return new SoftLayerApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java index 46c7377f2c..00f465a085 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java @@ -19,12 +19,8 @@ package org.jclouds.softlayer; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@ link org.jclouds.types.ProviderMetadata} for SoftLayer. @@ -32,84 +28,36 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ public class SoftLayerProviderMetadata extends BaseProviderMetadata { - - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "softlayer"; + public SoftLayerProviderMetadata() { + this(builder() + .id("softlayer") + .name("SoftLayer") + .api(new SoftLayerApiMetadata()) + .homepage(URI.create("http://www.softlayer.com")) + .console(URI.create("https://manage.softlayer.com")) + .iso3166Codes("SG","US-CA","US-TX","US-VA","US-WA","US-TX")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected SoftLayerProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "SoftLayer"; + private static class ConcreteBuilder extends Builder { + + @Override + public SoftLayerProviderMetadata build() { + return new SoftLayerProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "API Username"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "API Key"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.softlayer.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://manage.softlayer.com"); - } - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://sldn.softlayer.com/article/REST"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("softlayer"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("SG","US-CA","US-TX","US-VA","US-WA","US-TX"); - } - } \ No newline at end of file diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerProviderTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerProviderTest.java index 4f235dc999..01d71eb4ef 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerProviderTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/SoftLayerProviderTest.java @@ -19,7 +19,6 @@ package org.jclouds.softlayer; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -30,6 +29,6 @@ import org.testng.annotations.Test; public class SoftLayerProviderTest extends BaseProviderMetadataTest { public SoftLayerProviderTest() { - super(new SoftLayerProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new SoftLayerProviderMetadata(), new SoftLayerApiMetadata()); } } \ No newline at end of file diff --git a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java b/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java index 6ff8beb185..56d792b129 100644 --- a/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java +++ b/providers/stratogen-vcloud-mycloud/src/main/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderMetadata.java @@ -19,12 +19,9 @@ package org.jclouds.stratogen.vcloud.mycloud; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; +import org.jclouds.vcloud.VCloudApiMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for StratoGen VMware hosting @@ -33,84 +30,37 @@ import com.google.common.collect.ImmutableSet; */ public class StratoGenVCloudMyCloudProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "stratogen-vcloud-mycloud"; + public StratoGenVCloudMyCloudProviderMetadata() { + this(builder() + .id("stratogen-vcloud-mycloud") + .name("StratoGen VMware hosting") + .api(new VCloudApiMetadata()) + .homepage(URI.create("http://www.stratogen.net")) + .console(URI.create("https://mycloud.stratogen.net/cloud/org/YOUR_ORG_HERE")) + .iso3166Codes("GB")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected StratoGenVCloudMyCloudProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "StratoGen VMware hosting"; + private static class ConcreteBuilder extends Builder { + + @Override + public StratoGenVCloudMyCloudProviderMetadata build() { + return new StratoGenVCloudMyCloudProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "User at Organization (user@org)"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Password"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.stratogen.net"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://mycloud.stratogen.net/cloud/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("stratogen-vcloud-mycloud"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("GB"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } diff --git a/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderTest.java b/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderTest.java index bbeb2d98f9..09ea912b2e 100644 --- a/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderTest.java +++ b/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/StratoGenVCloudMyCloudProviderTest.java @@ -19,7 +19,7 @@ package org.jclouds.stratogen.vcloud.mycloud; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; +import org.jclouds.vcloud.VCloudApiMetadata; import org.testng.annotations.Test; /** @@ -30,6 +30,6 @@ import org.testng.annotations.Test; public class StratoGenVCloudMyCloudProviderTest extends BaseProviderMetadataTest { public StratoGenVCloudMyCloudProviderTest() { - super(new StratoGenVCloudMyCloudProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new StratoGenVCloudMyCloudProviderMetadata(), new VCloudApiMetadata()); } } diff --git a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java index 019c59d28b..fdd007508b 100644 --- a/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java +++ b/providers/synaptic-storage/src/main/java/org/jclouds/synaptic/storage/SynapticStorageProviderMetadata.java @@ -19,12 +19,9 @@ package org.jclouds.synaptic.storage; import java.net.URI; -import java.util.Set; +import org.jclouds.atmos.AtmosApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for AT&T's @@ -34,76 +31,37 @@ import com.google.common.collect.ImmutableSet; */ public class SynapticStorageProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "synaptic-storage"; + public SynapticStorageProviderMetadata() { + this(builder() + .id("synaptic-storage") + .name("AT&T Synaptic Storage") + .api(new AtmosApiMetadata()) + .homepage(URI.create("https://www.synaptic.att.com/")) + .console(URI.create("https://www.synaptic.att.com/clouduser/login.htm")) + .iso3166Codes("US-VA", "US-TX")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.BLOBSTORE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected SynapticStorageProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "AT&T Synaptic Storage"; + private static class ConcreteBuilder extends Builder { + + @Override + public SynapticStorageProviderMetadata build() { + return new SynapticStorageProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "Subtenant ID (UID)"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Shared Secret"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("https://www.synaptic.att.com/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://www.synaptic.att.com/clouduser/login.htm"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("https://www.synaptic.att.com/clouduser/emc_atmos_api.htm"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-VA", "US-TX"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } \ No newline at end of file diff --git a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/SynapticStorageProviderTest.java b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/SynapticStorageProviderTest.java index 897c37a7fd..be9da98de9 100644 --- a/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/SynapticStorageProviderTest.java +++ b/providers/synaptic-storage/src/test/java/org/jclouds/synaptic/storage/SynapticStorageProviderTest.java @@ -18,8 +18,8 @@ */ package org.jclouds.synaptic.storage; +import org.jclouds.atmos.AtmosApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -31,7 +31,7 @@ import org.testng.annotations.Test; public class SynapticStorageProviderTest extends BaseProviderMetadataTest { public SynapticStorageProviderTest() { - super(new SynapticStorageProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + super(new SynapticStorageProviderMetadata(), new AtmosApiMetadata()); } } \ No newline at end of file diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java new file mode 100644 index 0000000000..77b324a1fd --- /dev/null +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudApiMetadata.java @@ -0,0 +1,50 @@ +package org.jclouds.trmk.ecloud; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for Terremark eCloud v2.8 API + * + * @author Adrian Cole + */ +public class TerremarkECloudApiMetadata extends BaseApiMetadata { + + public TerremarkECloudApiMetadata() { + this(builder() + .id("trmk-ecloud") + .type(ApiType.COMPUTE) + .name("Terremark Enterprise Cloud v2.8 API") + .identityName("Email") + .credentialName("Password") + .documentation(URI.create("http://support.theenterprisecloud.com/kb/default.asp?id=533&Lang=1&SID="))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected TerremarkECloudApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public TerremarkECloudApiMetadata build() { + return new TerremarkECloudApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java index c69ce2766f..2cb542fa6d 100644 --- a/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java +++ b/providers/trmk-ecloud/src/main/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderMetadata.java @@ -19,12 +19,8 @@ package org.jclouds.trmk.ecloud; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Terremark's Enterprise Cloud. @@ -32,77 +28,36 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ public class TerremarkECloudProviderMetadata extends BaseProviderMetadata { - - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "trmk-ecloud"; + public TerremarkECloudProviderMetadata() { + this(builder() + .id("trmk-ecloud") + .name("Terremark Enterprise Cloud v2.8") + .api(new TerremarkECloudApiMetadata()) + .homepage(URI.create("http://www.terremark.com/services/cloudcomputing/theenterprisecloud.aspx")) + .console(URI.create("https://icenter.digitalops.net")) + .iso3166Codes("US-FL", "US-VA", "NL-NH", "BR-SP")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected TerremarkECloudProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Terremark Enterprise Cloud"; + private static class ConcreteBuilder extends Builder { + + @Override + public TerremarkECloudProviderMetadata build() { + return new TerremarkECloudProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "email"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "password"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("http://www.terremark.com/services/cloudcomputing/theenterprisecloud.aspx"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://icenter.digitalops.net"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://support.theenterprisecloud.com/kb/default.asp?id=533&Lang=1&SID="); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet. of("US-FL", "US-VA", "NL-NH", "BR-SP"); - } - } \ No newline at end of file diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderTest.java index 5b9b07b04b..e3b13fb7e3 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/TerremarkECloudProviderTest.java @@ -19,7 +19,6 @@ package org.jclouds.trmk.ecloud; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -31,6 +30,6 @@ import org.testng.annotations.Test; public class TerremarkECloudProviderTest extends BaseProviderMetadataTest { public TerremarkECloudProviderTest() { - super(new TerremarkECloudProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new TerremarkECloudProviderMetadata(), new TerremarkECloudApiMetadata()); } } \ No newline at end of file diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java new file mode 100644 index 0000000000..8362bd989d --- /dev/null +++ b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressApiMetadata.java @@ -0,0 +1,50 @@ +package org.jclouds.trmk.vcloudexpress; + +import java.net.URI; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.apis.ApiType; +import org.jclouds.apis.BaseApiMetadata; + +/** + * Implementation of {@link ApiMetadata} for the Terremark vCloud Express API + * + * @author Adrian Cole + */ +public class TerremarkVCloudExpressApiMetadata extends BaseApiMetadata { + + public TerremarkVCloudExpressApiMetadata() { + this(builder() + .id("trmk-vcloudexpress") + .type(ApiType.COMPUTE) + .name("Terremark vCloud Express API") + .identityName("Email") + .credentialName("Password") + .documentation(URI.create("https://community.vcloudexpress.terremark.com/en-us/product_docs/m/vcefiles/2342.aspx"))); + } + + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected TerremarkVCloudExpressApiMetadata(Builder builder) { + super(builder); + } + + private static class ConcreteBuilder extends Builder { + + @Override + public TerremarkVCloudExpressApiMetadata build() { + return new TerremarkVCloudExpressApiMetadata(this); + } + } + + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); + } + + @Override + public ConcreteBuilder toBuilder() { + return builder().fromApiMetadata(this); + } + +} \ No newline at end of file diff --git a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java index 8cc2cad297..a9a58ddf22 100644 --- a/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java +++ b/providers/trmk-vcloudexpress/src/main/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderMetadata.java @@ -19,12 +19,8 @@ package org.jclouds.trmk.vcloudexpress; import java.net.URI; -import java.util.Set; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for Terremark's vCloud Express. @@ -32,77 +28,37 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ public class TerremarkVCloudExpressProviderMetadata extends BaseProviderMetadata { - - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "trmk-vcloudexpress"; + public TerremarkVCloudExpressProviderMetadata() { + this(builder() + .id("trmk-vcloudexpress") + .name("Terremark vCloud Express") + .api(new TerremarkVCloudExpressApiMetadata()) + .homepage(URI.create("https://vcloudexpress.terremark.com/")) + .console(URI.create("https://my.vcloudexpress.terremark.com")) + .iso3166Codes("US-FL")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected TerremarkVCloudExpressProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "email"; + private static class ConcreteBuilder extends Builder { + + @Override + public TerremarkVCloudExpressProviderMetadata build() { + return new TerremarkVCloudExpressProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "password"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "Terremark vCloud Express"; - } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("https://vcloudexpress.terremark.com/"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://my.vcloudexpress.terremark.com"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("https://community.vcloudexpress.terremark.com/en-us/product_docs/m/vcefiles/2342.aspx"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-FL"); + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } } \ No newline at end of file diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderTest.java index 8a396e8f51..973b272f36 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/TerremarkVCloudExpressProviderTest.java @@ -19,7 +19,6 @@ package org.jclouds.trmk.vcloudexpress; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -31,6 +30,6 @@ import org.testng.annotations.Test; public class TerremarkVCloudExpressProviderTest extends BaseProviderMetadataTest { public TerremarkVCloudExpressProviderTest() { - super(new TerremarkVCloudExpressProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new TerremarkVCloudExpressProviderMetadata(), new TerremarkVCloudExpressApiMetadata()); } } \ No newline at end of file diff --git a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java b/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java index dc32ad933d..3c508fe33f 100644 --- a/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java +++ b/providers/trystack-nova/src/main/java/org/jclouds/trystack/nova/TryStackNovaProviderMetadata.java @@ -19,12 +19,9 @@ package org.jclouds.trystack.nova; import java.net.URI; -import java.util.Set; +import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; import org.jclouds.providers.BaseProviderMetadata; -import org.jclouds.providers.ProviderMetadata; - -import com.google.common.collect.ImmutableSet; /** @@ -34,84 +31,36 @@ import com.google.common.collect.ImmutableSet; */ public class TryStackNovaProviderMetadata extends BaseProviderMetadata { - /** - * {@inheritDoc} - */ - @Override - public String getId() { - return "trystack-nova"; + public TryStackNovaProviderMetadata() { + this(builder() + .id("trystack-nova") + .name("TryStack.org (Nova)") + .api(new NovaApiMetadata()) + .homepage(URI.create("https://trystack.org")) + .console(URI.create("https://trystack.org/dash")) + .iso3166Codes("US-CA")); } - /** - * {@inheritDoc} - */ - @Override - public String getType() { - return ProviderMetadata.COMPUTE_TYPE; + // below are so that we can reuse builders, toString, hashCode, etc. + // we have to set concrete classes here, as our base class cannot be + // concrete due to serviceLoader + protected TryStackNovaProviderMetadata(ConcreteBuilder builder) { + super(builder); } - /** - * {@inheritDoc} - */ - @Override - public String getIdentityName() { - return "tenantId:user"; + private static class ConcreteBuilder extends Builder { + + @Override + public TryStackNovaProviderMetadata build() { + return new TryStackNovaProviderMetadata(this); + } } - /** - * {@inheritDoc} - */ - @Override - public String getCredentialName() { - return "Password"; + public static ConcreteBuilder builder() { + return new ConcreteBuilder(); } - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return "HP Cloud Compute Services"; + public ConcreteBuilder toBuilder() { + return builder().fromProviderMetadata(this); } - - /** - * {@inheritDoc} - */ - @Override - public URI getHomepage() { - return URI.create("https://trystack.org"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getConsole() { - return URI.create("https://trystack.org/dash"); - } - - /** - * {@inheritDoc} - */ - @Override - public URI getApiDocumentation() { - return URI.create("http://api.openstack.org/"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getLinkedServices() { - return ImmutableSet.of("trystack-nova"); - } - - /** - * {@inheritDoc} - */ - @Override - public Set getIso3166Codes() { - return ImmutableSet.of("US-CA"); - } - } diff --git a/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/TryStackNovaProviderTest.java b/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/TryStackNovaProviderTest.java index ce95da3dcc..3971fadece 100644 --- a/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/TryStackNovaProviderTest.java +++ b/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/TryStackNovaProviderTest.java @@ -35,8 +35,8 @@ */ package org.jclouds.trystack.nova; +import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; import org.jclouds.providers.BaseProviderMetadataTest; -import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** @@ -47,6 +47,6 @@ import org.testng.annotations.Test; public class TryStackNovaProviderTest extends BaseProviderMetadataTest { public TryStackNovaProviderTest() { - super(new TryStackNovaProviderMetadata(), ProviderMetadata.COMPUTE_TYPE); + super(new TryStackNovaProviderMetadata(), new NovaApiMetadata()); } } diff --git a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/ProvidersInPropertiesTest.java b/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/ProvidersInPropertiesTest.java deleted file mode 100644 index c9a55a7d92..0000000000 --- a/sandbox-apis/nirvanix/src/test/java/org/jclouds/nirvanix/sdn/ProvidersInPropertiesTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.nirvanix.sdn; - -import org.jclouds.blobstore.util.BlobStoreUtils; -import org.jclouds.rest.Providers; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - * - */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "sdn") : providers; - } - - @Test - public void testSupportedBlobStoreProviders() { - Iterable providers = BlobStoreUtils.getSupportedProviders(); - assert !Iterables.contains(providers, "sdn") : providers; - } - -} diff --git a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/ProvidersInPropertiesTest.java b/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/ProvidersInPropertiesTest.java deleted file mode 100644 index 8e590191e9..0000000000 --- a/sandbox-apis/pcs/src/test/java/org/jclouds/mezeo/pcs/ProvidersInPropertiesTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.mezeo.pcs; - -import org.jclouds.blobstore.util.BlobStoreUtils; -import org.jclouds.rest.Providers; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - * - */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "pcs") : providers; - } - - @Test - public void testSupportedBlobStoreProviders() { - Iterable providers = BlobStoreUtils.getSupportedProviders(); - assert !Iterables.contains(providers, "pcs") : providers; - } - -} diff --git a/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/ProvidersInPropertiesTest.java b/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/ProvidersInPropertiesTest.java deleted file mode 100644 index 5426d8d188..0000000000 --- a/sandbox-providers/ibm-smartcloud/src/test/java/org/jclouds/ibm/smartcloud/ProvidersInPropertiesTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.jclouds.ibm.smartcloud; - -import org.jclouds.compute.util.ComputeServiceUtils; -import org.jclouds.rest.Providers; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; - -/** - * - * @author Adrian Cole - * - */ -@Test(groups = "unit") -public class ProvidersInPropertiesTest { - - @Test - public void testSupportedProviders() { - Iterable providers = Providers.getSupportedProviders(); - assert Iterables.contains(providers, "ibm-smartcloud") : providers; - } - - @Test - public void testSupportedComputeServiceProviders() { - Iterable providers = ComputeServiceUtils.getSupportedProviders(); - assert Iterables.contains(providers, "ibm-smartcloud") : providers; - } - -}