From 7329426b65a15590f7ed7c24e4c95d30a9b88255 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Tue, 30 Sep 2014 21:51:46 -0700 Subject: [PATCH] JCLOUDS-664 Updating Azure compute provider Renamed to azurecompute, removed dead code and refactored good code. --- azure-management/.gitignore | 9 - azure-management/README.txt | 8 - azure-management/pom.xml | 128 ------ .../azure/management/AzureManagementApi.java | 93 ----- .../management/AzureManagementApiMetadata.java | 92 ---- .../azure/management/AzureManagementAsyncApi.java | 94 ----- .../AzureManagementProviderMetadata.java | 80 ---- .../BindCreateHostedServiceToXmlPayload.java | 82 ---- .../binders/BindDeploymentParamsToXmlPayload.java | 139 ------- .../binders/BindOSImageParamsToXmlPayload.java | 48 --- .../AzureManagementComputeServiceAdapter.java | 125 ------ ...AzureManagementComputeServiceContextModule.java | 52 --- .../functions/DeploymentToNodeMetadata.java | 31 -- .../compute/functions/OSImageToImage.java | 31 -- .../compute/functions/RoleSizeToHardware.java | 31 -- .../config/AzureManagementProperties.java | 36 -- .../config/AzureManagementRestClientModule.java | 75 ---- .../azure/management/domain/Deployment.java | 306 -------------- .../azure/management/domain/DeploymentParams.java | 222 ---------- .../azure/management/domain/DeploymentSlot.java | 43 -- .../azure/management/domain/DeploymentStatus.java | 43 -- .../domain/DetailedHostedServiceProperties.java | 182 -------- .../org/jclouds/azure/management/domain/Disk.java | 463 --------------------- .../org/jclouds/azure/management/domain/Error.java | 250 ----------- .../azure/management/domain/HostedService.java | 195 --------- .../management/domain/HostedServiceProperties.java | 180 -------- .../HostedServiceWithDetailedProperties.java | 65 --- .../azure/management/domain/InputEndpoint.java | 139 ------- .../azure/management/domain/InstanceStatus.java | 155 ------- .../jclouds/azure/management/domain/Location.java | 161 ------- .../jclouds/azure/management/domain/OSImage.java | 306 -------------- .../azure/management/domain/OSImageParams.java | 177 -------- .../jclouds/azure/management/domain/OSType.java | 47 --- .../jclouds/azure/management/domain/Operation.java | 210 ---------- .../jclouds/azure/management/domain/RoleSize.java | 43 -- .../domain/hostedservice/CreateDeployment.java | 214 ---------- .../domain/hostedservice/ExtendedProperty.java | 102 ----- .../domain/hostedservice/package-info.java | 24 -- .../azure/management/domain/role/AbstractRole.java | 143 ------- .../jclouds/azure/management/domain/role/DNS.java | 78 ---- .../azure/management/domain/role/DNSServer.java | 93 ----- .../domain/role/DataVirtualHardDisk.java | 57 --- .../azure/management/domain/role/Deployment.java | 185 -------- .../azure/management/domain/role/HostCaching.java | 29 -- .../management/domain/role/OSVirtualHardDisk.java | 66 --- .../management/domain/role/PersistentVMRole.java | 24 -- .../azure/management/domain/role/Protocol.java | 31 -- .../jclouds/azure/management/domain/role/Role.java | 24 -- .../azure/management/domain/role/RoleSize.java | 36 -- .../management/domain/role/VirtualHardDisk.java | 88 ---- .../domain/role/conf/CertificateSetting.java | 78 ---- .../domain/role/conf/ConfigurationSet.java | 47 --- .../domain/role/conf/ConfigurationSetAdapter.java | 150 ------- .../management/domain/role/conf/Credentials.java | 75 ---- .../management/domain/role/conf/DomainJoin.java | 78 ---- .../management/domain/role/conf/InputEndpoint.java | 141 ------- .../azure/management/domain/role/conf/KeyPair.java | 32 -- .../role/conf/LinuxProvisioningConfiguration.java | 105 ----- .../domain/role/conf/LoadBalancerProbe.java | 81 ---- .../domain/role/conf/NetworkConfiguration.java | 68 --- .../management/domain/role/conf/PublicKey.java | 32 -- .../azure/management/domain/role/conf/SSH.java | 67 --- .../azure/management/domain/role/conf/SSHKey.java | 55 --- .../conf/WindowsProvisioningConfiguration.java | 140 ------- .../management/domain/role/conf/package-info.java | 25 -- .../azure/management/domain/role/package-info.java | 25 -- .../jclouds/azure/management/features/DiskApi.java | 43 -- .../azure/management/features/DiskAsyncApi.java | 71 ---- .../management/features/HostedServiceApi.java | 136 ------ .../management/features/HostedServiceAsyncApi.java | 155 ------- .../azure/management/features/LocationApi.java | 40 -- .../management/features/LocationAsyncApi.java | 58 --- .../azure/management/features/OSImageApi.java | 63 --- .../azure/management/features/OSImageAsyncApi.java | 95 ----- .../azure/management/features/OperationApi.java | 31 -- .../management/features/OperationAsyncApi.java | 55 --- .../jclouds/azure/management/features/RoleApi.java | 72 ---- .../azure/management/features/RoleAsyncApi.java | 137 ------ .../management/functions/OSImageParamsName.java | 37 -- .../management/functions/ParseRequestIdHeader.java | 46 -- .../options/CreateHostedServiceOptions.java | 126 ------ .../management/suppliers/KeyStoreSupplier.java | 133 ------ .../suppliers/SSLContextWithKeysSupplier.java | 83 ---- .../azure/management/xml/AttachmentHandler.java | 67 --- .../azure/management/xml/DeploymentHandler.java | 126 ------ .../DetailedHostedServicePropertiesHandler.java | 81 ---- .../jclouds/azure/management/xml/DiskHandler.java | 119 ------ .../jclouds/azure/management/xml/ErrorHandler.java | 68 --- .../azure/management/xml/HostedServiceHandler.java | 109 ----- .../xml/HostedServicePropertiesHandler.java | 74 ---- ...HostedServiceWithDetailedPropertiesHandler.java | 44 -- .../azure/management/xml/ListDisksHandler.java | 88 ---- .../management/xml/ListHostedServicesHandler.java | 93 ----- .../azure/management/xml/ListLocationsHandler.java | 88 ---- .../azure/management/xml/ListOSImagesHandler.java | 88 ---- .../azure/management/xml/LocationHandler.java | 67 --- .../azure/management/xml/OSImageHandler.java | 92 ---- .../azure/management/xml/OperationHandler.java | 111 ----- .../org.jclouds.providers.ProviderMetadata | 1 - .../AzureManagementProviderMetadataTest.java | 28 -- .../management/features/DiskApiExpectTest.java | 81 ---- .../azure/management/features/DiskApiLiveTest.java | 122 ------ .../features/HostedServiceApiExpectTest.java | 168 -------- .../features/HostedServiceApiLiveTest.java | 171 -------- .../management/features/LocationApiExpectTest.java | 59 --- .../management/features/LocationApiLiveTest.java | 61 --- .../management/features/OSImageApiExpectTest.java | 115 ----- .../management/features/OSImageApiLiveTest.java | 116 ------ .../features/OperationApiExpectTest.java | 55 --- .../management/features/RoleApiExpectTest.java | 173 -------- .../internal/BaseAzureManagementApiExpectTest.java | 23 - .../internal/BaseAzureManagementApiLiveTest.java | 51 --- .../BaseAzureManagementAsyncApiExpectTest.java | 32 -- .../internal/BaseAzureManagementExpectTest.java | 55 --- .../jclouds/azure/management/parse/ErrorTest.java | 52 --- .../azure/management/parse/GetDeploymentTest.java | 65 --- .../parse/GetHostedServiceDetailsTest.java | 67 --- .../management/parse/GetHostedServiceTest.java | 57 --- .../azure/management/parse/GetOperationTest.java | 60 --- .../azure/management/parse/ListDisksTest.java | 73 ---- .../management/parse/ListHostedServicesTest.java | 82 ---- .../azure/management/parse/ListLocationsTest.java | 82 ---- .../azure/management/parse/ListOSImagesTest.java | 122 ------ azure-management/src/test/resources/azure-test.p12 | Bin 1536 -> 0 bytes .../src/test/resources/capturerolepayload.xml | 1 - .../resources/create_hostedservice_location.xml | 1 - .../create_hostedservice_location_options.xml | 1 - azure-management/src/test/resources/deployment.xml | 70 ---- .../src/test/resources/deploymentparams.xml | 1 - azure-management/src/test/resources/disks.xml | 23 - azure-management/src/test/resources/error.xml | 5 - .../src/test/resources/hostedservice.xml | 10 - .../src/test/resources/hostedservice_details.xml | 13 - .../src/test/resources/hostedservices.xml | 29 -- .../src/test/resources/imageparams.xml | 1 - azure-management/src/test/resources/images.xml | 75 ---- azure-management/src/test/resources/locations.xml | 57 --- azure-management/src/test/resources/operation.xml | 10 - .../src/test/resources/restartrolepayload.xml | 1 - .../src/test/resources/shutdownrolepayload.xml | 1 - .../src/test/resources/startrolepayload.xml | 1 - azurecompute/.gitignore | 9 + azurecompute/README.md | 23 + azurecompute/pom.xml | 151 +++++++ .../org/jclouds/azurecompute/AzureComputeApi.java | 101 +++++ .../azurecompute/AzureComputeProviderMetadata.java | 78 ++++ .../azurecompute/AzureManagementApiMetadata.java | 80 ++++ .../BindCreateHostedServiceToXmlPayload.java | 79 ++++ .../binders/BindDeploymentParamsToXmlPayload.java | 112 +++++ .../binders/BindOSImageParamsToXmlPayload.java | 46 ++ .../compute/AzureComputeServiceAdapter.java | 103 +++++ .../config/AzureComputeServiceContextModule.java | 48 +++ .../compute/functions/AzureImageToImage.java | 29 ++ .../functions/DeploymentToNodeMetadata.java | 30 ++ .../compute/functions/RoleSizeToHardware.java | 30 ++ .../config/AzureComputeHttpApiModule.java | 41 ++ .../config/AzureComputeProperties.java | 36 ++ .../jclouds/azurecompute/domain/Deployment.java | 309 ++++++++++++++ .../azurecompute/domain/DeploymentParams.java | 208 +++++++++ .../azurecompute/domain/DeploymentSlot.java | 42 ++ .../azurecompute/domain/DeploymentStatus.java | 43 ++ .../domain/DetailedHostedServiceProperties.java | 173 ++++++++ .../java/org/jclouds/azurecompute/domain/Disk.java | 442 ++++++++++++++++++++ .../org/jclouds/azurecompute/domain/Error.java | 240 +++++++++++ .../jclouds/azurecompute/domain/HostedService.java | 184 ++++++++ .../domain/HostedServiceProperties.java | 170 ++++++++ .../HostedServiceWithDetailedProperties.java | 63 +++ .../org/jclouds/azurecompute/domain/Image.java | 298 +++++++++++++ .../jclouds/azurecompute/domain/ImageParams.java | 165 ++++++++ .../jclouds/azurecompute/domain/InputEndpoint.java | 137 ++++++ .../azurecompute/domain/InstanceStatus.java | 155 +++++++ .../org/jclouds/azurecompute/domain/Location.java | 150 +++++++ .../org/jclouds/azurecompute/domain/OSType.java | 47 +++ .../org/jclouds/azurecompute/domain/Operation.java | 200 +++++++++ .../org/jclouds/azurecompute/domain/Protocol.java | 31 ++ .../org/jclouds/azurecompute/domain/RoleSize.java | 42 ++ .../azurecompute/features/DeploymentApi.java | 80 ++++ .../org/jclouds/azurecompute/features/DiskApi.java | 69 +++ .../azurecompute/features/HostedServiceApi.java | 157 +++++++ .../jclouds/azurecompute/features/ImageApi.java | 99 +++++ .../jclouds/azurecompute/features/LocationApi.java | 54 +++ .../azurecompute/features/OperationApi.java | 48 +++ .../azurecompute/features/VirtualMachineApi.java | 87 ++++ .../azurecompute/functions/ImageParamsName.java | 34 ++ .../functions/ParseRequestIdHeader.java | 44 ++ .../options/CreateHostedServiceOptions.java | 116 ++++++ .../azurecompute/suppliers/KeyStoreSupplier.java | 129 ++++++ .../suppliers/SSLContextWithKeysSupplier.java | 80 ++++ .../azurecompute/xml/AttachmentHandler.java | 58 +++ .../azurecompute/xml/DeploymentHandler.java | 115 +++++ .../DetailedHostedServicePropertiesHandler.java | 73 ++++ .../org/jclouds/azurecompute/xml/DiskHandler.java | 107 +++++ .../org/jclouds/azurecompute/xml/ErrorHandler.java | 58 +++ .../azurecompute/xml/HostedServiceHandler.java | 93 +++++ .../xml/HostedServicePropertiesHandler.java | 64 +++ ...HostedServiceWithDetailedPropertiesHandler.java | 42 ++ .../org/jclouds/azurecompute/xml/ImageHandler.java | 88 ++++ .../jclouds/azurecompute/xml/ListDisksHandler.java | 73 ++++ .../xml/ListHostedServicesHandler.java | 78 ++++ .../azurecompute/xml/ListImagesHandler.java | 73 ++++ .../azurecompute/xml/ListLocationsHandler.java | 73 ++++ .../jclouds/azurecompute/xml/LocationHandler.java | 57 +++ .../jclouds/azurecompute/xml/OperationHandler.java | 97 +++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../AzureComputeProviderMetadataTest.java | 28 ++ .../features/DeploymentApiMockTest.java | 112 +++++ .../azurecompute/features/DiskApiLiveTest.java | 120 ++++++ .../azurecompute/features/DiskApiMockTest.java | 89 ++++ .../features/HostedServiceApiLiveTest.java | 168 ++++++++ .../features/HostedServiceApiMockTest.java | 186 +++++++++ .../azurecompute/features/ImageApiLiveTest.java | 110 +++++ .../azurecompute/features/ImageApiMockTest.java | 128 ++++++ .../azurecompute/features/LocationApiLiveTest.java | 60 +++ .../azurecompute/features/LocationApiMockTest.java | 59 +++ .../features/OperationApiMockTest.java | 59 +++ .../features/VirtualMachineApiMockTest.java | 99 +++++ .../internal/BaseAzureComputeApiLiveTest.java | 39 ++ .../internal/BaseAzureComputeApiMockTest.java | 95 +++++ .../org/jclouds/azurecompute/parse/ErrorTest.java | 50 +++ .../azurecompute/parse/GetDeploymentTest.java | 62 +++ .../parse/GetHostedServiceDetailsTest.java | 65 +++ .../azurecompute/parse/GetHostedServiceTest.java | 55 +++ .../azurecompute/parse/GetOperationTest.java | 57 +++ .../jclouds/azurecompute/parse/ListDisksTest.java | 71 ++++ .../azurecompute/parse/ListHostedServicesTest.java | 79 ++++ .../jclouds/azurecompute/parse/ListImagesTest.java | 117 ++++++ .../azurecompute/parse/ListLocationsTest.java | 79 ++++ azurecompute/src/test/resources/azure-test.p12 | Bin 0 -> 1536 bytes .../src/test/resources/capturerolepayload.xml | 1 + .../resources/create_hostedservice_location.xml | 1 + .../create_hostedservice_location_options.xml | 1 + azurecompute/src/test/resources/deployment.xml | 70 ++++ .../src/test/resources/deploymentparams.xml | 1 + azurecompute/src/test/resources/disks.xml | 23 + azurecompute/src/test/resources/error.xml | 5 + azurecompute/src/test/resources/hostedservice.xml | 10 + .../src/test/resources/hostedservice_details.xml | 13 + azurecompute/src/test/resources/hostedservices.xml | 29 ++ azurecompute/src/test/resources/imageparams.xml | 1 + azurecompute/src/test/resources/images.xml | 84 ++++ azurecompute/src/test/resources/locations.xml | 57 +++ azurecompute/src/test/resources/operation.xml | 10 + .../src/test/resources/restartrolepayload.xml | 1 + .../src/test/resources/shutdownrolepayload.xml | 1 + .../src/test/resources/startrolepayload.xml | 1 + pom.xml | 1 + 246 files changed, 8539 insertions(+), 11701 deletions(-) delete mode 100644 azure-management/.gitignore delete mode 100644 azure-management/README.txt delete mode 100644 azure-management/pom.xml delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApi.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApiMetadata.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/AzureManagementAsyncApi.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/AzureManagementProviderMetadata.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/binders/BindCreateHostedServiceToXmlPayload.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/binders/BindDeploymentParamsToXmlPayload.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/binders/BindOSImageParamsToXmlPayload.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/compute/AzureManagementComputeServiceAdapter.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/compute/config/AzureManagementComputeServiceContextModule.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/compute/functions/DeploymentToNodeMetadata.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/compute/functions/OSImageToImage.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/compute/functions/RoleSizeToHardware.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/config/AzureManagementProperties.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/config/AzureManagementRestClientModule.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/Deployment.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentParams.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentSlot.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentStatus.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/DetailedHostedServiceProperties.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/Disk.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/Error.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/HostedService.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceProperties.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceWithDetailedProperties.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/InputEndpoint.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/InstanceStatus.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/Location.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/OSImage.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/OSImageParams.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/OSType.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/Operation.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/RoleSize.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/CreateDeployment.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/ExtendedProperty.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/package-info.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/AbstractRole.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/DNS.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/DNSServer.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/DataVirtualHardDisk.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/Deployment.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/HostCaching.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/OSVirtualHardDisk.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/PersistentVMRole.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/Protocol.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/Role.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/RoleSize.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/VirtualHardDisk.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/CertificateSetting.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/ConfigurationSet.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/ConfigurationSetAdapter.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/Credentials.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/DomainJoin.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/InputEndpoint.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/KeyPair.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/LinuxProvisioningConfiguration.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/LoadBalancerProbe.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/NetworkConfiguration.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/PublicKey.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/SSH.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/SSHKey.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/WindowsProvisioningConfiguration.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/package-info.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/domain/role/package-info.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/features/DiskApi.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/features/DiskAsyncApi.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceApi.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceAsyncApi.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/features/LocationApi.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/features/LocationAsyncApi.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/features/OSImageApi.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/features/OSImageAsyncApi.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/features/OperationApi.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/features/OperationAsyncApi.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/features/RoleApi.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/features/RoleAsyncApi.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/functions/OSImageParamsName.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/functions/ParseRequestIdHeader.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/options/CreateHostedServiceOptions.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/suppliers/KeyStoreSupplier.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/suppliers/SSLContextWithKeysSupplier.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/AttachmentHandler.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/DeploymentHandler.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/DetailedHostedServicePropertiesHandler.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/DiskHandler.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/ErrorHandler.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceHandler.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServicePropertiesHandler.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceWithDetailedPropertiesHandler.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/ListDisksHandler.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/ListHostedServicesHandler.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/ListLocationsHandler.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/ListOSImagesHandler.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/LocationHandler.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/OSImageHandler.java delete mode 100644 azure-management/src/main/java/org/jclouds/azure/management/xml/OperationHandler.java delete mode 100644 azure-management/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/AzureManagementProviderMetadataTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiExpectTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiLiveTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiExpectTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiLiveTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiExpectTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiLiveTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiExpectTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiLiveTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/features/OperationApiExpectTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/features/RoleApiExpectTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementApiExpectTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementApiLiveTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementAsyncApiExpectTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementExpectTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/parse/ErrorTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/parse/GetDeploymentTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/parse/GetHostedServiceDetailsTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/parse/GetHostedServiceTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/parse/GetOperationTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/parse/ListDisksTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/parse/ListHostedServicesTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/parse/ListLocationsTest.java delete mode 100644 azure-management/src/test/java/org/jclouds/azure/management/parse/ListOSImagesTest.java delete mode 100644 azure-management/src/test/resources/azure-test.p12 delete mode 100644 azure-management/src/test/resources/capturerolepayload.xml delete mode 100644 azure-management/src/test/resources/create_hostedservice_location.xml delete mode 100644 azure-management/src/test/resources/create_hostedservice_location_options.xml delete mode 100644 azure-management/src/test/resources/deployment.xml delete mode 100644 azure-management/src/test/resources/deploymentparams.xml delete mode 100644 azure-management/src/test/resources/disks.xml delete mode 100644 azure-management/src/test/resources/error.xml delete mode 100644 azure-management/src/test/resources/hostedservice.xml delete mode 100644 azure-management/src/test/resources/hostedservice_details.xml delete mode 100644 azure-management/src/test/resources/hostedservices.xml delete mode 100644 azure-management/src/test/resources/imageparams.xml delete mode 100644 azure-management/src/test/resources/images.xml delete mode 100644 azure-management/src/test/resources/locations.xml delete mode 100644 azure-management/src/test/resources/operation.xml delete mode 100644 azure-management/src/test/resources/restartrolepayload.xml delete mode 100644 azure-management/src/test/resources/shutdownrolepayload.xml delete mode 100644 azure-management/src/test/resources/startrolepayload.xml create mode 100644 azurecompute/.gitignore create mode 100644 azurecompute/README.md create mode 100644 azurecompute/pom.xml create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeProviderMetadata.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindCreateHostedServiceToXmlPayload.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindOSImageParamsToXmlPayload.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/compute/AzureComputeServiceAdapter.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/compute/config/AzureComputeServiceContextModule.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/AzureImageToImage.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/RoleSizeToHardware.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeProperties.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentSlot.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentStatus.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/DetailedHostedServiceProperties.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/Error.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedService.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceProperties.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceWithDetailedProperties.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/InputEndpoint.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/InstanceStatus.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/Location.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSType.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/Operation.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/Protocol.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/domain/RoleSize.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/features/DeploymentApi.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/options/CreateHostedServiceOptions.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/KeyStoreSupplier.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/SSLContextWithKeysSupplier.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/AttachmentHandler.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/DeploymentHandler.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/DetailedHostedServicePropertiesHandler.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/ErrorHandler.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceHandler.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServicePropertiesHandler.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceWithDetailedPropertiesHandler.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListDisksHandler.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListHostedServicesHandler.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListLocationsHandler.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/LocationHandler.java create mode 100644 azurecompute/src/main/java/org/jclouds/azurecompute/xml/OperationHandler.java create mode 100644 azurecompute/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/AzureComputeProviderMetadataTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiMockTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiLiveTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/features/OperationApiMockTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/parse/ErrorTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetDeploymentTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceDetailsTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetOperationTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListDisksTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListHostedServicesTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListImagesTest.java create mode 100644 azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListLocationsTest.java create mode 100644 azurecompute/src/test/resources/azure-test.p12 create mode 100644 azurecompute/src/test/resources/capturerolepayload.xml create mode 100644 azurecompute/src/test/resources/create_hostedservice_location.xml create mode 100644 azurecompute/src/test/resources/create_hostedservice_location_options.xml create mode 100644 azurecompute/src/test/resources/deployment.xml create mode 100644 azurecompute/src/test/resources/deploymentparams.xml create mode 100644 azurecompute/src/test/resources/disks.xml create mode 100644 azurecompute/src/test/resources/error.xml create mode 100644 azurecompute/src/test/resources/hostedservice.xml create mode 100644 azurecompute/src/test/resources/hostedservice_details.xml create mode 100644 azurecompute/src/test/resources/hostedservices.xml create mode 100644 azurecompute/src/test/resources/imageparams.xml create mode 100644 azurecompute/src/test/resources/images.xml create mode 100644 azurecompute/src/test/resources/locations.xml create mode 100644 azurecompute/src/test/resources/operation.xml create mode 100644 azurecompute/src/test/resources/restartrolepayload.xml create mode 100644 azurecompute/src/test/resources/shutdownrolepayload.xml create mode 100644 azurecompute/src/test/resources/startrolepayload.xml diff --git a/azure-management/.gitignore b/azure-management/.gitignore deleted file mode 100644 index 83c270e..0000000 --- a/azure-management/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -# use glob syntax. -syntax: glob -target -.settings -.classpath -.project -jclouds-azure-management.iml -jclouds-azure-management.ipr -jclouds-azure-management.iws diff --git a/azure-management/README.txt b/azure-management/README.txt deleted file mode 100644 index 4136495..0000000 --- a/azure-management/README.txt +++ /dev/null @@ -1,8 +0,0 @@ - How to create the certificate : - - Create the .cer and pfx files using http://www.windowsazure4j.org/learn/labs/Management/index.html or http://msdn.microsoft.com/en-us/library/gg551722 - - Add it to azure : http://msdn.microsoft.com/en-us/library/gg551726 - - Generate the keystore http://stackoverflow.com/questions/4217107/how-to-convert-pfx-file-to-keystore-with-private-key - openssl pkcs12 -in certificate.pfx -out certificate.pem diff --git a/azure-management/pom.xml b/azure-management/pom.xml deleted file mode 100644 index 90664ff..0000000 --- a/azure-management/pom.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - 4.0.0 - - org.apache.jclouds.labs - jclouds-labs - 2.0.0-SNAPSHOT - - - - org.apache.jclouds.labs - azure-management - jclouds azure-management api - jclouds components to access an implementation of Azure Management - bundle - - - FIXME_subscription-id - - https://management.core.windows.net/${jclouds.azure.management.subscription-id} - 2012-03-01 - - /path/to/cert.p12 - password to cert - org.jclouds.azure.management*;version="${project.version}" - - org.jclouds.rest.internal;version="${project.version}", - org.jclouds*;version="${project.version}", - * - - - - - - com.jamesmurty.utils - java-xmlbuilder - 0.4 - - - org.apache.jclouds - jclouds-compute - ${jclouds.version} - - - org.apache.jclouds - jclouds-compute - ${jclouds.version} - test-jar - test - - - org.apache.jclouds - jclouds-core - ${jclouds.version} - test-jar - test - - - org.apache.jclouds.driver - jclouds-slf4j - ${jclouds.version} - test - - - org.apache.jclouds.driver - jclouds-sshj - ${jclouds.version} - test - - - ch.qos.logback - logback-classic - test - - - - - - live - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration - integration-test - - test - - - - ${test.azure-management.endpoint} - ${test.azure-management.api-version} - ${test.azure-management.build-version} - ${test.azure-management.identity} - ${test.azure-management.credential} - ${test.jclouds.azure.management.subscription-id} - - - - - - - - - - - diff --git a/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApi.java b/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApi.java deleted file mode 100644 index 3caec3a..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApi.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management; - -import org.jclouds.azure.management.features.DiskApi; -import org.jclouds.azure.management.features.HostedServiceApi; -import org.jclouds.azure.management.features.LocationApi; -import org.jclouds.azure.management.features.OSImageApi; -import org.jclouds.azure.management.features.OperationApi; -import org.jclouds.azure.management.features.RoleApi; -import org.jclouds.rest.annotations.Delegate; - -/** - * The Windows Azure Service Management API is a REST API for managing your services and - * deployments. - *

- * - * @see AzureManagementAsyncApi - * @see doc - */ -public interface AzureManagementApi { - /** - * The Service Management API includes operations for listing the available data center locations - * for a hosted service in your subscription. - * - * @see docs - * @see AzureManagementAsyncApi#getLocationApi() - */ - @Delegate - LocationApi getLocationApi(); - - /** - * The Service Management API includes operations for managing the hosted services beneath your - * subscription. - * - * @see docs - * @see AzureManagementAsyncApi#getHostedServiceApi() - */ - @Delegate - HostedServiceApi getHostedServiceApi(); - - /** - * The Service Management API includes operations for managing the virtual machines in your - * subscription. - * - * @see docs - * @see AzureManagementAsyncApi#getRoleApi() - */ - @Delegate - RoleApi getRoleApi(); - - /** - * The Service Management API includes operations for managing the OS images in your - * subscription. - * - * @see docs - * @see AzureManagementAsyncApi#getOSImageApi() - */ - @Delegate - OSImageApi getOSImageApi(); - - /** - * The Service Management API includes operations for Tracking Asynchronous Service Management Requests. - * - * @see docs - * @see AzureManagementAsyncApi#getOperationApi() - */ - @Delegate - OperationApi getOperationApi(); - - /** - * The Service Management API includes operations for managing Disks in your subscription. - * - * @see docs - * @see AzureManagementAsyncApi#getDiskApi() - */ - @Delegate - DiskApi getDiskApi(); -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApiMetadata.java b/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApiMetadata.java deleted file mode 100644 index d095522..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementApiMetadata.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management; -import static org.jclouds.azure.management.config.AzureManagementProperties.SUBSCRIPTION_ID; -import static org.jclouds.reflect.Reflection2.typeToken; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.apis.ApiMetadata; -import org.jclouds.azure.management.compute.config.AzureManagementComputeServiceContextModule; -import org.jclouds.azure.management.config.AzureManagementRestClientModule; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.rest.RestContext; -import org.jclouds.rest.internal.BaseRestApiMetadata; - -import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; -import com.google.inject.Module; - -/** - * Implementation of {@link ApiMetadata} for Microsoft Service Management Service API - */ -public class AzureManagementApiMetadata extends BaseRestApiMetadata { - - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; - - private static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return builder().fromApiMetadata(this); - } - - public AzureManagementApiMetadata() { - this(builder()); - } - - protected AzureManagementApiMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); - return properties; - } - - public static class Builder extends BaseRestApiMetadata.Builder { - protected Builder() { - super(AzureManagementApi.class, AzureManagementAsyncApi.class); - id("azure-management") - .name("Microsoft Azure Service Management Service API") - .version("2012-03-01") - .identityName("Path to Management Certificate .p12 file, or PEM string") - .credentialName("Password to Management Certificate") - .defaultEndpoint("https://management.core.windows.net/${" + SUBSCRIPTION_ID + "}") - .endpointName("Service Management Endpoint ending in your Subscription Id") - .documentation(URI.create("http://msdn.microsoft.com/en-us/library/ee460799")) - .defaultProperties(AzureManagementApiMetadata.defaultProperties()) - .view(typeToken(ComputeServiceContext.class)) - .defaultModules(ImmutableSet.> of(AzureManagementComputeServiceContextModule.class, AzureManagementRestClientModule.class)); - } - - @Override - public AzureManagementApiMetadata build() { - return new AzureManagementApiMetadata(this); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementAsyncApi.java b/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementAsyncApi.java deleted file mode 100644 index 3facdc3..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementAsyncApi.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management; - -import org.jclouds.azure.management.features.DiskAsyncApi; -import org.jclouds.azure.management.features.HostedServiceAsyncApi; -import org.jclouds.azure.management.features.LocationAsyncApi; -import org.jclouds.azure.management.features.OSImageAsyncApi; -import org.jclouds.azure.management.features.OperationAsyncApi; -import org.jclouds.azure.management.features.RoleAsyncApi; -import org.jclouds.rest.annotations.Delegate; - -/** - * The Windows Azure Service Management API is a REST API for managing your services and - * deployments. - *

- * - * @see AzureManagementApi - * @see doc - */ -public interface AzureManagementAsyncApi { - /** - * The Service Management API includes operations for listing the available data center locations - * for a hosted service in your subscription. - * - * @see docs - * @see AzureManagementApi#getLocationApi() - */ - @Delegate - LocationAsyncApi getLocationApi(); - - /** - * The Service Management API includes operations for managing the hosted services beneath your - * subscription. - * - * @see docs - * @see AzureManagementApi#getHostedServiceApi() - */ - @Delegate - HostedServiceAsyncApi getHostedServiceApi(); - - /** - * The Service Management API includes operations for managing the virtual machines in your - * subscription. - * - * @see docs - * @see AzureManagementApi#getRoleApi() - */ - @Delegate - RoleAsyncApi getRoleApi(); - - /** - * The Service Management API includes operations for managing the OS images in your - * subscription. - * - * @see docs - * @see AzureManagementApi#getOSImageApi() - */ - @Delegate - OSImageAsyncApi getOSImageApi(); - - /** - * The Service Management API includes operations for Tracking Asynchronous Service Management Requests. - * - * @see docs - * @see AzureManagementApi#getOperationApi() - */ - @Delegate - OperationAsyncApi getOperationApi(); - - - /** - * The Service Management API includes operations for managing Disks in your subscription. - * - * @see docs - * @see AzureManagementApi#getDiskApi() - */ - @Delegate - DiskAsyncApi getDiskApi(); -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementProviderMetadata.java b/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementProviderMetadata.java deleted file mode 100644 index 8b39ea6..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/AzureManagementProviderMetadata.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management; - -import static org.jclouds.azure.management.config.AzureManagementProperties.SUBSCRIPTION_ID; - -import java.net.URI; -import java.util.Properties; - -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadata; - -/** - * Implementation of {@link org.jclouds.types.ProviderMetadata} for Microsoft Azure Service - * Management Service. - */ -public class AzureManagementProviderMetadata extends BaseProviderMetadata { - - public static Builder builder() { - return new Builder(); - } - - @Override - public Builder toBuilder() { - return builder().fromProviderMetadata(this); - } - - public AzureManagementProviderMetadata() { - super(builder()); - } - - public AzureManagementProviderMetadata(Builder builder) { - super(builder); - } - - public static Properties defaultProperties() { - Properties properties = new Properties(); - return properties; - } - - public static class Builder extends BaseProviderMetadata.Builder { - - protected Builder() { - id("azure-management") - .name("Microsoft Azure Service Management Service") - .apiMetadata(new AzureManagementApiMetadata()) - .endpoint("https://management.core.windows.net/${" + SUBSCRIPTION_ID + "}") - .homepage(URI.create("https://www.windowsazure.com/")) - .console(URI.create("https://windows.azure.com/default.aspx")) - .linkedServices("azureblob", "azurequeue", "azuretable") - .iso3166Codes("US-TX", "US-IL", "IE-D", "SG", "NL-NH", "HK") - .defaultProperties(AzureManagementProviderMetadata.defaultProperties()); - } - - @Override - public AzureManagementProviderMetadata build() { - return new AzureManagementProviderMetadata(this); - } - - @Override - public Builder fromProviderMetadata(ProviderMetadata in) { - super.fromProviderMetadata(in); - return this; - } - } -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/binders/BindCreateHostedServiceToXmlPayload.java b/azure-management/src/main/java/org/jclouds/azure/management/binders/BindCreateHostedServiceToXmlPayload.java deleted file mode 100644 index 1337101..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/binders/BindCreateHostedServiceToXmlPayload.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.binders; - -import static com.google.common.base.Charsets.UTF_8; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.io.BaseEncoding.base64; - -import java.util.Map; -import java.util.Map.Entry; - -import javax.inject.Singleton; - -import org.jclouds.azure.management.options.CreateHostedServiceOptions; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.MapBinder; - -import com.google.common.base.Optional; -import com.google.common.base.Throwables; -import com.jamesmurty.utils.XMLBuilder; - -@Singleton -public class BindCreateHostedServiceToXmlPayload implements MapBinder { - - private static final CreateHostedServiceOptions NO_OPTIONS = new CreateHostedServiceOptions(); - - @Override - public R bindToRequest(R request, Map postParams) { - String serviceName = checkNotNull(postParams.get("serviceName"), "serviceName").toString(); - String label = base64().encode(checkNotNull(postParams.get("label"), "label").toString().getBytes(UTF_8)); - - Optional location = Optional.fromNullable((String) postParams.get("location")); - Optional affinityGroup = Optional.fromNullable((String) postParams.get("affinityGroup")); - CreateHostedServiceOptions options = Optional - .fromNullable((CreateHostedServiceOptions) postParams.get("options")).or(NO_OPTIONS); - try { - XMLBuilder createHostedService = XMLBuilder.create("CreateHostedService") - .a("xmlns", "http://schemas.microsoft.com/windowsazure").e("ServiceName").t(serviceName).up() - .e("Label").t(label).up(); - - if (options.getDescription().isPresent()) - createHostedService.e("Description").t(options.getDescription().get()).up(); - - if (location.isPresent()) - createHostedService.e("Location").t(location.get()).up(); - else if (affinityGroup.isPresent()) - createHostedService.e("AffinityGroup").t(affinityGroup.get()).up(); - else - throw new IllegalArgumentException("you must specify either Location or AffinityGroup!"); - - if (options.getExtendedProperties().isPresent() && options.getExtendedProperties().get().size() > 0) { - XMLBuilder extendedProperties = createHostedService.e("ExtendedProperties"); - for (Entry entry : options.getExtendedProperties().get().entrySet()) - extendedProperties.e("ExtendedProperty").e("Name").t(entry.getKey()).up().e("Value").t(entry.getValue()); - } - return (R) request.toBuilder().payload(createHostedService.asString()).build(); - } catch (Exception e) { - throw Throwables.propagate(e); - } - - } - - @Override - public R bindToRequest(R request, Object input) { - throw new IllegalStateException("BindCreateHostedServiceToXmlPayload is needs parameters"); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/binders/BindDeploymentParamsToXmlPayload.java b/azure-management/src/main/java/org/jclouds/azure/management/binders/BindDeploymentParamsToXmlPayload.java deleted file mode 100644 index 5ad949f..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/binders/BindDeploymentParamsToXmlPayload.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.binders; - -import javax.inject.Singleton; - -import org.jclouds.azure.management.domain.DeploymentParams; -import org.jclouds.azure.management.domain.InputEndpoint; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -import com.google.common.base.Throwables; -import com.jamesmurty.utils.XMLBuilder; - -@Singleton -public class BindDeploymentParamsToXmlPayload implements Binder { - - - @Override - public R bindToRequest(R request, Object input) { - DeploymentParams params = DeploymentParams.class.cast(input); - try { - - XMLBuilder builder = XMLBuilder.create("Deployment").a("xmlns", "http://schemas.microsoft.com/windowsazure") - .e("Name").t(params.getName()).up() - .e("DeploymentSlot").t("Production").up() - .e("Label").t(params.getName()).up() - .e("RoleList") - .e("Role") - .e("RoleName").t(params.getName()).up() - .e("RoleType").t("PersistentVMRole").up() - .e("ConfigurationSets"); - - if (params.getOsType() == OSType.WINDOWS){ - XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Windows - configBuilder.e("ConfigurationSetType").t("WindowsProvisioningConfiguration").up() - .e("ComputerName").t(params.getUsername()).up() - .e("AdminPassword").t(params.getPassword()).up() - .e("ResetPasswordOnFirstLogon").t("false").up() - .e("EnableAutomaticUpdate").t("false").up() - .e("DomainJoin") - .e("Credentials") - .e("Domain").t(params.getName()).up() - .e("Username").t(params.getUsername()).up() - .e("Password").t(params.getPassword()).up() - .up()//Credentials - .e("JoinDomain").t(params.getName()).up() - .up()// Domain Join - .e("StoredCertificateSettings").up() - .up();//Windows ConfigurationSet - }else if (params.getOsType() == OSType.LINUX){ - XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Linux - configBuilder.e("ConfigurationSetType").t("LinuxProvisioningConfiguration").up() - .e("HostName").t(params.getName()).up() - .e("UserName").t(params.getUsername()).up() - .e("UserPassword").t(params.getPassword()).up() - .e("DisableSshPasswordAuthentication").t("false").up() - .e("SSH").up() - .up();//Linux ConfigurationSet - } - - XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Network - configBuilder.e("ConfigurationSetType").t("NetworkConfiguration").up(); - - XMLBuilder inputEndpoints = configBuilder.e("InputEndpoints"); - for (InputEndpoint endpoint : params.getEndpoints()){ - XMLBuilder inputBuilder = inputEndpoints.e("InputEndpoint"); - inputBuilder.e("LocalPort").t(endpoint.getLocalPort().toString()).up() - .e("Name").t(endpoint.getName()).up() - .e("Port").t(endpoint.getExternalPort().toString()).up() - .e("Protocol").t(endpoint.getProtocol().name()).up() - .up();//InputEndpoint - } - - inputEndpoints.up(); - configBuilder.e("SubnetNames").up() - .up(); - - builder.up()//ConfigurationSets - .e("DataVirtualHardDisks").up() - .e("OSVirtualHardDisk") - .e("HostCaching").t("ReadWrite").up() - .e("MediaLink").t("http://"+params.getStorageAccount()+".blob.core.windows.net/disks/"+params.getName()+"/"+params.getSourceImageName()).up() - .e("SourceImageName").t(params.getSourceImageName()).up() - .e("OS").t("Linux").up() - .up()//OSVirtualHardDisk - .e("RoleSize").t(params.getSize().value()).up() - .up()//Role - .up();//RoleList - - -// builder.e("ConfigurationSet") // Network -// .e("ConfigurationSetType").t("NetworkConfiguration").up() -// .e("InputEndpoints"); -// -// -// -// -// -// builder.up()//InputEndpoints -// .e("SubnetNames").up() -// .up()//Network ConfigurationSet -// .up()//ConfigurationSets -// .e("DataVirtualHardDisks").up() -// .e("OSVirtualHardDisk") -// .e("HostCaching").t("ReadWrite").up() -// .e("MediaLink").t("http://"+params.getStorageAccount()+".blob.core.windows.net/disks/"+params.getName()+"/"+params.getSourceImageName()).up() -// .e("SourceImageName").t(params.getSourceImageName()).up() -// .e("OS").t("Linux").up() -// .up()//OSVirtualHardDisk -// .e("RoleSize").t(params.getSize().name()).up() -// .up()//Role -// .up();//RoleList - - - - return (R) request.toBuilder().payload(builder.asString()).build(); - } catch (Exception e) { - throw Throwables.propagate(e); - } - - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/binders/BindOSImageParamsToXmlPayload.java b/azure-management/src/main/java/org/jclouds/azure/management/binders/BindOSImageParamsToXmlPayload.java deleted file mode 100644 index 060a68b..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/binders/BindOSImageParamsToXmlPayload.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.binders; - -import javax.inject.Singleton; - -import org.jclouds.azure.management.domain.OSImageParams; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -import com.google.common.base.Throwables; -import com.jamesmurty.utils.XMLBuilder; - -@Singleton -public class BindOSImageParamsToXmlPayload implements Binder { - - - @Override - public R bindToRequest(R request, Object input) { - OSImageParams params = OSImageParams.class.cast(input); - try { - return (R) request.toBuilder().payload(XMLBuilder.create("OSImage").a("xmlns", "http://schemas.microsoft.com/windowsazure") - .e("Label").t(params.getLabel()).up() - .e("MediaLink").t(params.getMediaLink().toASCIIString()).up() - .e("Name").t(params.getName()).up() - .e("OS").t(params.getOS().toString()).up() - .up().asString()).build(); - } catch (Exception e) { - throw Throwables.propagate(e); - } - - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/compute/AzureManagementComputeServiceAdapter.java b/azure-management/src/main/java/org/jclouds/azure/management/compute/AzureManagementComputeServiceAdapter.java deleted file mode 100644 index f2e16d9..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/compute/AzureManagementComputeServiceAdapter.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.compute; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.AzureManagementAsyncApi; -import org.jclouds.azure.management.domain.Deployment; -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.RoleSize; -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.logging.Logger; - -/** - * defines the connection between the {@link AzureApi} implementation and the - * jclouds {@link ComputeService} - */ -@Singleton -public class AzureManagementComputeServiceAdapter implements - ComputeServiceAdapter { - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - private final AzureManagementApi api; - private final AzureManagementAsyncApi aapi; - - @Inject - public AzureManagementComputeServiceAdapter(AzureManagementApi api, - AzureManagementAsyncApi aapi) { - this.api = checkNotNull(api, "api"); - this.aapi = checkNotNull(aapi, "aapi"); - } - - @Override - public org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials createNodeWithGroupEncodedIntoName( - String group, String name, Template template) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Iterable listHardwareProfiles() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Iterable listImages() { - // TODO Auto-generated method stub - return null; - } - - @Override - public OSImage getImage(String id) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Iterable listLocations() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Deployment getNode(String id) { - // TODO Auto-generated method stub - return null; - } - - @Override - public void destroyNode(String id) { - // TODO Auto-generated method stub - - } - - @Override - public void rebootNode(String id) { - // TODO Auto-generated method stub - - } - - @Override - public void resumeNode(String id) { - // TODO Auto-generated method stub - - } - - @Override - public void suspendNode(String id) { - // TODO Auto-generated method stub - - } - - @Override - public Iterable listNodes() { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/compute/config/AzureManagementComputeServiceContextModule.java b/azure-management/src/main/java/org/jclouds/azure/management/compute/config/AzureManagementComputeServiceContextModule.java deleted file mode 100644 index 7c77ff2..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/compute/config/AzureManagementComputeServiceContextModule.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.compute.config; - -import org.jclouds.azure.management.compute.AzureManagementComputeServiceAdapter; -import org.jclouds.azure.management.compute.functions.DeploymentToNodeMetadata; -import org.jclouds.azure.management.compute.functions.OSImageToImage; -import org.jclouds.azure.management.compute.functions.RoleSizeToHardware; -import org.jclouds.azure.management.domain.Deployment; -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.RoleSize; -import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.config.ComputeServiceAdapterContextModule; -import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.NodeMetadata; - -import com.google.common.base.Function; -import com.google.inject.TypeLiteral; - -public class AzureManagementComputeServiceContextModule extends - ComputeServiceAdapterContextModule { - - @Override - protected void configure() { - super.configure(); - bind(new TypeLiteral>() { - }).to(AzureManagementComputeServiceAdapter.class); - bind(new TypeLiteral>() { - }).to(OSImageToImage.class); - bind(new TypeLiteral>() { - }).to(RoleSizeToHardware.class); - bind(new TypeLiteral>() { - }).to(DeploymentToNodeMetadata.class); - - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/DeploymentToNodeMetadata.java b/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/DeploymentToNodeMetadata.java deleted file mode 100644 index 66fe39b..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/DeploymentToNodeMetadata.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.compute.functions; - -import org.jclouds.azure.management.domain.Deployment; -import org.jclouds.compute.domain.NodeMetadata; - -import com.google.common.base.Function; - -public class DeploymentToNodeMetadata implements Function { - - @Override - public NodeMetadata apply(Deployment input) { - return null; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/OSImageToImage.java b/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/OSImageToImage.java deleted file mode 100644 index b6575e9..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/OSImageToImage.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.compute.functions; - -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.compute.domain.Image; - -import com.google.common.base.Function; - -public class OSImageToImage implements Function{ - - @Override - public Image apply(OSImage input) { - return null; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/RoleSizeToHardware.java b/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/RoleSizeToHardware.java deleted file mode 100644 index 00ce385..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/compute/functions/RoleSizeToHardware.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.compute.functions; - -import org.jclouds.azure.management.domain.RoleSize; -import org.jclouds.compute.domain.Hardware; - -import com.google.common.base.Function; - -public class RoleSizeToHardware implements Function { - - @Override - public Hardware apply(RoleSize input) { - return null; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/config/AzureManagementProperties.java b/azure-management/src/main/java/org/jclouds/azure/management/config/AzureManagementProperties.java deleted file mode 100644 index d543455..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/config/AzureManagementProperties.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.config; - -/** - * Configuration properties and constants used in Azure Service Management - * connections. - */ -public class AzureManagementProperties { - /** - * Every call to the Service Management API must include the subscription ID - * for your subscription. The subscription ID is appended to the base URI, - * as follows: - * - *

-	 * https://management.core.windows.net/${subscriptionId}
-	 * 
- * - * @see docs - */ - public static final String SUBSCRIPTION_ID = "jclouds.azure.management.subscription-id"; -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/config/AzureManagementRestClientModule.java b/azure-management/src/main/java/org/jclouds/azure/management/config/AzureManagementRestClientModule.java deleted file mode 100644 index 7e7a351..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/config/AzureManagementRestClientModule.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.config; - -import java.security.KeyStore; -import java.util.Map; - -import javax.net.ssl.SSLContext; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.AzureManagementAsyncApi; -import org.jclouds.azure.management.features.DiskApi; -import org.jclouds.azure.management.features.DiskAsyncApi; -import org.jclouds.azure.management.features.HostedServiceApi; -import org.jclouds.azure.management.features.HostedServiceAsyncApi; -import org.jclouds.azure.management.features.LocationApi; -import org.jclouds.azure.management.features.LocationAsyncApi; -import org.jclouds.azure.management.features.OSImageApi; -import org.jclouds.azure.management.features.OSImageAsyncApi; -import org.jclouds.azure.management.features.OperationApi; -import org.jclouds.azure.management.features.OperationAsyncApi; -import org.jclouds.azure.management.features.RoleApi; -import org.jclouds.azure.management.features.RoleAsyncApi; -import org.jclouds.azure.management.suppliers.KeyStoreSupplier; -import org.jclouds.azure.management.suppliers.SSLContextWithKeysSupplier; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; - -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; -import com.google.inject.TypeLiteral; - -/** - * Configures the Azure Service Management connection. - */ -@ConfiguresRestClient -public class AzureManagementRestClientModule extends RestClientModule { - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder() - .put(LocationApi.class, LocationAsyncApi.class) - .put(RoleApi.class, RoleAsyncApi.class) - .put(HostedServiceApi.class, HostedServiceAsyncApi.class) - .put(OSImageApi.class, OSImageAsyncApi.class) - .put(OperationApi.class, OperationAsyncApi.class) - .put(DiskApi.class, DiskAsyncApi.class).build(); - - public AzureManagementRestClientModule() { - super(DELEGATE_MAP); - } - - @Override - protected void configure() { - super.configure(); - bind(new TypeLiteral>() { - }).to(new TypeLiteral() { - }); - bind(new TypeLiteral>() { - }).to(new TypeLiteral() { - }); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/Deployment.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/Deployment.java deleted file mode 100644 index 9b800e0..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/Deployment.java +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import java.net.URI; - -public class Deployment { - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String deploymentName; - private DeploymentSlot deploymentSlot; - private DeploymentStatus deploymentStatus; - private String deploymentLabel; - private URI deploymentURL; - private String roleName; - private String instanceName; - private InstanceStatus instanceStatus; - private String instanceStateDetails; - private String instanceErrorCode; - private RoleSize instanceSize; - private String privateIpAddress; - private String publicIpAddress; - - public Builder deploymentName(final String deploymentName) { - this.deploymentName = deploymentName; - return this; - } - - public Builder deploymentSlot(final DeploymentSlot deploymentSlot) { - this.deploymentSlot = deploymentSlot; - return this; - } - - public Builder deploymentStatus(final DeploymentStatus deploymentStatus) { - this.deploymentStatus = deploymentStatus; - return this; - } - - public Builder deploymentLabel(final String deploymentLabel) { - this.deploymentLabel = deploymentLabel; - return this; - } - - public Builder deploymentURL(final URI deploymentURL) { - this.deploymentURL = deploymentURL; - return this; - } - - public Builder instanceSize(final RoleSize instanceSize) { - this.instanceSize = instanceSize; - return this; - } - - public Builder instanceName(final String instanceName) { - this.instanceName = instanceName; - return this; - } - - public Builder instanceStatus(final InstanceStatus instanceStatus) { - this.instanceStatus = instanceStatus; - return this; - } - - public Builder instanceStateDetails(final String instanceStateDetails) { - this.instanceStateDetails = instanceStateDetails; - return this; - } - - public Builder instanceErrorCode(final String instanceErrorCode) { - this.instanceErrorCode = instanceErrorCode; - return this; - } - - public Builder privateIpAddress(final String privateIpAddress) { - this.privateIpAddress = privateIpAddress; - return this; - } - - public Builder publicIpAddress(final String publicIpAddress) { - this.publicIpAddress = publicIpAddress; - return this; - } - - public Builder roleName(final String roleName) { - this.roleName = roleName; - return this; - } - - public Deployment build() { - return new Deployment(deploymentName, deploymentSlot, - deploymentStatus, deploymentLabel, deploymentURL, roleName, - instanceName, instanceStatus,instanceStateDetails,instanceErrorCode, instanceSize, - privateIpAddress, publicIpAddress); - } - - } - - /** - * The user-supplied name for this deployment. - */ - private final String deploymentName; - /** - * The environment to which the hosted service is deployed, either staging - * or production. - */ - private final DeploymentSlot deploymentSlot; - /** - * The status of the deployment. - */ - private final DeploymentStatus deploymentStatus; - /** - * The user-supplied name of the deployment returned as a base-64 encoded - * string. This name can be used identify the deployment for your tracking - * purposes. - */ - private final String deploymentLabel; - /** - * The URL used to access the hosted service. For example, if the service - * name is MyService you could access the access the service by calling: - * http://MyService.cloudapp.net - */ - private final URI deploymentURL; - - /** - * Specifies the name for the virtual machine. The name must be unique - * within Windows Azure. - */ - private final String roleName; - - /** - * The name of the specific role instance (if any). - */ - private final String instanceName; - /** - * The current status of this instance. - */ - private final InstanceStatus instanceStatus; - /** - * The instance state is returned as an English human-readable string that, - * when present, provides a snapshot of the state of the virtual machine at - * the time the operation was called. - * - * For example, when the instance is first being initialized a - * "Preparing Windows for first use." could be returned. - */ - private final String instanceStateDetails; - /** - * Error code of the latest role or VM start - * - * For VMRoles the error codes are: - * - * WaitTimeout - The virtual machine did not communicate back to Azure - * infrastructure within 25 minutes. Typically this indicates that the - * virtual machine did not start or that the guest agent is not installed. - * - * VhdTooLarge - The VHD image selected was too large for the virtual - * machine hosting the role. - * - * AzureInternalError – An internal error has occurred that has caused to - * virtual machine to fail to start. Contact support for additional - * assistance. - * - * For web and worker roles this field returns an error code that can be provided to Windows Azure support to assist in resolution of errors. Typically this field will be empty. - */ - private final String instanceErrorCode; - - /** - * The size of the role instance - */ - private final RoleSize instanceSize; - private final String privateIpAddress; - private final String publicIpAddress; - - public Deployment(String deploymentName, DeploymentSlot deploymentSlot, - DeploymentStatus deploymentStatus, String deploymentLabel, - URI deploymentURL, String roleName, String instanceName, - InstanceStatus instanceStatus,String instanceStateDetails, String instanceErrorCode, RoleSize instanceSize, - String privateIpAddress, String publicIpAddress) { - super(); - this.deploymentName = deploymentName; - this.deploymentSlot = deploymentSlot; - this.deploymentStatus = deploymentStatus; - this.deploymentLabel = deploymentLabel; - this.deploymentURL = deploymentURL; - this.roleName = roleName; - this.instanceName = instanceName; - this.instanceStatus = instanceStatus; - this.instanceStateDetails = instanceStateDetails; - this.instanceErrorCode = instanceErrorCode; - this.instanceSize = instanceSize; - this.privateIpAddress = privateIpAddress; - this.publicIpAddress = publicIpAddress; - } - - public String getDeploymentName() { - return deploymentName; - } - - public DeploymentSlot getDeploymentSlot() { - return deploymentSlot; - } - - public DeploymentStatus getDeploymentStatus() { - return deploymentStatus; - } - - public String getDeploymentLabel() { - return deploymentLabel; - } - - public URI getDeploymentURL() { - return deploymentURL; - } - - public String getRoleName() { - return roleName; - } - - public String getInstanceName() { - return instanceName; - } - - public InstanceStatus getInstanceStatus() { - return instanceStatus; - } - - public String getInstanceStateDetails() { - return instanceStateDetails; - } - - public String getInstanceErrorCode() { - return instanceErrorCode; - } - - public RoleSize getInstanceSize() { - return instanceSize; - } - - public String getPrivateIpAddress() { - return privateIpAddress; - } - - public String getPublicIpAddress() { - return publicIpAddress; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((deploymentName == null) ? 0 : deploymentName.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Deployment other = (Deployment) obj; - if (deploymentName == null) { - if (other.deploymentName != null) - return false; - } else if (!deploymentName.equals(other.deploymentName)) - return false; - return true; - } - - @Override - public String toString() { - return "Deployment [deploymentName=" + deploymentName - + ", deploymentSlot=" + deploymentSlot + ", deploymentStatus=" - + deploymentStatus + ", deploymentLabel=" + deploymentLabel - + ", deploymentURL=" + deploymentURL + ", roleName=" + roleName - + ", instanceName=" + instanceName + ", instanceStatus=" - + instanceStatus + ", instanceStateDetails=" - + instanceStateDetails + ", instanceErrorCode=" - + instanceErrorCode + ", instanceSize=" + instanceSize - + ", privateIpAddress=" + privateIpAddress - + ", publicIpAddress=" + publicIpAddress + "]"; - } - - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentParams.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentParams.java deleted file mode 100644 index dc51c38..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentParams.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import java.util.List; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; -import com.google.common.collect.Lists; - -/** - * - * To create a new deployment/role - * - * Warning : the OSType must be the one of the source image used to create the VM - */ -public class DeploymentParams { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromLinuxDeploymentParams(this); - } - - public static class Builder { - - protected String name; - protected String sourceImageName; - protected String username; - protected String password; - protected String storageAccount; - protected OSType osType; - protected RoleSize size = RoleSize.SMALL; - protected List endpoints = Lists.newArrayList(); - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder sourceImageName(String sourceImageName) { - this.sourceImageName = sourceImageName; - return this; - } - - public Builder username(String username) { - this.username = username; - return this; - } - - public Builder password(String password) { - this.password = password; - return this; - } - - public Builder storageAccount(String storageAccount) { - this.storageAccount = storageAccount; - return this; - } - - public Builder size(RoleSize size) { - this.size = size; - return this; - } - - public Builder osType(OSType osType) { - this.osType = osType; - return this; - } - - public Builder endpoint(InputEndpoint endpoint) { - endpoints.add(endpoint); - return this; - } - - public DeploymentParams build() { - return new DeploymentParams(name, sourceImageName, - username, password, storageAccount, size,osType,endpoints); - } - - public Builder fromLinuxDeploymentParams(DeploymentParams in) { - // TODO Since the roleName should be unique, is it a good idea to - // copy it ? - return this.name(in.getName()) - .sourceImageName(in.getSourceImageName()) - .username(in.getUsername()).password(in.getPassword()) - .size(in.getSize()); - } - } - - protected final String name; - protected final String sourceImageName; - protected final String username; - protected final String password; - protected final String storageAccount; - protected final RoleSize size; - protected final OSType osType; - protected final List endpoints; - - - public DeploymentParams(String name, String sourceImageName, - String username, String password, String storageAccount, - RoleSize size,OSType osType,final List endpoints) { - super(); - this.name = name; - this.sourceImageName = sourceImageName; - this.username = username; - this.password = password; - this.storageAccount = storageAccount; - this.size = size; - this.osType = osType; - this.endpoints = endpoints; - } - - /** - * Specifies the name for the deployment and its virtual machine. The name must be unique - * within Windows Azure. - */ - public String getName() { - return name; - } - - /** - * Specifies the name of an operating system image in the image repository. - */ - public String getSourceImageName() { - return sourceImageName; - } - - /** - * Specifies the name of a user to be created in the sudoer group of the - * virtual machine. User names are ASCII character strings 1 to 32 - * characters in length. - */ - public String getUsername() { - return username; - } - - /** - * Specifies the associated password for the user name. - * PasswoazureManagement are ASCII character strings 6 to 72 characters in - * length. - */ - public String getPassword() { - return password; - } - - public String getStorageAccount() { - return storageAccount; - } - - /** - * The size of the virtual machine to allocate. The default value is Small. - */ - public RoleSize getSize() { - return size; - } - - /** - * Os type of the given sourceImage - */ - public OSType getOsType() { - return osType; - } - - public List getEndpoints() { - return endpoints; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - DeploymentParams other = (DeploymentParams) obj; - return Objects.equal(this.name, other.name); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this).add("name", name) - .add("sourceImageName", sourceImageName).add("size", size); - } -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentSlot.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentSlot.java deleted file mode 100644 index 93a207e..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentSlot.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -public enum DeploymentSlot { - PRODUCTION,STAGING; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static DeploymentSlot fromValue(String type) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to( - CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); - } catch (IllegalArgumentException e) { - return null; - } - } -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentStatus.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentStatus.java deleted file mode 100644 index 9114378..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentStatus.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -public enum DeploymentStatus { - RUNNING, SUSPENDED, RUNNING_TRANSITIONING, SUSPENDED_TRANSITIONING, STARTING, SUSPENDING, DEPLOYING, DELETING; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static DeploymentStatus fromValue(String type) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to( - CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); - } catch (IllegalArgumentException e) { - return null; - } - } -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/DetailedHostedServiceProperties.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/DetailedHostedServiceProperties.java deleted file mode 100644 index 6cbb60f..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/DetailedHostedServiceProperties.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Date; -import java.util.Map; - -import org.jclouds.azure.management.domain.HostedService.Status; - -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; - -public class DetailedHostedServiceProperties extends HostedServiceProperties { - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromDetailedHostedServiceProperties(this); - } - - public abstract static class Builder> extends HostedServiceProperties.Builder { - - protected String rawStatus; - protected Status status; - protected Date created; - protected Date lastModified; - protected ImmutableMap.Builder extendedProperties = ImmutableMap. builder(); - - /** - * @see DetailedHostedServiceProperties#getRawStatus() - */ - public T rawStatus(String rawStatus) { - this.rawStatus = rawStatus; - return self(); - } - - /** - * @see DetailedHostedServiceProperties#getStatus() - */ - public T status(Status status) { - this.status = status; - return self(); - } - - /** - * @see DetailedHostedServiceProperties#getCreated() - */ - public T created(Date created) { - this.created = created; - return self(); - } - - /** - * @see DetailedHostedServiceProperties#getLastModified() - */ - public T lastModified(Date lastModified) { - this.lastModified = lastModified; - return self(); - } - - /** - * @see DetailedHostedServiceProperties#getExtendedProperties() - */ - public T extendedProperties(Map extendedProperties) { - this.extendedProperties.putAll(checkNotNull(extendedProperties, "extendedProperties")); - return self(); - } - - /** - * @see DetailedHostedServiceProperties#getExtendedProperties() - */ - public T addExtendedProperty(String name, String value) { - this.extendedProperties.put(checkNotNull(name, "name"), checkNotNull(value, "value")); - return self(); - } - - public DetailedHostedServiceProperties build() { - return new DetailedHostedServiceProperties(description, location, affinityGroup, label, rawStatus, status, - created, lastModified, extendedProperties.build()); - } - - public T fromDetailedHostedServiceProperties(DetailedHostedServiceProperties in) { - return fromHostedServiceProperties(in).rawStatus(in.getRawStatus()).status(in.getStatus()) - .created(in.getCreated()).lastModified(in.getLastModified()) - .extendedProperties(in.getExtendedProperties()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final String rawStatus; - protected final Status status; - protected final Date created; - protected final Date lastModified; - protected final Map extendedProperties; - - protected DetailedHostedServiceProperties(Optional description, Optional location, - Optional affinityGroup, String label, String rawStatus, Status status, Date created, - Date lastModified, Map extendedProperties) { - super(description, location, affinityGroup, label); - this.rawStatus = checkNotNull(rawStatus, "rawStatus of %s", description); - this.status = checkNotNull(status, "status of %s", description); - this.created = checkNotNull(created, "created of %s", description); - this.lastModified = checkNotNull(lastModified, "lastModified of %s", description); - this.extendedProperties = ImmutableMap.copyOf(checkNotNull(extendedProperties, "extendedProperties of %s", - description)); - } - - /** - * The status of the hosted service. - */ - public Status getStatus() { - return status; - } - - /** - * The status of the hosted service unparsed. - */ - public String getRawStatus() { - return rawStatus; - } - - /** - * The date that the hosted service was created. - */ - public Date getCreated() { - return created; - } - - /** - * The date that the hosted service was last updated. - */ - public Date getLastModified() { - return lastModified; - } - - /** - * Represents the name of an extended hosted service property. Each extended property must have - * both a defined name and value. You can have a maximum of 50 extended property name/value - * pairs. - * - * The maximum length of the Name element is 64 characters, only alphanumeric characters and - * underscores are valid in the Name, and the name must start with a letter. Each extended - * property value has a maximum length of 255 characters. - */ - public Map getExtendedProperties() { - return extendedProperties; - } - - /** - * {@inheritDoc} - */ - @Override - public ToStringHelper string() { - return super.string().add("status", rawStatus).add("created", created).add("lastModified", lastModified) - .add("extendedProperties", extendedProperties); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/Disk.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/Disk.java deleted file mode 100644 index a8df087..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/Disk.java +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; -import com.google.common.base.Optional; - -/** - * disk in the image repository - * - * @see api - */ -public class Disk { - public static class Attachment { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromAttachment(this); - } - - public static class Builder { - - private String hostedService; - private String deployment; - private String role; - - /** - * @see Attachment#getHostedService() - */ - public Builder hostedService(String hostedService) { - this.hostedService = hostedService; - return this; - } - - /** - * @see Attachment#getDeployment() - */ - public Builder deployment(String deployment) { - this.deployment = deployment; - return this; - } - - /** - * @see Attachment#getRole() - */ - public Builder role(String role) { - this.role = role; - return this; - } - - public Attachment build() { - return new Attachment(hostedService, deployment, role); - } - - public Builder fromAttachment(Attachment in) { - return this.hostedService(in.hostedService).deployment(in.deployment).role(in.role); - } - } - - private final String hostedService; - private final String deployment; - private final String role; - - protected Attachment(String hostedService, String deployment, String role) { - this.hostedService = checkNotNull(hostedService, "hostedService"); - this.deployment = checkNotNull(deployment, "deployment"); - this.role = checkNotNull(role, "role"); - } - - /** - * The deployment in which the disk is being used. - */ - public String getDeployment() { - return deployment; - } - - /** - * The hosted service in which the disk is being used. - */ - public String getHostedService() { - return hostedService; - } - - /** - * The virtual machine that the disk is attached to. - */ - public String getRole() { - return role; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(hostedService, deployment, role); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Attachment other = (Attachment) obj; - return Objects.equal(this.hostedService, other.hostedService) - && Objects.equal(this.deployment, other.deployment) && Objects.equal(this.role, other.role); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return MoreObjects.toStringHelper(this).omitNullValues().add("deployment", hostedService).add("role", role) - .toString(); - } - - } - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromHostedService(this); - } - - public abstract static class Builder> { - protected abstract T self(); - - protected Optional attachedTo = Optional.absent(); - protected OSType os; - protected String name; - protected Optional logicalSizeInGB = Optional.absent(); - protected Optional description = Optional.absent(); - protected Optional location = Optional.absent(); - protected Optional affinityGroup = Optional.absent(); - protected Optional mediaLink = Optional.absent(); - protected Optional sourceImage = Optional.absent(); - protected Optional label = Optional.absent(); - protected boolean hasOperatingSystem; - protected boolean isCorrupted; - - /** - * @see Disk#getAttachedTo() - */ - public T attachedTo(Attachment attachedTo) { - this.attachedTo = Optional.fromNullable(attachedTo); - return self(); - } - - /** - * @see Disk#getOS() - */ - public T os(OSType os) { - this.os = os; - return self(); - } - - /** - * @see Disk#getName() - */ - public T name(String name) { - this.name = name; - return self(); - } - - /** - * @see Disk#getDescription() - */ - public T description(String description) { - this.description = Optional.fromNullable(description); - return self(); - } - - /** - * @see Disk#getLogicalSizeInGB() - */ - public T logicalSizeInGB(Integer logicalSizeInGB) { - this.logicalSizeInGB = Optional.fromNullable(logicalSizeInGB); - return self(); - } - - /** - * @see Disk#getLocation() - */ - public T location(String location) { - this.location = Optional.fromNullable(location); - return self(); - } - - /** - * @see Disk#getAffinityGroup() - */ - public T affinityGroup(String affinityGroup) { - this.affinityGroup = Optional.fromNullable(affinityGroup); - return self(); - } - - /** - * @see Disk#getMediaLink() - */ - public T mediaLink(URI mediaLink) { - this.mediaLink = Optional.fromNullable(mediaLink); - return self(); - } - - /** - * @see Disk#getSourceImage() - */ - public T sourceImage(String sourceImage) { - this.sourceImage = Optional.fromNullable(sourceImage); - return self(); - } - - /** - * @see Disk#getLabel() - */ - public T label(String label) { - this.label = Optional.fromNullable(label); - return self(); - } - - /** - * @see Disk#hasOperatingSystem() - */ - public T hasOperatingSystem(boolean hasOperatingSystem) { - this.hasOperatingSystem = hasOperatingSystem; - return self(); - } - - /** - * @see Disk#isCorrupted() - */ - public T isCorrupted(boolean isCorrupted) { - this.isCorrupted = isCorrupted; - return self(); - } - - public Disk build() { - return new Disk(attachedTo, os, name, logicalSizeInGB, description, location, affinityGroup, mediaLink, - sourceImage, label, hasOperatingSystem, isCorrupted); - } - - public T fromHostedService(Disk in) { - return this.attachedTo(in.attachedTo.orNull()).os(in.getOS()).name(in.getName()) - .logicalSizeInGB(in.getLogicalSizeInGB().orNull()).description(in.getDescription().orNull()) - .location(in.getLocation().orNull()).affinityGroup(in.getAffinityGroup().orNull()) - .mediaLink(in.getMediaLink().orNull()).sourceImage(in.getSourceImage().orNull()) - .label(in.getLabel().orNull()).hasOperatingSystem(in.hasOperatingSystem).isCorrupted(in.isCorrupted); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final Optional attachedTo; - protected final OSType os; - protected final String name; - protected final Optional logicalSizeInGB; - protected final Optional description; - protected final Optional location; - protected final Optional affinityGroup; - protected final Optional mediaLink; - protected final Optional sourceImage; - protected final Optional label; - protected final boolean hasOperatingSystem; - protected final boolean isCorrupted; - - protected Disk(Optional attachedTo, OSType os, String name, Optional logicalSizeInGB, - Optional description, Optional location, Optional affinityGroup, - Optional mediaLink, Optional sourceImage, Optional label, boolean hasOperatingSystem, - boolean isCorrupted) { - this.name = checkNotNull(name, "name"); - this.attachedTo = checkNotNull(attachedTo, "attachedTo for %s", name); - this.logicalSizeInGB = checkNotNull(logicalSizeInGB, "logicalSizeInGB for %s", name); - this.description = checkNotNull(description, "description for %s", name); - this.os = checkNotNull(os, "os for %s", name); - this.location = checkNotNull(location, "location for %s", name); - this.affinityGroup = checkNotNull(affinityGroup, "affinityGroup for %s", name); - this.mediaLink = checkNotNull(mediaLink, "mediaLink for %s", name); - this.sourceImage = checkNotNull(sourceImage, "sourceImage for %s", name); - this.label = checkNotNull(label, "label for %s", name); - this.hasOperatingSystem = hasOperatingSystem; - this.isCorrupted = isCorrupted; - } - - /** - * Contains properties that specify a virtual machine that currently using the disk. A disk - * cannot be deleted as long as it is attached to a virtual machine. - */ - public Optional getAttachedTo() { - return attachedTo; - } - - /** - * The operating system type of the OS image. - */ - public OSType getOS() { - return os; - } - - /** - * The name of the disk. This is the name that is used when creating one or more virtual machines - * using the disk. - */ - public String getName() { - return name; - } - - /** - * The size, in GB, of the image. - */ - public Optional getLogicalSizeInGB() { - return logicalSizeInGB; - } - - /** - * The description for the image. - */ - public Optional getDescription() { - return description; - } - - /** - * The geo-location in which this media is located. The Location value is derived from storage - * account that contains the blob in which the media is located. If the storage account belongs - * to an affinity group the value is absent. - */ - public Optional getLocation() { - return location; - } - - /** - * The affinity in which the media is located. The AffinityGroup value is derived from storage - * account that contains the blob in which the media is located. If the storage account does not - * belong to an affinity group the value is absent. - */ - public Optional getAffinityGroup() { - return affinityGroup; - } - - /** - * The location of the blob in the blob store in which the media for the disk is located. The - * blob location belongs to a storage account in the subscription specified by the - * value in the operation call. - * - * Example: - * - * http://example.blob.core.windows.net/disks/mydisk.vhd - */ - public Optional getMediaLink() { - return mediaLink; - } - - /** - * The name of the OS Image from which the disk was created. This property is populated - * automatically when a disk is created from an OS image by calling the Add Role, Create - * Deployment, or Provision Disk operations. - */ - public Optional getSourceImage() { - return sourceImage; - } - - /** - * The description of the image. - */ - public Optional getLabel() { - return label; - } - - /** - * Returns whether this disk contains operation system. Only disks that have an operating system - * installed can be mounted as an OS Drive. - */ - public boolean hasOperatingSystem() { - return hasOperatingSystem; - } - - /** - * Returns whether there is a consistency failure detected with this disk. If a disk fails the - * consistency check, you delete any virtual machines using it, delete the disk, and inspect the - * blob media to see if the content is intact. You can then reregister the media in the blob as a - * disk. - */ - public boolean isCorrupted() { - return isCorrupted; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Disk other = (Disk) obj; - return Objects.equal(this.name, other.name); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this).omitNullValues().add("os", os).add("name", name) - .add("attachedTo", attachedTo.orNull()).add("logicalSizeInGB", logicalSizeInGB.orNull()) - .add("description", description).add("location", location.orNull()) - .add("affinityGroup", affinityGroup.orNull()).add("mediaLink", mediaLink.orNull()) - .add("sourceImage", sourceImage.orNull()).add("label", label.orNull()) - .add("hasOperatingSystem", hasOperatingSystem).add("isCorrupted", isCorrupted); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/Error.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/Error.java deleted file mode 100644 index 45106a5..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/Error.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; - -/** - * additional error information that is defined by the management service. Th - * - * @see api - */ -public class Error { - - public static enum Code { - - /** - * Bad Request (400) - * - * The versioning header is not specified or was specified incorrectly. - */ - MISSING_OR_INCORRECT_VERSION_HEADER, - - /** - * Bad Request (400) - * - * The request body’s XML was invalid or not correctly specified. - */ - INVALID_XML_REQUEST, - - /** - * Bad Request (400) - * - * A required query parameter was not specified for this request or was specified incorrectly. - */ - MISSING_OR_INVALID_REQUIRED_QUERY_PARAMETER, - - /** - * Bad Request (400) - * - * The HTTP verb specified was not recognized by the server or isn’t valid for this resource. - */ - INVALID_HTTP_VERB, - - /** - * Forbidden (403) - * - * The server failed to authenticate the request. Verify that the certificate is valid and is - * associated with this subscription. - */ - AUTHENTICATION_FAILED, - - /** - * Not Found (404) - * - * The specified resource does not exist. - */ - RESOURCE_NOT_FOUND, - - /** - * Internal Server Error (500) - * - * The server encountered an internal error. Please retry the request. - */ - INTERNAL_ERROR, - - /** - * Internal Server Error (500) - * - * The operation could not be completed within the permitted time. - */ - OPERATION_TIMED_OUT, - - /** - * Service Unavailable (503) - * - * The server (or an internal component) is currently unavailable to receive requests. Please - * retry your request - */ - SERVER_BUSY, - - /** - * Forbidden (403) - * - * The subscription is in a disabled state. - */ - SUBSCRIPTION_DISABLED, - - /** - * Bad Request (400) - * - * A parameter was incorrect. - */ - BAD_REQUEST, - - /** - * Conflict (409) - * - * A conflict occurred to prevent the operation from completing. - */ - CONFLICT_ERROR, - - UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static Code fromValue(String code) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(code, "code"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromError(this); - } - - public static class Builder { - - private String rawCode; - private Code code; - private String message; - - /** - * @see Error#getRawCode() - */ - public Builder rawCode(String rawCode) { - this.rawCode = rawCode; - return this; - } - - /** - * @see Error#getCode() - */ - public Builder code(Code code) { - this.code = code; - return this; - } - - /** - * @see Error#getMessage() - */ - public Builder message(String message) { - this.message = message; - return this; - } - - public Error build() { - return new Error(rawCode, code, message); - } - - public Builder fromError(Error in) { - return this.rawCode(in.rawCode).code(in.code).message(in.message); - } - } - - private final String rawCode; - private final Code code; - private final String message; - - protected Error(String rawCode, Code code, String message) { - this.rawCode = checkNotNull(rawCode, "rawCode for %s", message); - this.code = checkNotNull(code, "code for %s", message); - this.message = checkNotNull(message, "message"); - } - - /** - * Error code - */ - public Code getCode() { - return code; - } - - /** - * Error code, unparsed - */ - public String getRawCode() { - return rawCode; - } - - /** - * User message - */ - public String getMessage() { - return message; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(rawCode, code, message); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Error other = (Error) obj; - return Objects.equal(this.rawCode, other.rawCode) && Objects.equal(this.code, other.code) - && Objects.equal(this.message, other.message); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return MoreObjects.toStringHelper(this).omitNullValues().add("code", rawCode).add("message", message).toString(); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedService.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedService.java deleted file mode 100644 index 982266c..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedService.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import com.google.common.base.CaseFormat; -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; - -/** - * System properties for the specified hosted service - * - * @see api - */ -public class HostedService { - public static enum Status { - - CREATING, - - CREATED, - - DELETING, - - DELETED, - - CHANGING, - - RESOLVING_DNS, - - UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static Status fromValue(String status) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - } - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromHostedService(this); - } - - public abstract static class Builder> { - protected abstract T self(); - - protected URI url; - protected String name; - protected HostedServiceProperties properties; - - /** - * @see HostedService#getUrl() - */ - public T url(URI url) { - this.url = url; - return self(); - } - - /** - * @see HostedService#getName() - */ - public T name(String name) { - this.name = name; - return self(); - } - - /** - * @see HostedService#getProperties() - */ - public T properties(HostedServiceProperties properties) { - this.properties = properties; - return self(); - } - - public HostedService build() { - return new HostedService(url, name, properties); - } - - public T fromHostedService(HostedService in) { - return this.url(in.getUrl()).name(in.getName()).properties(in.getProperties()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final URI url; - protected final String name; - protected final HostedServiceProperties properties; - - protected HostedService(URI url, String name, HostedServiceProperties properties) { - this.url = checkNotNull(url, "url"); - this.name = checkNotNull(name, "name"); - this.properties = checkNotNull(properties, "properties"); - } - - /** - * The Service Management API request URI used to perform Get Hosted Service Properties requests - * against the hosted service. - */ - public URI getUrl() { - return url; - } - - /** - * The name of the hosted service. This name is the DNS prefix name and can be used to access the - * hosted service. - * - * For example, if the service name is MyService you could access the access the service by - * calling: http://MyService.cloudapp.net - */ - public String getName() { - return name; - } - - /** - * Provides the url of the database properties to be used for this DB HostedService. - */ - public HostedServiceProperties getProperties() { - return properties; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(url); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - HostedService other = (HostedService) obj; - return Objects.equal(this.url, other.url); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this).omitNullValues().add("url", url).add("name", name) - .add("properties", properties); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceProperties.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceProperties.java deleted file mode 100644 index d97f20b..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceProperties.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; -import com.google.common.base.Optional; - -/** - * System properties for the specified hosted service. These properties include the service name and - * service type; the name of the affinity group to which the service belongs, or its location if it - * is not part of an affinity group. - * - * @see api - */ -public class HostedServiceProperties { - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromHostedServiceProperties(this); - } - - public abstract static class Builder> { - protected abstract T self(); - - protected Optional description = Optional.absent(); - protected Optional location = Optional.absent(); - protected Optional affinityGroup = Optional.absent(); - protected String label; - - /** - * @see HostedServiceProperties#getDescription() - */ - public T description(String description) { - this.description = Optional.fromNullable(description); - return self(); - } - - /** - * @see HostedServiceProperties#getLocation() - */ - public T location(String location) { - this.location = Optional.fromNullable(location); - return self(); - } - - /** - * @see HostedServiceProperties#getAffinityGroup() - */ - public T affinityGroup(String affinityGroup) { - this.affinityGroup = Optional.fromNullable(affinityGroup); - return self(); - } - - /** - * @see HostedServiceProperties#getLabel() - */ - public T label(String label) { - this.label = label; - return self(); - } - - public HostedServiceProperties build() { - return new HostedServiceProperties(description, location, affinityGroup, label); - } - - public T fromHostedServiceProperties(HostedServiceProperties in) { - return this.description(in.getDescription().orNull()).location(in.getLocation().orNull()) - .affinityGroup(in.getAffinityGroup().orNull()).label(in.getLabel()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final Optional description; - protected final Optional location; - protected final Optional affinityGroup; - protected final String label; - - protected HostedServiceProperties(Optional description, Optional location, - Optional affinityGroup, String label) { - this.description = checkNotNull(description, "description"); - this.location = checkNotNull(location, "location"); - this.affinityGroup = checkNotNull(affinityGroup, "affinityGroup"); - this.label = checkNotNull(label, "label"); - } - - /** - * The description for the hosted service.. - */ - public Optional getDescription() { - return description; - } - - /** - * The geo-location of the hosted service in Windows Azure, if the hosted service is not - * associated with an affinity group. If a location has been specified, the AffinityGroup element - * is not returned. - */ - public Optional getLocation() { - return location; - } - - /** - * The affinity group with which this hosted service is associated, if any. If the service is - * associated with an affinity group, the Location element is not returned. - */ - public Optional getAffinityGroup() { - return affinityGroup; - } - - /** - * The name can be up to 100 characters in length. The name can be used identify the storage account for your tracking purposes. - */ - public String getLabel() { - return label; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(description, location, affinityGroup, label); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - HostedServiceProperties other = (HostedServiceProperties) obj; - return Objects.equal(this.description, other.description) && Objects.equal(this.location, other.location) - && Objects.equal(this.affinityGroup, other.affinityGroup) && Objects.equal(this.label, other.label); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this).omitNullValues().add("description", description.orNull()) - .add("location", location.orNull()).add("affinityGroup", affinityGroup.orNull()).add("label", label); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceWithDetailedProperties.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceWithDetailedProperties.java deleted file mode 100644 index 435ee77..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceWithDetailedProperties.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import java.net.URI; - -public class HostedServiceWithDetailedProperties extends HostedService { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromHostedServiceWithDetailedProperties(this); - } - - public abstract static class Builder> extends HostedService.Builder { - - @Override - public T properties(HostedServiceProperties properties) { - this.properties = DetailedHostedServiceProperties.class.cast(properties); - return self(); - } - - public HostedServiceWithDetailedProperties build() { - return new HostedServiceWithDetailedProperties(url, name, - DetailedHostedServiceProperties.class.cast(properties)); - } - - public T fromHostedServiceWithDetailedProperties(HostedServiceWithDetailedProperties in) { - return fromHostedService(in); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected HostedServiceWithDetailedProperties(URI url, String serviceName, DetailedHostedServiceProperties properties) { - super(url, serviceName, properties); - } - - @Override - public DetailedHostedServiceProperties getProperties() { - return DetailedHostedServiceProperties.class.cast(properties); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/InputEndpoint.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/InputEndpoint.java deleted file mode 100644 index f631775..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/InputEndpoint.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import org.jclouds.azure.management.domain.role.Protocol; - -public class InputEndpoint { - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private Integer localPort; - private Integer externalPort; - private String name; - private Protocol protocol; - - public Builder localPort(Integer localPort) { - this.localPort = localPort; - return this; - } - - public Builder externalPort(Integer externalPort) { - this.externalPort = externalPort; - return this; - } - - public Builder name(String name) { - this.name = name; - return this; - } - - public Builder protocol(Protocol protocol) { - this.protocol = protocol; - return this; - } - - public InputEndpoint build(){ - return new InputEndpoint(localPort, externalPort, name, protocol); - } - - } - - private final Integer localPort; - private final Integer externalPort; - private final String name; - private final Protocol protocol; - - public InputEndpoint(Integer localPort, Integer externalPort, String name, - Protocol protocol) { - super(); - this.localPort = localPort; - this.externalPort = externalPort; - this.name = name; - this.protocol = protocol; - } - - public Integer getLocalPort() { - return localPort; - } - - public Integer getExternalPort() { - return externalPort; - } - - public String getName() { - return name; - } - - public Protocol getProtocol() { - return protocol; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((externalPort == null) ? 0 : externalPort.hashCode()); - result = prime * result - + ((localPort == null) ? 0 : localPort.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result - + ((protocol == null) ? 0 : protocol.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - InputEndpoint other = (InputEndpoint) obj; - if (externalPort == null) { - if (other.externalPort != null) - return false; - } else if (!externalPort.equals(other.externalPort)) - return false; - if (localPort == null) { - if (other.localPort != null) - return false; - } else if (!localPort.equals(other.localPort)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (protocol != other.protocol) - return false; - return true; - } - - @Override - public String toString() { - return "InputEndPoint [localPort=" + localPort + ", externalPort=" - + externalPort + ", name=" + name + ", protocol=" + protocol - + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/InstanceStatus.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/InstanceStatus.java deleted file mode 100644 index 0a59a39..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/InstanceStatus.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -public enum InstanceStatus { - - /** - * The role state is currently unknown. The state should automatically be - * resolved once the role state is detected, so no action is required. - */ - ROLE_STATE_UNKNOWN, - - /** - * The host agent is currently creating resources for the Virtual Machine - * (VM). - */ - CREATING_V_M, - - /** - * The host agent is starting the Virtual Machine. - */ - STARTING_V_M, - - /** - * Windows Azure is creating resources for the role. - */ - CREATING_ROLE, - - /** - * Windows Azure is starting the role. - */ - STARTING_ROLE, - - /** - * The role instance has started and is ready to be used. - */ - READY_ROLE, - - /** - * The role instance is unavailable for requests. This state is usually - * generated while the role is being created or stopped. - */ - BUSY_ROLE, - - /** - * Windows Azure is stopping the role. - */ - STOPPING_ROLE, - - /** - * The host agent is stopping the Virtual Machine. This status also - * indicates that the role has already been stopped. - */ - STOPPING_V_M, - - /** - * The Virtual Machine is being deleted by the host agent. - */ - DELETING_V_M, - - /** - * The Virtual Machine is not running. This is the final state of the - * shutdown process, and no other status messages should be received after - * StoppedVM. - */ - STOPPED_V_M, - - /** - * The role has unexpectedly stopped or has failed to start. This status - * indicates that there is a problem with the role that is causing it to - * crash or preventing it from starting, and must be corrected before the - * role can be started. The InstanceStateDetails and InstanceErrorCode - * fields can hold information about the role error that caused this state, - * which may be useful for identifying and debugging the problem. - */ - RESTARTING_ROLE, - - /** - * The role has continually crashed after being started by Windows Azure. - * This status indicates that there is a problem with the role that prevents - * it from starting, and may be generated after the StartingRole even - * ReadyRole statuses are received. The problem in the role must be found - * and corrected before the role can be started. The InstanceStateDetails - * and InstanceErrorCode fields can hold information about the role error - * that caused this state, which may be useful for identifying and debugging - * the problem. - */ - CYCLING_ROLE, - - /** - * The role has continually failed to start. This status indicates that - * there is a problem with the role that prevents it from starting, and may - * be generated after the process returns StartingRole. The problem in the - * role must be found and corrected before the role can be started. The - * InstanceStateDetails and InstanceErrorCode fields can hold information - * about the role error that caused this state, which may be useful for - * identifying and debugging the problem. - */ - FAILED_STARTING_ROLE, - - /** - * A Windows Azure or container error is preventing the Virtual Machine from - * starting. This status is generated by Windows Azure, and does not - * indicate an error with the role. It may be generated after the - * StartingRole state. - */ - FAILED_STARTING_V_M, - - /** - * The role has timed out before receiving a status message and is not - * responding to requests. - */ - UNRESPONSIVE_ROLE, - - /** - * UNDOCUMENTED BY AZURE - */ - PROVISIONING; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static InstanceStatus fromValue(String type) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to( - CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); - } catch (IllegalArgumentException e) { - return ROLE_STATE_UNKNOWN; - } - } -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/Location.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/Location.java deleted file mode 100644 index 3bae9c1..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/Location.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Set; - -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; - -/** - * - * A geographical region in which a service or storage account will be hosted. - * - * @see api - */ -public class Location { - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromLocation(this); - } - - public static class Builder { - - private String name; - private String displayName; - private ImmutableSet.Builder availableServices = ImmutableSet. builder(); - - /** - * @see Location#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see Location#getDisplayName() - */ - public Builder displayName(String displayName) { - this.displayName = displayName; - return this; - } - - /** - * @see Location#getAvailableServices() - */ - public Builder addAvailableService(String availableService) { - this.availableServices.add(checkNotNull(availableService, "availableService")); - return this; - } - - /** - * @see Location#getAvailableServices() - */ - public Builder availableServices(Iterable availableServices) { - this.availableServices = ImmutableSet. builder().addAll( - checkNotNull(availableServices, "availableServices")); - return this; - } - - public Location build() { - return new Location(name, displayName, availableServices.build()); - } - - public Builder fromLocation(Location in) { - return this.name(in.getName()).displayName(in.getDisplayName()).availableServices(in.getAvailableServices()); - } - } - - private final String name; - private final String displayName; - private final Set availableServices; - - protected Location(String name, String displayName, Iterable availableServices) { - this.name = checkNotNull(name, "name"); - this.displayName = checkNotNull(displayName, "displayName for %s", name); - this.availableServices = ImmutableSet.copyOf(checkNotNull(availableServices, "availableServices for %s", name)); - } - - /** - * - * The name of a data center location that is valid for your subscription. For example: - * {@code West Europe} - */ - public String getName() { - return name; - } - - /** - * The localized name of data center location. - */ - public String getDisplayName() { - return displayName; - } - - /** - * Indicates the services available at a location. - * - * Returned values are none, one, or both of the values listed below. - * - * Compute - * - * Storage - */ - public Set getAvailableServices() { - return availableServices; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Location other = (Location) obj; - return Objects.equal(this.name, other.name); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return MoreObjects.toStringHelper(this).omitNullValues().add("name", name).add("displayName", displayName) - .add("availableServices", availableServices).toString(); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/OSImage.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/OSImage.java deleted file mode 100644 index dc6cb3e..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/OSImage.java +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; -import com.google.common.base.Optional; - -/** - * OS images from the image repository - * - * @see api - */ -public class OSImage { - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromHostedService(this); - } - - public abstract static class Builder> { - protected abstract T self(); - - protected OSType os; - protected String name; - protected Optional logicalSizeInGB = Optional.absent(); - protected Optional description = Optional.absent(); - protected Optional category = Optional.absent(); - protected Optional location = Optional.absent(); - protected Optional affinityGroup = Optional.absent(); - protected Optional mediaLink = Optional.absent(); - protected Optional eula = Optional.absent(); - protected String label; - - /** - * @see OSImage#getOS() - */ - public T os(OSType os) { - this.os = os; - return self(); - } - - /** - * @see OSImage#getName() - */ - public T name(String name) { - this.name = name; - return self(); - } - - /** - * @see OSImage#getDescription() - */ - public T description(String description) { - this.description = Optional.fromNullable(description); - return self(); - } - - /** - * @see OSImage#getLogicalSizeInGB() - */ - public T logicalSizeInGB(Integer logicalSizeInGB) { - this.logicalSizeInGB = Optional.fromNullable(logicalSizeInGB); - return self(); - } - - /** - * @see OSImage#getCategory() - */ - public T category(String category) { - this.category = Optional.fromNullable(category); - return self(); - } - - /** - * @see OSImage#getLocation() - */ - public T location(String location) { - this.location = Optional.fromNullable(location); - return self(); - } - - /** - * @see OSImage#getAffinityGroup() - */ - public T affinityGroup(String affinityGroup) { - this.affinityGroup = Optional.fromNullable(affinityGroup); - return self(); - } - - /** - * @see OSImage#getMediaLink() - */ - public T mediaLink(URI mediaLink) { - this.mediaLink = Optional.fromNullable(mediaLink); - return self(); - } - - /** - * @see OSImage#getEula() - */ - public T eula(URI eula) { - this.eula = Optional.fromNullable(eula); - return self(); - } - - /** - * @see OSImage#getLabel() - */ - public T label(String label) { - this.label = label; - return self(); - } - - public OSImage build() { - return new OSImage(os, name, logicalSizeInGB, description, category, location, affinityGroup, mediaLink, eula, - label); - } - - public T fromHostedService(OSImage in) { - return this.os(in.getOS()).name(in.getName()).logicalSizeInGB(in.getLogicalSizeInGB().orNull()) - .description(in.getDescription().orNull()).category(in.getCategory().orNull()) - .location(in.getLocation().orNull()).affinityGroup(in.getAffinityGroup().orNull()) - .mediaLink(in.getMediaLink().orNull()).eula(in.getEula().orNull()).label(in.getLabel()); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final OSType os; - protected final String name; - protected final Optional logicalSizeInGB; - protected final Optional description; - protected final Optional category; - protected final Optional location; - protected final Optional affinityGroup; - protected final Optional mediaLink; - protected final Optional eula; - protected final String label; - - protected OSImage(OSType os, String name, Optional logicalSizeInGB, Optional description, - Optional category, Optional location, Optional affinityGroup, - Optional mediaLink, Optional eula, String label) { - this.name = checkNotNull(name, "name"); - this.logicalSizeInGB = checkNotNull(logicalSizeInGB, "logicalSizeInGB for %s", name); - this.description = checkNotNull(description, "description for %s", name); - this.os = checkNotNull(os, "os for %s", name); - this.category = checkNotNull(category, "category for %s", name); - this.location = checkNotNull(location, "location for %s", name); - this.affinityGroup = checkNotNull(affinityGroup, "affinityGroup for %s", name); - this.mediaLink = checkNotNull(mediaLink, "mediaLink for %s", name); - this.eula = checkNotNull(eula, "eula for %s", name); - this.label = checkNotNull(label, "label for %s", name); - } - - /** - * The operating system type of the OS image. - */ - public OSType getOS() { - return os; - } - - /** - * The name of the hosted service. This name is the DNS prefix name and can be used to access the - * hosted service. - * - * For example, if the service name is MyService you could access the access the service by - * calling: http://MyService.cloudapp.net - */ - public String getName() { - return name; - } - - /** - * The size, in GB, of the image. - */ - public Optional getLogicalSizeInGB() { - return logicalSizeInGB; - } - - /** - * The description for the image. - */ - public Optional getDescription() { - return description; - } - - /** - * The repository classification of image. All user images have the category "User", but - * categories for other images could be, for example "Canonical" - */ - public Optional getCategory() { - return category; - } - - /** - * The geo-location in which this media is located. The Location value is derived from storage - * account that contains the blob in which the media is located. If the storage account belongs - * to an affinity group the value is absent. - */ - public Optional getLocation() { - return location; - } - - /** - * The affinity in which the media is located. The AffinityGroup value is derived from storage - * account that contains the blob in which the media is located. If the storage account does not - * belong to an affinity group the value is absent. - */ - public Optional getAffinityGroup() { - return affinityGroup; - } - - /** - * The location of the blob in the blob store in which the media for the image is located. The - * blob location belongs to a storage account in the subscription specified by the - * value in the operation call. - * - * Example: - * - * http://example.blob.core.windows.net/disks/myimage.vhd - */ - public Optional getMediaLink() { - return mediaLink; - } - - /** - * The eula for the image, if available. - */ - public Optional getEula() { - return eula; - } - - /** - * The description of the image. - */ - public String getLabel() { - return label; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - OSImage other = (OSImage) obj; - return Objects.equal(this.name, other.name); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this).omitNullValues().add("os", os).add("name", name) - .add("logicalSizeInGB", logicalSizeInGB.orNull()).add("description", description) - .add("category", category.orNull()).add("location", location.orNull()) - .add("affinityGroup", affinityGroup.orNull()).add("mediaLink", mediaLink.orNull()) - .add("eula", eula.orNull()).add("label", label); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/OSImageParams.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/OSImageParams.java deleted file mode 100644 index 4a9fce5..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/OSImageParams.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; - -/** - * The Add OS Image operation adds an OS image that is currently stored in a storage account in your - * subscription to the image repository. - * - * @see api - */ -public class OSImageParams { - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromHostedService(this); - } - - public static class Builder { - - protected String label; - protected URI mediaLink; - protected OSType os; - protected String name; - - /** - * @see OSImageParams#getLabel() - */ - public Builder label(String label) { - this.label = label; - return this; - } - - /** - * @see OSImageParams#getMediaLink() - */ - public Builder mediaLink(URI mediaLink) { - this.mediaLink = mediaLink; - return this; - } - - /** - * @see OSImageParams#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see OSImageParams#getOS() - */ - public Builder os(OSType os) { - this.os = os; - return this; - } - - public OSImageParams build() { - return new OSImageParams(label, mediaLink, name, os); - } - - public Builder fromHostedService(OSImageParams in) { - return this.label(in.getLabel()).mediaLink(in.getMediaLink()).name(in.getName()).os(in.getOS()); - } - } - - protected final String label; - protected final URI mediaLink; - protected final String name; - protected final OSType os; - - protected OSImageParams(String label, URI mediaLink, String name, OSType os) { - this.label = checkNotNull(label, "label"); - this.name = checkNotNull(name, "name for %s", label); - this.mediaLink = checkNotNull(mediaLink, "mediaLink for %s", label); - this.os = checkNotNull(os, "os for %s", label); - } - - /** - * The operating system type of the OS image. - */ - public OSType getOS() { - return os; - } - - /** - * The name of the hosted service. This name is the DNS prefix name and can be used to access the - * hosted service. - * - * For example, if the service name is MyService you could access the access the service by - * calling: http://MyService.cloudapp.net - */ - public String getName() { - return name; - } - - /** - * The location of the blob in the blob store in which the media for the image is located. The - * blob location belongs to a storage account in the subscription specified by the - * value in the operation call. - * - * Example: - * - * http://example.blob.core.windows.net/disks/myimage.vhd - */ - public URI getMediaLink() { - return mediaLink; - } - - /** - * The description of the image. - */ - public String getLabel() { - return label; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - OSImageParams other = (OSImageParams) obj; - return Objects.equal(this.name, other.name); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this).add("label", label).add("mediaLink", mediaLink).add("name", name) - .add("os", os); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/OSType.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/OSType.java deleted file mode 100644 index 673bfd0..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/OSType.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -public enum OSType { - - LINUX, - - WINDOWS, - - UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static OSType fromValue(String type) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/Operation.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/Operation.java deleted file mode 100644 index f925288..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/Operation.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; -import com.google.common.base.Optional; - -/** - * - * Determines whether the operation has succeeded, failed, or is still in progress. - * - * @see api - */ -public class Operation { - - public static enum Status { - - IN_PROGRESS, - - SUCCEEDED, - - FAILED, - - UNRECOGNIZED; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static Status fromValue(String status) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromOperation(this); - } - - public static class Builder { - - private String id; - private String rawStatus; - private Status status; - // When the operation is in progress, no status code is returned - private Optional httpStatusCode = Optional.absent(); - private Optional error = Optional.absent(); - - /** - * @see Operation#getId() - */ - public Builder id(String id) { - this.id = id; - return this; - } - - /** - * @see Operation#getRawStatus() - */ - public Builder rawStatus(String rawStatus) { - this.rawStatus = rawStatus; - return this; - } - - /** - * @see Operation#getStatus() - */ - public Builder status(Status status) { - this.status = status; - return this; - } - - /** - * @see Operation#getHttpStatusCode() - */ - public Builder httpStatusCode(Integer httpStatusCode) { - this.httpStatusCode = Optional.fromNullable(httpStatusCode); - return this; - } - - /** - * @see Operation#getError() - */ - public Builder error(Error error) { - this.error = Optional.fromNullable(error); - return this; - } - - public Operation build() { - return new Operation(id, rawStatus, status, httpStatusCode, error); - } - - public Builder fromOperation(Operation in) { - return this.id(in.id).rawStatus(in.rawStatus).status(in.status).httpStatusCode(in.httpStatusCode.orNull()) - .error(in.error.orNull()); - } - } - - private final String id; - private final String rawStatus; - private final Status status; - private final Optional httpStatusCode; - private final Optional error; - - protected Operation(String id, String rawStatus, Status status, Optional httpStatusCode, Optional error) { - this.id = checkNotNull(id, "id"); - this.rawStatus = checkNotNull(rawStatus, "rawStatus for %s", id); - this.status = checkNotNull(status, "status for %s", id); - this.httpStatusCode = checkNotNull(httpStatusCode, "httpStatusCode for %s", id); - this.error = checkNotNull(error, "error for %s", id); - } - - /** - * The request ID of the asynchronous request. - */ - public String getId() { - return id; - } - - /** - * The status of the asynchronous request. - */ - public Status getStatus() { - return status; - } - - /** - * The status of the asynchronous request, unparsed - */ - public String getRawStatus() { - return rawStatus; - } - - /** - * The HTTP status code for the asynchronous request. - */ - public Optional getHttpStatusCode() { - return httpStatusCode; - } - - /** - * The management service error returned if the asynchronous request failed. - */ - public Optional getError() { - return error; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(id); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Operation other = (Operation) obj; - return Objects.equal(this.id, other.id); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return MoreObjects.toStringHelper(this).omitNullValues().add("id", id).add("status", rawStatus) - .add("httpStatusCode", httpStatusCode).add("error", error.orNull()).toString(); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/RoleSize.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/RoleSize.java deleted file mode 100644 index 481207b..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/RoleSize.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.google.common.base.CaseFormat; - -public enum RoleSize { - EXTRA_SMALL, SMALL, MEDIUM, LARGE, EXTRA_LARGE; - - public String value() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - - @Override - public String toString() { - return value(); - } - - public static RoleSize fromValue(String type) { - try { - return valueOf(CaseFormat.UPPER_CAMEL.to( - CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); - } catch (IllegalArgumentException e) { - return null; - } - } -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/CreateDeployment.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/CreateDeployment.java deleted file mode 100644 index 90e13a2..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/CreateDeployment.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.hostedservice; - -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.collect.Lists; - -@XmlRootElement(name = "CreateDeployment") -public class CreateDeployment { - - /** - * The name for the deployment. The deployment name must be unique among other deployments for - * the hosted service. - */ - @XmlElement(required = true, name = "Name") - private String name; - - /** - * A URL that refers to the location of the service package in the Blob service. The service - * package can be located either in a storage account beneath the same subscription or a Shared - * Access Signature (SAS) URI from any storage account. - */ - @XmlElement(required = true, name = "PackageUrl") - private String packageUrl; - - /** - * The base-64 encoded service configuration file for the deployment. - */ - @XmlElement(required = true, name = "Configuration") - private String configuration; - - /** - * A name for the hosted service that is base-64 encoded. The name can be up to 100 characters in - * length. - * - * It is recommended that the label be unique within the subscription. The name can be used - * identify the hosted service for your tracking purposes. - */ - @XmlElement(required = true, name = "Label") - private String label; - - /** - * - * Indicates whether to start the deployment immediately after it is created. The default value - * is false. - * - * If false, the service model is still deployed to the virtual machines but the code is not run - * immediately. Instead, the service is Suspended until you call Update Deployment Status and set - * the status to Running, at which time the service will be started. A deployed service still - * incurs charges, even if it is suspended. - */ - @XmlElement(name = "StartDeployment") - private Boolean startDeployment; - - /** - * - * Optional. Indicates whether to treat package validation warnings as errors. The default value - * is false. If set to true, the Created Deployment operation fails if there are validation - * warnings on the service package. - */ - @XmlElement(name = "TreatWarningsAsError") - private Boolean treatWarningsAsError; - - @XmlElementWrapper(name = "ExtendedProperties") - @XmlElement(required = true, name = "ExtendedProperty") - private List extendedProperties = Lists.newArrayList(); - - public CreateDeployment() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPackageUrl() { - return packageUrl; - } - - public void setPackageUrl(String packageUrl) { - this.packageUrl = packageUrl; - } - - public String getConfiguration() { - return configuration; - } - - public void setConfiguration(String configuration) { - this.configuration = configuration; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public Boolean getStartDeployment() { - return startDeployment; - } - - public void setStartDeployment(Boolean startDeployment) { - this.startDeployment = startDeployment; - } - - public Boolean getTreatWarningsAsError() { - return treatWarningsAsError; - } - - public void setTreatWarningsAsError(Boolean treatWarningsAsError) { - this.treatWarningsAsError = treatWarningsAsError; - } - - public List getExtendedProperties() { - return extendedProperties; - } - - public void setExtendedProperties(List extendedProperties) { - this.extendedProperties = extendedProperties; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((configuration == null) ? 0 : configuration.hashCode()); - result = prime * result + ((extendedProperties == null) ? 0 : extendedProperties.hashCode()); - result = prime * result + ((label == null) ? 0 : label.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((packageUrl == null) ? 0 : packageUrl.hashCode()); - result = prime * result + ((startDeployment == null) ? 0 : startDeployment.hashCode()); - result = prime * result + ((treatWarningsAsError == null) ? 0 : treatWarningsAsError.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CreateDeployment other = (CreateDeployment) obj; - if (configuration == null) { - if (other.configuration != null) - return false; - } else if (!configuration.equals(other.configuration)) - return false; - if (extendedProperties == null) { - if (other.extendedProperties != null) - return false; - } else if (!extendedProperties.equals(other.extendedProperties)) - return false; - if (label == null) { - if (other.label != null) - return false; - } else if (!label.equals(other.label)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (packageUrl == null) { - if (other.packageUrl != null) - return false; - } else if (!packageUrl.equals(other.packageUrl)) - return false; - if (startDeployment == null) { - if (other.startDeployment != null) - return false; - } else if (!startDeployment.equals(other.startDeployment)) - return false; - if (treatWarningsAsError == null) { - if (other.treatWarningsAsError != null) - return false; - } else if (!treatWarningsAsError.equals(other.treatWarningsAsError)) - return false; - return true; - } - - @Override - public String toString() { - return "CreateDeployment [name=" + name + ", packageUrl=" + packageUrl + ", configuration=" + configuration - + ", label=" + label + ", startDeployment=" + startDeployment + ", treatWarningsAsError=" - + treatWarningsAsError + ", extendedProperties=" + extendedProperties + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/ExtendedProperty.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/ExtendedProperty.java deleted file mode 100644 index 9f50be0..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/ExtendedProperty.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.hostedservice; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "ExtendedProperty") -public class ExtendedProperty { - - /** - * Represents the name of an extended hosted service property. Each extended property must have - * both a defined name and value. You can have a maximum of 50 extended property name/value - * pairs. - * - * The maximum length of the Name element is 64 characters, only alphanumeric characters and - * underscores are valid in the Name, and the name must start with a letter. Attempting to use - * other characters, starting the Name with a non-letter character, or entering a name that is - * identical to that of another extended property owned by the same hosted service, will result - * in a status code 400 (Bad Request) error. - */ - @XmlElement(name = "Name") - private String name; - - /** - * Represents the value of an extended hosted service property. Each extended property must have - * both a defined name and value. You can have a maximum of 50 extended property name/value - * pairs, and each extended property value has a maximum length of 255 characters. - */ - @XmlElement(name = "Value") - private String value; - - public ExtendedProperty() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((value == null) ? 0 : value.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - ExtendedProperty other = (ExtendedProperty) obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (value == null) { - if (other.value != null) - return false; - } else if (!value.equals(other.value)) - return false; - return true; - } - - @Override - public String toString() { - return "ExtendedProperty [name=" + name + ", value=" + value + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/package-info.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/package-info.java deleted file mode 100644 index 38bafea..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/hostedservice/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -@XmlSchema(namespace = "http://schemas.microsoft.com/windowsazure", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -@XmlAccessorType(XmlAccessType.FIELD) -package org.jclouds.azure.management.domain.hostedservice; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlSchema; - diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/AbstractRole.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/AbstractRole.java deleted file mode 100644 index c58df75..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/AbstractRole.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role; - -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; - -import com.google.common.collect.Lists; - -import org.jclouds.azure.management.domain.role.conf.ConfigurationSet; - -//@XmlRootElement(name = "PersistentVMRole") -public abstract class AbstractRole { - - /** - * Specifies the name for the virtual machine. The name must be unique within Windows Azure. - */ - @XmlElement(required = true, name = "RoleName") - private String roleName; - - /** - * The type of the role for the virtual machine. The only supported value is PersistentVMRole. - */ - @XmlElement(required = true, name = "RoleType") - private String roleType; - - /** - * Required. You must specify either a WindowsProvisioningConfigurationSet or - * LinuxProvisioningConfigurationSet configuration set. - * - * Optional. You can specify a NetworkConfigurationSet which contains the metadata required to - * create the virtual network configuration for a virtual machine. - */ - @XmlElementWrapper(name = "ConfigurationSets") - @XmlElement(name = "ConfigurationSet") - private List configurationSets = Lists.newArrayListWithCapacity(0); - - /** - * Specifies the name of an availability set to which to add the virtual machine. This value - * controls the virtual machine allocation in the Windows Azure environment. Virtual machines - * specified in the same availability set are allocated to different nodes to maximize - * availability. - */ - @XmlElement(name = "AvailabilitySetName") - private String availabilitySetName; - - @XmlElementWrapper(name = "DataVirtualHardDisks") - @XmlElement(name = "DataVirtualHardDisk") - private List dataVirtualHardDisks = Lists.newArrayListWithCapacity(0); - - @XmlElement(name = "OSVirtualHardDisk") - private OSVirtualHardDisk osVirtualHardDisk; - - /** - * The size of the virtual machine to allocate. The default value is Small. - */ - @XmlElement(name = "RoleSize") - private RoleSize roleSize; - - public AbstractRole() { - super(); - } - - public String getRoleName() { - return roleName; - } - - public String getRoleType() { - return roleType; - } - - public String getAvailabilitySetName() { - return availabilitySetName; - } - - public RoleSize getRoleSize() { - return roleSize; - } - - public void setRoleName(String roleName) { - this.roleName = roleName; - } - - public void setRoleType(String roleType) { - this.roleType = roleType; - } - - public void setAvailabilitySetName(String availabilitySetName) { - this.availabilitySetName = availabilitySetName; - } - - public void setRoleSize(RoleSize roleSize) { - this.roleSize = roleSize; - } - - public void setOsVirtualHardDisk(OSVirtualHardDisk osVirtualHardDisk) { - this.osVirtualHardDisk = osVirtualHardDisk; - } - - public OSVirtualHardDisk getOsVirtualHardDisk() { - return osVirtualHardDisk; - } - - public List getConfigurationSets() { - return configurationSets; - } - - public void setConfigurationSets(List configurationSets) { - this.configurationSets = configurationSets; - } - - public List getDataVirtualHardDisks() { - return dataVirtualHardDisks; - } - - public void setDataVirtualHardDisks(List dataVirtualHardDisks) { - this.dataVirtualHardDisks = dataVirtualHardDisks; - } - - @Override - public String toString() { - return "Role [roleName=" + roleName + ", roleType=" + roleType + ", availabilitySetName=" + availabilitySetName - + ", roleSize=" + roleSize + ", osVirtualHardDisk=" + osVirtualHardDisk + ", configurationSets=" - + configurationSets + ", dataVirtualHardDisks=" + dataVirtualHardDisks + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DNS.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DNS.java deleted file mode 100644 index 0955b52..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DNS.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role; - -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.collect.Lists; - -@XmlRootElement(name = "Dns") -public class DNS { - /** - * Contains the parameters specifying the DNS servers to use for the virtual machine. - */ - @XmlElementWrapper(required = true, name = "DnsServers") - @XmlElement(name = "DnsServer") - private List dnsServers = Lists.newArrayList(); - - public DNS() { - super(); - } - - public List getDnsServers() { - return dnsServers; - } - - public void setDnsServers(List dnsServers) { - this.dnsServers = dnsServers; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((dnsServers == null) ? 0 : dnsServers.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - DNS other = (DNS) obj; - if (dnsServers == null) { - if (other.dnsServers != null) - return false; - } else if (!dnsServers.equals(other.dnsServers)) - return false; - return true; - } - - @Override - public String toString() { - return "DNS [dnsServers=" + dnsServers + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DNSServer.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DNSServer.java deleted file mode 100644 index 2d63fad..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DNSServer.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "DnsServer") -public class DNSServer { - - /** - * Specifies the name of the DNS server. - */ - @XmlElement(required = true, name = "Name") - private String name; - - /** - * Specifies the IP address of the DNS server. - */ - @XmlElement(required = true, name = "Address") - private String address; - - public DNSServer() { - super(); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((address == null) ? 0 : address.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - DNSServer other = (DNSServer) obj; - if (address == null) { - if (other.address != null) - return false; - } else if (!address.equals(other.address)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - - @Override - public String toString() { - return "DNSServer [name=" + name + ", address=" + address + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DataVirtualHardDisk.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DataVirtualHardDisk.java deleted file mode 100644 index a7ca035..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/DataVirtualHardDisk.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "DataVirtualHardDisk") -public class DataVirtualHardDisk extends VirtualHardDisk { - - @XmlElement(name = "Lun") - private Integer lun; - - @XmlElement(name = "LogicalDiskSizeInGB") - private Integer logicalDiskSizeInGB; - - public DataVirtualHardDisk() { - - } - - public Integer getLun() { - return lun; - } - - public void setLun(Integer lun) { - this.lun = lun; - } - - public Integer getLogicalDiskSizeInGB() { - return logicalDiskSizeInGB; - } - - public void setLogicalDiskSizeInGB(Integer logicalDiskSizeInGB) { - this.logicalDiskSizeInGB = logicalDiskSizeInGB; - } - - @Override - public String toString() { - return "DataVirtualHardDisk [lun=" + lun + ", logicalDiskSizeInGB=" + logicalDiskSizeInGB + ", hostCaching=" - + hostCaching + ", diskLabel=" + diskLabel + ", diskName=" + diskName + ", mediaLink=" + mediaLink + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Deployment.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Deployment.java deleted file mode 100644 index e58264f..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Deployment.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role; - -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.collect.Lists; - -@XmlRootElement(name = "Deployment") -public class Deployment { - - /** - * A name for the deployment. The deployment name must be unique among other deployments for the - * hosted service. - */ - @XmlElement(required = true, name = "Name") - private String name; - - /** - * Specifies the environment in which to deploy the virtual machine. - * - * Possible values are: Staging Production - */ - @XmlElement(required = true, name = "DeploymentSlot") - private String deploymentSlot; - - /** - * A name for the hosted service that is base-64 encoded. The name can be up to 100 characters in - * length. - * - * It is recommended that the label be unique within the subscription. The name can be used - * identify the hosted service for tracking purposes. - */ - @XmlElement(required = true, name = "Label") - private String label; - - @XmlElementWrapper(required = true, name = "RoleList") - @XmlElement(required = true, name = "Role") - private List roleList = Lists.newArrayList(); - - /** - * Specifies the name of an existing virtual network to which the deployment will belong. - * - * Virtual networks are created by calling the Set Network Configuration operation. - */ - @XmlElement(required = true, name = "VirtualNetworkName") - private String virtualNetworkName; - - /** - * Contains a list of DNS servers to associate with the machine. - */ - @XmlElement(required = true, name = "Dns") - private DNS dns; - - public Deployment() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDeploymentSlot() { - return deploymentSlot; - } - - public void setDeploymentSlot(String deploymentSlot) { - this.deploymentSlot = deploymentSlot; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public List getRoleList() { - return roleList; - } - - public void setRoleList(List roleList) { - this.roleList = roleList; - } - - public String getVirtualNetworkName() { - return virtualNetworkName; - } - - public void setVirtualNetworkName(String virtualNetworkName) { - this.virtualNetworkName = virtualNetworkName; - } - - public DNS getDns() { - return dns; - } - - public void setDns(DNS dns) { - this.dns = dns; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((deploymentSlot == null) ? 0 : deploymentSlot.hashCode()); - result = prime * result + ((dns == null) ? 0 : dns.hashCode()); - result = prime * result + ((label == null) ? 0 : label.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((roleList == null) ? 0 : roleList.hashCode()); - result = prime * result + ((virtualNetworkName == null) ? 0 : virtualNetworkName.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Deployment other = (Deployment) obj; - if (deploymentSlot == null) { - if (other.deploymentSlot != null) - return false; - } else if (!deploymentSlot.equals(other.deploymentSlot)) - return false; - if (dns == null) { - if (other.dns != null) - return false; - } else if (!dns.equals(other.dns)) - return false; - if (label == null) { - if (other.label != null) - return false; - } else if (!label.equals(other.label)) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (roleList == null) { - if (other.roleList != null) - return false; - } else if (!roleList.equals(other.roleList)) - return false; - if (virtualNetworkName == null) { - if (other.virtualNetworkName != null) - return false; - } else if (!virtualNetworkName.equals(other.virtualNetworkName)) - return false; - return true; - } - - @Override - public String toString() { - return "Deployment [name=" + name + ", deploymentSlot=" + deploymentSlot + ", label=" + label + ", roleList=" - + roleList + ", virtualNetworkName=" + virtualNetworkName + ", dns=" + dns + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/HostCaching.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/HostCaching.java deleted file mode 100644 index df78bc6..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/HostCaching.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlType; - -@XmlType(name = "HostCaching") -@XmlEnum -public enum HostCaching { - @XmlEnumValue("ReadOnly") - ReadOnly, @XmlEnumValue("ReadWrite") - ReadWrite; -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/OSVirtualHardDisk.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/OSVirtualHardDisk.java deleted file mode 100644 index 91e03cc..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/OSVirtualHardDisk.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Contains the parameters Windows Azure uses to create the operating system - * disk for the virtual machine. - */ -@XmlRootElement(name = "OSVirtualHardDisk") -public class OSVirtualHardDisk extends VirtualHardDisk { - - /** - * Specifies the name of the disk image to use to create the virtual - * machine. - */ - @XmlElement(name = "SourceImageName") - private String sourceImageName; - - @XmlElement(name = "OS") - private String os; - - public OSVirtualHardDisk() { - - } - - public String getSourceImageName() { - return sourceImageName; - } - - public void setSourceImageName(String sourceImageName) { - this.sourceImageName = sourceImageName; - } - - public void setOs(String os) { - this.os = os; - } - - public String getOs() { - return os; - } - - @Override - public String toString() { - return "OSVirtualHardDisk [hostCaching=" + hostCaching + ", diskLabel=" - + diskLabel + ", diskName=" + diskName + ", mediaLink=" - + mediaLink + ", sourceImageName=" + sourceImageName + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/PersistentVMRole.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/PersistentVMRole.java deleted file mode 100644 index 4198831..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/PersistentVMRole.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "PersistentVMRole") -public class PersistentVMRole extends AbstractRole { - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Protocol.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Protocol.java deleted file mode 100644 index 92c01ed..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Protocol.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlType; - -@XmlType(name = "Protocol") -@XmlEnum -public enum Protocol { - @XmlEnumValue("tcp") - TCP, @XmlEnumValue("http") - HTTP, @XmlEnumValue("udp") - UDP; - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Role.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Role.java deleted file mode 100644 index 4de282e..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/Role.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "Role") -public class Role extends AbstractRole { - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/RoleSize.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/RoleSize.java deleted file mode 100644 index bcdac6e..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/RoleSize.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlEnum; -import javax.xml.bind.annotation.XmlEnumValue; -import javax.xml.bind.annotation.XmlType; - -@XmlType(name = "RoleSize") -@XmlEnum -public enum RoleSize { - @XmlEnumValue("ExtraSmall") - ExtraSmall, - @XmlEnumValue("Small") - Small, - @XmlEnumValue("Medium") - Medium, - @XmlEnumValue("Large") - Large, - @XmlEnumValue("ExtraLarge") - ExtraLarge; -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/VirtualHardDisk.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/VirtualHardDisk.java deleted file mode 100644 index 51f018b..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/VirtualHardDisk.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlElement; - -public class VirtualHardDisk { - - /** - * Specifies whether the OS disk can be cached for greater efficiency during writes. This setting - * impacts the consistency and performance of the OS disk. The default value is ReadWrite. - */ - @XmlElement(name = "HostCaching") - protected HostCaching hostCaching; - /** - * Specifies the friendly name of the disk containing the guest OS image in the image repository. - */ - @XmlElement(name = "DiskLabel") - protected String diskLabel; - /** - * Specifies the name of an operating system image in the image repository. - */ - @XmlElement(name = "DiskName") - protected String diskName; - /** - * Specifies the URI for a blob in a Windows Azure storage account that contains the OS image to - * use to create the OS disk. - */ - @XmlElement(name = "MediaLink") - protected String mediaLink; - - public VirtualHardDisk() { - - } - - public HostCaching getHostCaching() { - return hostCaching; - } - - public void setHostCaching(HostCaching hostCaching) { - this.hostCaching = hostCaching; - } - - public String getDiskLabel() { - return diskLabel; - } - - public void setDiskLabel(String diskLabel) { - this.diskLabel = diskLabel; - } - - public String getDiskName() { - return diskName; - } - - public void setDiskName(String diskName) { - this.diskName = diskName; - } - - public String getMediaLink() { - return mediaLink; - } - - public void setMediaLink(String mediaLink) { - this.mediaLink = mediaLink; - } - - @Override - public String toString() { - return "VirtualHardDisk [hostCaching=" + hostCaching + ", diskLabel=" + diskLabel + ", diskName=" + diskName - + ", mediaLink=" + mediaLink + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/CertificateSetting.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/CertificateSetting.java deleted file mode 100644 index 2ef1cf3..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/CertificateSetting.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "CertificateSetting") -public class CertificateSetting { - - /** - * Specifies the name of the certificate store from which retrieve certificate. - */ - @XmlElement(required = true, name = "StoreLocation") - private String StoreLocation; - /** - * Specifies the target certificate store location on the virtual machine. - * - * The only supported value is LocalMachine. - */ - @XmlElement(required = true, name = "StoreName") - private String StoreName; - /** - * Specifies the thumbprint of the certificate to be provisioned. The thumbprint must specify an - * existing service certificate. - */ - @XmlElement(required = true, name = "Thumbprint") - private String Thumbprint; - - public CertificateSetting() { - super(); - } - - public String getStoreLocation() { - return StoreLocation; - } - - public void setStoreLocation(String storeLocation) { - StoreLocation = storeLocation; - } - - public String getStoreName() { - return StoreName; - } - - public void setStoreName(String storeName) { - StoreName = storeName; - } - - public String getThumbprint() { - return Thumbprint; - } - - public void setThumbprint(String thumbprint) { - Thumbprint = thumbprint; - } - - @Override - public String toString() { - return "CertificateSetting [StoreLocation=" + StoreLocation + ", StoreName=" + StoreName + ", Thumbprint=" - + Thumbprint + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/ConfigurationSet.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/ConfigurationSet.java deleted file mode 100644 index 4185b1d..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/ConfigurationSet.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - -@XmlJavaTypeAdapter(ConfigurationSetAdapter.class) -public abstract class ConfigurationSet { - - /** - * Specifies the configuration set type. - */ - @XmlElement(required = true, name = "ConfigurationSetType") - protected String configurationSetType; - - public ConfigurationSet() { - } - - public String getConfigurationSetType() { - return configurationSetType; - } - - public void setConfigurationSetType(String configurationSetType) { - this.configurationSetType = configurationSetType; - } - - @Override - public String toString() { - return "ConfigurationSet [configurationSetType=" + configurationSetType + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/ConfigurationSetAdapter.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/ConfigurationSetAdapter.java deleted file mode 100644 index 19abcf8..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/ConfigurationSetAdapter.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role.conf; - -import java.util.List; -import java.util.TimeZone; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.adapters.XmlAdapter; - -import com.google.common.collect.Lists; - -public class ConfigurationSetAdapter extends - XmlAdapter { - - @Override - public ConfigurationSet unmarshal(AdaptedConfigurationSet adapted) throws Exception { - - final String type = adapted.configurationSetType; - if (NetworkConfiguration.ID.equals(type)) { - NetworkConfiguration network = new NetworkConfiguration(); - network.setConfigurationSetType(NetworkConfiguration.ID); - network.setInputEndpoints(adapted.inputEndpoints); - network.setSubnetNames(adapted.subnetNames); - return network; - } else if (LinuxProvisioningConfiguration.ID.equals(type)) { - LinuxProvisioningConfiguration linux = new LinuxProvisioningConfiguration(); - linux.setConfigurationSetType(LinuxProvisioningConfiguration.ID); - linux.setDisableSshPasswordAuthentication(adapted.disableSshPasswordAuthentication); - linux.setHostName(adapted.hostName); - linux.setSsh(adapted.ssh); - linux.setUserName(adapted.userName); - linux.setUserPassword(adapted.userPassword); - return linux; - } else if (WindowsProvisioningConfiguration.ID.equals(type)) { - WindowsProvisioningConfiguration windows = new WindowsProvisioningConfiguration(); - windows.setConfigurationSetType(WindowsProvisioningConfiguration.ID); - windows.setAdminPassword(adapted.adminPassword); - windows.setComputerName(adapted.computerName); - windows.setDomainJoin(adapted.domainJoin); - windows.setEnableAutomaticUpdates(adapted.enableAutomaticUpdates); - windows.setResetPasswordOnFirstLogon(adapted.resetPasswordOnFirstLogon); - windows.setStoredCertificateSettings(adapted.storedCertificateSettings); - windows.setTimeZone(adapted.timeZone); - return windows; - } - - return null; - } - - @Override - public AdaptedConfigurationSet marshal(ConfigurationSet configSet) throws Exception { - if (configSet == null) { - return null; - } - - AdaptedConfigurationSet adapted = new AdaptedConfigurationSet(); - adapted.configurationSetType = configSet.getConfigurationSetType(); - - if (configSet instanceof NetworkConfiguration) { - NetworkConfiguration network = (NetworkConfiguration) configSet; - adapted.inputEndpoints = network.getInputEndpoints(); - adapted.subnetNames = network.getSubnetNames(); - } else if (configSet instanceof LinuxProvisioningConfiguration) { - LinuxProvisioningConfiguration linux = (LinuxProvisioningConfiguration) configSet; - adapted.disableSshPasswordAuthentication = linux.getDisableSshPasswordAuthentication(); - adapted.hostName = linux.getHostName(); - adapted.ssh = linux.getSsh(); - adapted.userName = linux.getUserName(); - adapted.userPassword = linux.getUserPassword(); - } else if (configSet instanceof WindowsProvisioningConfiguration) { - WindowsProvisioningConfiguration windows = (WindowsProvisioningConfiguration) configSet; - adapted.adminPassword = windows.getAdminPassword(); - adapted.computerName = windows.getComputerName(); - adapted.domainJoin = windows.getDomainJoin(); - adapted.enableAutomaticUpdates = windows.getEnableAutomaticUpdates(); - adapted.resetPasswordOnFirstLogon = windows.getResetPasswordOnFirstLogon(); - adapted.storedCertificateSettings = windows.getStoredCertificateSettings(); - adapted.timeZone = windows.getTimeZone(); - } - - return adapted; - } - - public static class AdaptedConfigurationSet { - @XmlElement(required = true, name = "ConfigurationSetType") - public String configurationSetType; - - @XmlElement(required = true, name = "HostName") - public String hostName; - - @XmlElement(required = true, name = "UserName") - public String userName; - - @XmlElement(required = true, name = "UserPassword") - public String userPassword; - - @XmlElement(name = "DisableSshPasswordAuthentication") - public Boolean disableSshPasswordAuthentication; - - @XmlElement(name = "SSH") - public SSH ssh; - - @XmlElement(name = "ComputerName") - public String computerName; - - @XmlElement(required = true, name = "AdminPassword") - public String adminPassword; - - @XmlElement(required = true, name = "ResetPasswordOnFirstLogon") - public Boolean resetPasswordOnFirstLogon; - - @XmlElement(name = "EnableAutomaticUpdates") - public Boolean enableAutomaticUpdates; - - @XmlElement(name = "TimeZone") - public TimeZone timeZone; - - @XmlElement(name = "DomainJoin") - public DomainJoin domainJoin; - - @XmlElementWrapper(required = true, name = "StoredCertificateSettings") - @XmlElement(name = "CertificateSetting") - public List storedCertificateSettings = Lists.newArrayList(); - - @XmlElementWrapper(name = "InputEndpoints") - @XmlElement(name = "InputEndpoint") - public List inputEndpoints = Lists.newArrayListWithCapacity(0); - - @XmlElementWrapper(name = "SubnetNames") - @XmlElement(name = "SubnetName") - public List subnetNames = Lists.newArrayListWithCapacity(0); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/Credentials.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/Credentials.java deleted file mode 100644 index f4784a6..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/Credentials.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "Credentials") -public class Credentials { - - /** - * Specifies the name of the domain used to authenticate an account. The value is a fully - * qualified DNS domain. - */ - @XmlElement(name = "Domain") - private String domain; - /** - * Specifies a user name in the domain that can be used to join the domain. - */ - @XmlElement(required = true, name = "Username") - private String username; - /** - * Specifies the password to use to join the domain. - */ - @XmlElement(name = "Password") - private String password; - - public Credentials() { - super(); - } - - public String getDomain() { - return domain; - } - - public void setDomain(String domain) { - this.domain = domain; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - @Override - public String toString() { - return "Credentials [domain=" + domain + ", username=" + username + ", password=" + password + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/DomainJoin.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/DomainJoin.java deleted file mode 100644 index a04c0b5..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/DomainJoin.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "DomainJoin") -public class DomainJoin { - - /** - * Specifies the domain to join. - */ - @XmlElement(name = "JoinDomain") - private String joinDomain; - /** - * Specifies the Lightweight Directory Access Protocol (LDAP) X 500-distinguished name of the - * organizational unit (OU) in which the computer account is created. This account is in Active - * Directory on a domain controller in the domain to which the computer is being joined. - */ - @XmlElement(name = "MachineObjectOU") - private String machineObjectOU; - /** - * Specifies the Domain, Password, and Username values to use to join the virtual machine to the - * domain. - */ - @XmlElement(name = "Credentials") - private Credentials credentials; - - public DomainJoin() { - super(); - } - - public String getJoinDomain() { - return joinDomain; - } - - public void setJoinDomain(String joinDomain) { - this.joinDomain = joinDomain; - } - - public String getMachineObjectOU() { - return machineObjectOU; - } - - public void setMachineObjectOU(String machineObjectOU) { - this.machineObjectOU = machineObjectOU; - } - - public Credentials getCredentials() { - return credentials; - } - - public void setCredentials(Credentials credentials) { - this.credentials = credentials; - } - - @Override - public String toString() { - return "DomainJoin [joinDomain=" + joinDomain + ", machineObjectOU=" + machineObjectOU + ", credentials=" - + credentials + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/InputEndpoint.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/InputEndpoint.java deleted file mode 100644 index 9d726d4..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/InputEndpoint.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.azure.management.domain.role.Protocol; - -@XmlRootElement(name = "InputEndpoint") -public class InputEndpoint { - - /** - * - */ - @XmlElement(name = "EnableDirectServerReturn") - private Boolean enableDirectServerReturn; - - /** - * Specifies a name for a set of load-balanced endpoints. Specifying this element for a given - * endpoint adds it to the set. - */ - @XmlElement(required = true, name = "LoadBalancedEndpointSetName") - private String loadBalancedEndpointSetName; - - /** - * Specifies the internal port on which the virtual machine is listening to serve the endpoint. - */ - @XmlElement(required = true, name = "LocalPort") - private Integer localPort; - - /** - * Specifies the name for the external endpoint. - */ - @XmlElement(required = true, name = "Name") - private String name; - - /** - * Specifies the external port to use for the endpoint. - */ - @XmlElement(required = true, name = "Port") - private Integer port; - - @XmlElement(name = "LoadBalancerProbe") - private LoadBalancerProbe loadBalancerProbe; - - @XmlElement(name = "Protocol") - private Protocol protocol; - - @XmlElement(name = "Vip") - private String vip; - - public InputEndpoint() { - } - - public Boolean getEnableDirectServerReturn() { - return enableDirectServerReturn; - } - - public void setEnableDirectServerReturn(Boolean enableDirectServerReturn) { - this.enableDirectServerReturn = enableDirectServerReturn; - } - - public String getLoadBalancedEndpointSetName() { - return loadBalancedEndpointSetName; - } - - public void setLoadBalancedEndpointSetName(String loadBalancedEndpointSetName) { - this.loadBalancedEndpointSetName = loadBalancedEndpointSetName; - } - - public Integer getLocalPort() { - return localPort; - } - - public void setLocalPort(Integer localPort) { - this.localPort = localPort; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getPort() { - return port; - } - - public void setPort(Integer port) { - this.port = port; - } - - public LoadBalancerProbe getLoadBalancerProbe() { - return loadBalancerProbe; - } - - public void setLoadBalancerProbe(LoadBalancerProbe loadBalancerProbe) { - this.loadBalancerProbe = loadBalancerProbe; - } - - public Protocol getProtocol() { - return protocol; - } - - public void setProtocol(Protocol protocol) { - this.protocol = protocol; - } - - public String getVip() { - return vip; - } - - public void setVip(String vip) { - this.vip = vip; - } - - @Override - public String toString() { - return "InputEndpoint [enableDirectServerReturn=" + enableDirectServerReturn + ", loadBalancedEndpointSetName=" - + loadBalancedEndpointSetName + ", localPort=" + localPort + ", name=" + name + ", port=" + port - + ", loadBalancerProbe=" + loadBalancerProbe + ", protocol=" + protocol + ", vip=" + vip + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/KeyPair.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/KeyPair.java deleted file mode 100644 index 8ba3714..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/KeyPair.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "KeyPair") -public class KeyPair extends SSHKey { - - public KeyPair() { - } - - @Override - public String toString() { - return "KeyPair [fingerPrint=" + fingerPrint + ", path=" + path + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/LinuxProvisioningConfiguration.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/LinuxProvisioningConfiguration.java deleted file mode 100644 index 10c47c0..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/LinuxProvisioningConfiguration.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role.conf; - - -public class LinuxProvisioningConfiguration extends ConfigurationSet { - - public static final String ID = "LinuxProvisioningConfiguration"; - - /** - * Specifies the host name for the VM. Host names are ASCII character strings 1 to 64 characters - * in length. - */ - // @XmlElement(required = true,name = "HostName") - private String hostName; - /** - * Specifies the name of a user to be created in the sudoer group of the virtual machine. User - * names are ASCII character strings 1 to 32 characters in length. - */ - // @XmlElement(required = true,name = "UserName") - private String userName; - /** - * Specifies the associated password for the user name. PasswoazureManagement are ASCII character - * strings 6 to 72 characters in length. - */ - // @XmlElement(required = true,name = "UserPassword") - private String userPassword; - /** - * Specifies whether or not SSH password authentication is disabled. By default this value is set - * to true. - */ - // @XmlElement(name = "DisableSshPasswordAuthentication") - private Boolean disableSshPasswordAuthentication; - /** - * Specifies the SSH public keys and key pairs to populate in the image during provisioning. - */ - // @XmlElement(name = "SSH") - private SSH ssh; - - public LinuxProvisioningConfiguration() { - - } - - public String getHostName() { - return hostName; - } - - public void setHostName(String hostName) { - this.hostName = hostName; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getUserPassword() { - return userPassword; - } - - public void setUserPassword(String userPassword) { - this.userPassword = userPassword; - } - - public Boolean getDisableSshPasswordAuthentication() { - return disableSshPasswordAuthentication; - } - - public void setDisableSshPasswordAuthentication(Boolean disableSshPasswordAuthentication) { - this.disableSshPasswordAuthentication = disableSshPasswordAuthentication; - } - - public SSH getSsh() { - return ssh; - } - - public void setSsh(SSH ssh) { - this.ssh = ssh; - } - - @Override - public String toString() { - return "LinuxProvisioningConfigurationSet [hostName=" + hostName + ", userName=" + userName + ", userPassword=" - + userPassword + ", disableSshPasswordAuthentication=" + disableSshPasswordAuthentication + ", ssh=" - + ssh + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/LoadBalancerProbe.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/LoadBalancerProbe.java deleted file mode 100644 index b113bfb..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/LoadBalancerProbe.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import org.jclouds.azure.management.domain.role.Protocol; - -/** - * Contains properties that specify the endpoint settings which the Windows Azure load balancer uses - * to monitor the availability of this virtual machine before forwarding traffic to the endpoint. - */ -@XmlRootElement(name = "LoadBalancerProbe") -public class LoadBalancerProbe { - - /** - * Specifies the relative path name to inspect to determine the virtual machine availability - * status. If Protocol is set to TCP, this value must be NULL. - */ - @XmlElement(name = "Path") - private String path; - /** - * Specifies the port to use to inspect the virtual machine availability status. - */ - @XmlElement(name = "Port") - private Integer port; - /** - * Specifies the protocol to use to inspect the virtual machine availability status. - */ - @XmlElement(name = "Protocol") - private Protocol protocol; - - public LoadBalancerProbe() { - super(); - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public Integer getPort() { - return port; - } - - public void setPort(Integer port) { - this.port = port; - } - - public Protocol getProtocol() { - return protocol; - } - - public void setProtocol(Protocol protocol) { - this.protocol = protocol; - } - - @Override - public String toString() { - return "LoadBalancerProbe [path=" + path + ", port=" + port + ", protocol=" + protocol + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/NetworkConfiguration.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/NetworkConfiguration.java deleted file mode 100644 index d84548b..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/NetworkConfiguration.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role.conf; - -import java.util.List; - -import com.google.common.collect.Lists; - -//@XmlRootElement(name = "ConfigurationSet") -public class NetworkConfiguration extends ConfigurationSet { - - public static final String ID = "NetworkConfiguration"; - - /** - * Contains a collection of external endpoints for the virtual machine. - */ - // @XmlElementWrapper(name = "InputEndpoints") - // @XmlElement(name = "InputEndpoint") - private List inputEndpoints = Lists.newArrayListWithCapacity(0); - - /** - * Specifies the name of a subnet to which the virtual machine belongs. - */ - // @XmlElementWrapper(name = "SubnetNames") - // @XmlElement(name = "SubnetName") - private List subnetNames = Lists.newArrayListWithCapacity(0); - - public NetworkConfiguration() { - setConfigurationSetType(ID); - } - - public List getInputEndpoints() { - return inputEndpoints; - } - - public void setInputEndpoints(List inputEndpoints) { - this.inputEndpoints = inputEndpoints; - } - - public List getSubnetNames() { - return subnetNames; - } - - public void setSubnetNames(List subnetNames) { - this.subnetNames = subnetNames; - } - - @Override - public String toString() { - return "NetworkConfigurationSet [configurationSetType=" + configurationSetType + ", InputEndpoints=" - + inputEndpoints + ", SubnetNames=" + subnetNames + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/PublicKey.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/PublicKey.java deleted file mode 100644 index 7576e7a..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/PublicKey.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "PublicKey") -public class PublicKey extends SSHKey { - - public PublicKey() { - } - - @Override - public String toString() { - return "PublicKey [fingerPrint=" + fingerPrint + ", path=" + path + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/SSH.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/SSH.java deleted file mode 100644 index b7d9990..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/SSH.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role.conf; - -import java.util.List; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -import com.google.common.collect.Lists; - -@XmlRootElement(name = "SSH") -public class SSH { - - /** - * Specifies the collection of SSH public keys. - */ - @XmlElementWrapper(name = "PublicKeys") - @XmlElement(name = "PublicKey") - private List publicKeys = Lists.newArrayListWithCapacity(0); - - /** - * Specifies the public key. - */ - @XmlElementWrapper(name = "KeyPairs") - @XmlElement(name = "KeyPair") - private List keyPairs = Lists.newArrayListWithCapacity(0); - - public SSH() { - } - - public List getPublicKeys() { - return publicKeys; - } - - public void setPublicKeys(List publicKeys) { - this.publicKeys = publicKeys; - } - - public List getKeyPairs() { - return keyPairs; - } - - public void setKeyPairs(List keyPairs) { - this.keyPairs = keyPairs; - } - - @Override - public String toString() { - return "SSH [publicKeys=" + publicKeys + ", keyPairs=" + keyPairs + "]"; - } -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/SSHKey.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/SSHKey.java deleted file mode 100644 index bf85b86..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/SSHKey.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlElement; - -public class SSHKey { - - /** - * Specifies the SHA1 fingerprint of an X509 certificate associated with the hosted service that - * includes the SSH public key. - */ - @XmlElement(required = true, name = "FingerPrint") - protected String fingerPrint; - - /** - * Specifies the full path of a file, on the virtual machine, which stores the SSH public key. If - * the file already exists, the specified key is appended to the file. - */ - @XmlElement(required = true, name = "Path") - protected String path; - - public SSHKey() { - } - - public String getFingerPrint() { - return fingerPrint; - } - - public void setFingerPrint(String fingerPrint) { - this.fingerPrint = fingerPrint; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/WindowsProvisioningConfiguration.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/WindowsProvisioningConfiguration.java deleted file mode 100644 index c7a0cb1..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/WindowsProvisioningConfiguration.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.domain.role.conf; - -import java.util.List; -import java.util.TimeZone; - -import com.google.common.collect.Lists; - -//@XmlRootElement(name = "ConfigurationSet") -public class WindowsProvisioningConfiguration extends ConfigurationSet { - - public static final String ID = "WindowsProvisioningConfiguration"; - - /** - * Specifies the computer name for the virtual machine - * - * Computer names must be 1 to 15 characters in length. - */ - // @XmlElement(name = "ComputerName") - private String computerName; - /** - * Specifies the base-64 encoded string representing the administrator password to use for the - * virtual machine. - */ - // @XmlElement(required = true, name = "AdminPassword") - private String adminPassword; - /** - * Specifies whether the user must change the administrator password on first logon. The default - * value is false. - */ - // @XmlElement(required = true, name = "ResetPasswordOnFirstLogon") - private Boolean resetPasswordOnFirstLogon; - /** - * Specifies whether automatic updates are enabled for the virtual machine. The default value is - * true. - */ - // @XmlElement(name = "EnableAutomaticUpdates") - private Boolean enableAutomaticUpdates; - /** - * Specifies the time zone for the virtual machine. - */ - // @XmlElement(name = "TimeZone") - private TimeZone timeZone; - /** - * Contains properties that specify a domain to which the virtual machine will be joined. The - * DomainJoin node contains either credentials or provisioning information. - */ - // @XmlElement(name = "DomainJoin") - private DomainJoin domainJoin; - /** - * Contains a list of service certificates with which to provision to the new virtual machine. - */ - // @XmlElementWrapper(required = true, name = "StoredCertificateSettings") - // @XmlElement(name = "CertificateSetting") - private List storedCertificateSettings = Lists.newArrayList(); - - public WindowsProvisioningConfiguration() { - - } - - public String getComputerName() { - return computerName; - } - - public void setComputerName(String computerName) { - this.computerName = computerName; - } - - public String getAdminPassword() { - return adminPassword; - } - - public void setAdminPassword(String adminPassword) { - this.adminPassword = adminPassword; - } - - public Boolean getResetPasswordOnFirstLogon() { - return resetPasswordOnFirstLogon; - } - - public void setResetPasswordOnFirstLogon(Boolean resetPasswordOnFirstLogon) { - this.resetPasswordOnFirstLogon = resetPasswordOnFirstLogon; - } - - public Boolean getEnableAutomaticUpdates() { - return enableAutomaticUpdates; - } - - public void setEnableAutomaticUpdates(Boolean enableAutomaticUpdates) { - this.enableAutomaticUpdates = enableAutomaticUpdates; - } - - public TimeZone getTimeZone() { - return timeZone; - } - - public void setTimeZone(TimeZone timeZone) { - this.timeZone = timeZone; - } - - public DomainJoin getDomainJoin() { - return domainJoin; - } - - public void setDomainJoin(DomainJoin domainJoin) { - this.domainJoin = domainJoin; - } - - public List getStoredCertificateSettings() { - return storedCertificateSettings; - } - - public void setStoredCertificateSettings(List storedCertificateSettings) { - this.storedCertificateSettings = storedCertificateSettings; - } - - @Override - public String toString() { - return "WindowsProvisioningConfigurationSet [computerName=" + computerName + ", adminPassword=" + adminPassword - + ", resetPasswordOnFirstLogon=" + resetPasswordOnFirstLogon + ", enableAutomaticUpdates=" - + enableAutomaticUpdates + ", timeZone=" + timeZone + ", domainJoin=" + domainJoin - + ", storedCertificateSettings=" + storedCertificateSettings + "]"; - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/package-info.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/package-info.java deleted file mode 100644 index 4f7b323..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/conf/package-info.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -@XmlSchema(namespace = "http://schemas.microsoft.com/windowsazure", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -@XmlAccessorType(XmlAccessType.FIELD) -//@XmlJavaTypeAdapters({@XmlJavaTypeAdapter(NetworkConfigurationSetAdapter.class),@XmlJavaTypeAdapter(LinuxProvisioningConfigurationSetAdapter.class)}) -package org.jclouds.azure.management.domain.role.conf; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlSchema; - diff --git a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/package-info.java b/azure-management/src/main/java/org/jclouds/azure/management/domain/role/package-info.java deleted file mode 100644 index 3d9ed50..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/domain/role/package-info.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -@XmlSchema(namespace = "http://schemas.microsoft.com/windowsazure", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) -@XmlAccessorType(XmlAccessType.FIELD) -//@XmlJavaTypeAdapters({@XmlJavaTypeAdapter(NetworkConfigurationSetAdapter.class),@XmlJavaTypeAdapter(LinuxProvisioningConfigurationSetAdapter.class)}) -package org.jclouds.azure.management.domain.role; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlSchema; - diff --git a/azure-management/src/main/java/org/jclouds/azure/management/features/DiskApi.java b/azure-management/src/main/java/org/jclouds/azure/management/features/DiskApi.java deleted file mode 100644 index 68f91c5..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/features/DiskApi.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; -import org.jclouds.azure.management.domain.Disk; - -/** - * The Service Management API includes operations for managing the disks in your subscription. - * - * @see docs - * @see DiskAsyncApi - */ -public interface DiskApi { - - /** - * The List Disks operation retrieves a list of the disks in your image repository. - */ - Set list(); - - /** - * The Delete Disk operation deletes the specified data or operating system disk from your image - * repository. - * - * @return request id or null, if not found - * - */ - String delete(String diskName); -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/features/DiskAsyncApi.java b/azure-management/src/main/java/org/jclouds/azure/management/features/DiskAsyncApi.java deleted file mode 100644 index 2c32b5e..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/features/DiskAsyncApi.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azure.management.domain.Disk; -import org.jclouds.azure.management.functions.ParseRequestIdHeader; -import org.jclouds.azure.management.xml.ListDisksHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * The Service Management API includes operations for managing the virtual machines Disk in your - * subscription. - * - * @see docs - * @see DiskApi - */ -@Headers(keys = "x-ms-version", values = "2012-03-01") -public interface DiskAsyncApi { - - /** - * @see DiskApi#list() - */ - @Named("ListDisks") - @GET - @Path("/services/disks") - @XMLResponseParser(ListDisksHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture> list(); - - /** - * @see DiskApi#delete - */ - @Named("DeleteDisk") - @DELETE - @Path("/services/disks/{diskName}") - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - ListenableFuture delete(@PathParam("diskName") String imageName); -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceApi.java b/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceApi.java deleted file mode 100644 index 25dad7e..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceApi.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; -import org.jclouds.azure.management.domain.Deployment; -import org.jclouds.azure.management.domain.HostedService; -import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties; -import org.jclouds.azure.management.options.CreateHostedServiceOptions; - -/** - * The Service Management API includes operations for managing the hosted services beneath your - * subscription. - * - * @see docs - * @see HostedServiceAsyncApi - */ -public interface HostedServiceApi { - - /** - * The List Hosted Services operation lists the hosted services available under the current - * subscription. - * - * @return the response object - */ - Set list(); - - /** - * The Create Hosted Service operation creates a new hosted service in Windows Azure. - * - * @param serviceName - * A name for the hosted service that is unique within Windows Azure. This name is the - * DNS prefix name and can be used to access the hosted service. - * - * For example: http://ServiceName.cloudapp.net// - * @param label - * The name can be used identify the storage account for your tracking purposes. The - * name can be up to 100 characters in length. - * @param location - * The location where the hosted service will be created. - * @return the requestId to track this async request progress - * - * @see docs - */ - String createServiceWithLabelInLocation(String serviceName, String label, String location); - - /** - * same as {@link #createServiceWithLabelInLocation(String, String, String)} , except you can - * specify optional parameters such as extended properties or a description. - * - * @param options - * parameters such as extended properties or a description. - */ - String createServiceWithLabelInLocation(String serviceName, String label, String location, - CreateHostedServiceOptions options); - - /** - * The Get Hosted Service Properties operation retrieves system properties for the specified - * hosted service. These properties include the service name and service type; the name of the - * affinity group to which the service belongs, or its location if it is not part of an affinity - * group. - * - * @param serviceName - * the unique DNS Prefix value in the Windows Azure Management Portal - */ - HostedService get(String serviceName); - - /** - * like {@link #get(String)}, except additional data such as status and deployment information is - * returned. - * - * @param serviceName - * the unique DNS Prefix value in the Windows Azure Management Portal - */ - HostedServiceWithDetailedProperties getDetails(String serviceName); - - /** - * The Delete Hosted Service operation deletes the specified hosted service from Windows Azure. - * - * @param serviceName - * the unique DNS Prefix value in the Windows Azure Management Portal - * - * @return request id or null, if not found - */ - String delete(String serviceName); - - /** - * http://msdn.microsoft.com/en-us/library/ee460813 - * - * @param serviceName - * the unique DNS Prefix value in the Windows Azure Management Portal - * @param deploymentSlotName - * "staging" or "production", depending on where you wish to deploy your service - * package - * @param createDeployment - * the deployment to create - */ - // This is a PaaS REST service ! -// void createDeployment(String serviceName, String deploymentSlotName, CreateDeployment createDeployment); - - /** - * The Delete Deployment operation deletes the specified deployment from Windows Azure. - * - * @param serviceName - * the unique DNS Prefix value in the Windows Azure Management Portal - * @param deploymentName - * the unique DNS Prefix value in the Windows Azure Management Portal - */ - String deleteDeployment(String serviceName, String deploymentName); - - - /** - * The Get Deployment operation returns the specified deployment from Windows Azure. - * - * @param serviceName - * the unique DNS Prefix value in the Windows Azure Management Portal - * @param deploymentName - * the unique DNS Prefix value in the Windows Azure Management Portal - */ - Deployment getDeployment(String serviceName, String deploymentName); - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceAsyncApi.java b/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceAsyncApi.java deleted file mode 100644 index 699b6dc..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceAsyncApi.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.azure.management.binders.BindCreateHostedServiceToXmlPayload; -import org.jclouds.azure.management.domain.Deployment; -import org.jclouds.azure.management.domain.HostedService; -import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties; -import org.jclouds.azure.management.functions.ParseRequestIdHeader; -import org.jclouds.azure.management.options.CreateHostedServiceOptions; -import org.jclouds.azure.management.xml.DeploymentHandler; -import org.jclouds.azure.management.xml.HostedServiceHandler; -import org.jclouds.azure.management.xml.HostedServiceWithDetailedPropertiesHandler; -import org.jclouds.azure.management.xml.ListHostedServicesHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * The Service Management API includes operations for managing the hosted services beneath your - * subscription. - * - * @see docs - * @see HostedServiceApi - */ -@Headers(keys = "x-ms-version", values = "2012-03-01") -public interface HostedServiceAsyncApi { - - /** - * @see HostedServiceApi#list() - */ - @Named("ListHostedServices") - @GET - @Path("/services/hostedservices") - @XMLResponseParser(ListHostedServicesHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture> list(); - - /** - * @see HostedServiceApi#createServiceWithLabelInLocation(String, String, String) - */ - @Named("CreateHostedService") - @POST - @Path("/services/hostedservices") - @MapBinder(BindCreateHostedServiceToXmlPayload.class) - @Produces(MediaType.APPLICATION_XML) - @ResponseParser(ParseRequestIdHeader.class) - ListenableFuture createServiceWithLabelInLocation(@PayloadParam("serviceName") String serviceName, - @PayloadParam("label") String label, @PayloadParam("location") String location); - - /** - * @see HostedServiceApi#createServiceWithLabelInLocation(String, String, String, - * CreateHostedServiceOptions) - */ - @Named("CreateHostedService") - @POST - @Path("/services/hostedservices") - @MapBinder(BindCreateHostedServiceToXmlPayload.class) - @Produces(MediaType.APPLICATION_XML) - @ResponseParser(ParseRequestIdHeader.class) - ListenableFuture createServiceWithLabelInLocation(@PayloadParam("serviceName") String serviceName, - @PayloadParam("label") String label, @PayloadParam("location") String location, - @PayloadParam("options") CreateHostedServiceOptions options); - - /** - * @see HostedServiceApi#get(String) - */ - @Named("GetHostedServiceProperties") - @GET - @Path("/services/hostedservices/{serviceName}") - @XMLResponseParser(HostedServiceHandler.class) - @Fallback(NullOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture get(@PathParam("serviceName") String serviceName); - - /** - * @see HostedServiceApi#getDetails(String) - */ - @Named("GetHostedServiceProperties") - @GET - @Path("/services/hostedservices/{serviceName}") - @QueryParams(keys = "embed-detail", values = "true") - @XMLResponseParser(HostedServiceWithDetailedPropertiesHandler.class) - @Fallback(NullOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture getDetails(@PathParam("serviceName") String serviceName); - - /** - * @see HostedServiceApi#delete(String) - */ - @Named("DeleteHostedService") - @DELETE - @Path("/services/hostedservices/{serviceName}") - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - ListenableFuture delete(@PathParam("serviceName") String serviceName); - - /** - * @see HostedServiceApi#deleteDeployment(String, String) - */ - @Named("DeleteDeployment") - @DELETE - @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}") - @Fallback(VoidOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - ListenableFuture deleteDeployment(@PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName); - - /** - * @see HostedServiceApi#get(String,String) - */ - @Named("GetDeployment") - @GET - @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}") - @XMLResponseParser(DeploymentHandler.class) - @Fallback(VoidOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture getDeployment(@PathParam("serviceName") String serviceName, @PathParam("deploymentName") String deploymentName); -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/features/LocationApi.java b/azure-management/src/main/java/org/jclouds/azure/management/features/LocationApi.java deleted file mode 100644 index 8c73f03..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/features/LocationApi.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; -import org.jclouds.azure.management.domain.Location; - -/** - * The Service Management API includes operations for listing the available data center locations - * for a hosted service in your subscription. - *

- * - * @see - * @see LocationAsyncApi - */ -public interface LocationApi { - - /** - * The List Locations operation lists all of the data center locations that are valid for your - * subscription. - * - * @return the response object - */ - Set list(); - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/features/LocationAsyncApi.java b/azure-management/src/main/java/org/jclouds/azure/management/features/LocationAsyncApi.java deleted file mode 100644 index fcc1749..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/features/LocationAsyncApi.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.azure.management.domain.Location; -import org.jclouds.azure.management.xml.ListLocationsHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * The Service Management API includes operations for listing the available data center locations - * for a hosted service in your subscription. - *

- * - * @see - * @see LocationApi - */ -@Headers(keys = "x-ms-version", values = "2012-03-01") -public interface LocationAsyncApi { - - /** - * @see LocationApi#list() - */ - @Named("ListLocations") - @GET - @Path("/locations") - @XMLResponseParser(ListLocationsHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture> list(); - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageApi.java b/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageApi.java deleted file mode 100644 index dc02e4f..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageApi.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.OSImageParams; - -/** - * The Service Management API includes operations for managing the OS images in your subscription. - * - * @see docs - * @see OSImageAsyncApi - */ -public interface OSImageApi { - - /** - * The List Hosted Services operation lists the hosted services available under the current - * subscription. - * - * @return the response object - */ - Set list(); - - /** - * The Add OS Image operation adds an OS image that is currently stored in a storage account in your subscription to the image repository. - * - * @param params - * the required parameters needed to add an image - */ - void add(OSImageParams params); - - /** - * The Update OS Image operation updates an OS image that in your image repository. - * - * @param params - * the required parameters needed to update an image - */ - void update(OSImageParams params); - - /** - * The Delete Hosted Service operation deletes the specified hosted service from Windows Azure. - * - * @param imageName - * the unique DNS Prefix value in the Windows Azure Management Portal - */ - void delete(String imageName); - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageAsyncApi.java b/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageAsyncApi.java deleted file mode 100644 index 23df1d2..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageAsyncApi.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import java.util.Set; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.azure.management.binders.BindOSImageParamsToXmlPayload; -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.OSImageParams; -import org.jclouds.azure.management.functions.OSImageParamsName; -import org.jclouds.azure.management.xml.ListOSImagesHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.ParamParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * The Service Management API includes operations for managing the OS images in your subscription. - * - * @see docs - * @see OSImageApi - */ -@Headers(keys = "x-ms-version", values = "2012-03-01") -public interface OSImageAsyncApi { - - /** - * @see OSImageApi#list() - */ - @Named("ListOsImages") - @GET - @Path("/services/images") - @XMLResponseParser(ListOSImagesHandler.class) - @Fallback(EmptySetOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture> list(); - - /** - * @see OSImageApi#add(String) - */ - @Named("AddOsImage") - @POST - @Path("/services/images") - @Produces(MediaType.APPLICATION_XML) - ListenableFuture add(@BinderParam(BindOSImageParamsToXmlPayload.class) OSImageParams params); - - /** - * @see OSImageApi#update(String) - */ - @Named("UpdateOsImage") - @PUT - @Path("/services/images/{imageName}") - @Produces(MediaType.APPLICATION_XML) - ListenableFuture update( - @PathParam("imageName") @ParamParser(OSImageParamsName.class) @BinderParam(BindOSImageParamsToXmlPayload.class) OSImageParams params); - - /** - * @see OSImageApi#delete(String) - */ - @Named("DeleteOsImage") - @DELETE - @Path("/services/images/{imageName}") - @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("imageName") String imageName); - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/features/OperationApi.java b/azure-management/src/main/java/org/jclouds/azure/management/features/OperationApi.java deleted file mode 100644 index c2655d7..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/features/OperationApi.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import org.jclouds.azure.management.domain.Operation; - -/** - * The Service Management API includes one operation for tracking the progress of asynchronous requests. - * - * @see docs - * @see OperationAsyncApi - */ -public interface OperationApi { - - Operation get(String requestId); - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/features/OperationAsyncApi.java b/azure-management/src/main/java/org/jclouds/azure/management/features/OperationAsyncApi.java deleted file mode 100644 index 06011b2..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/features/OperationAsyncApi.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azure.management.domain.Operation; -import org.jclouds.azure.management.xml.OperationHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.XMLResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * The Service Management API includes one operation for tracking the progress - * of asynchronous requests. - * - * @see docs - * @see OperationApi - */ -@Headers(keys = "x-ms-version", values = "2012-03-01") -public interface OperationAsyncApi { - - /** - * @see OperationApi#get(String) - */ - @Named("GetOperation") - @GET - @Path("/operations/{request-id}") - @XMLResponseParser(OperationHandler.class) - @Fallback(NullOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_XML) - ListenableFuture get(@PathParam("request-id") String requestId); -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/features/RoleApi.java b/azure-management/src/main/java/org/jclouds/azure/management/features/RoleApi.java deleted file mode 100644 index cca3408..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/features/RoleApi.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import org.jclouds.azure.management.domain.DeploymentParams; -import org.jclouds.azure.management.domain.role.PersistentVMRole; - -/** - * The Service Management API includes operations for managing the virtual - * machines in your subscription. - * - * @see docs - * @see RoleAsyncApi - */ -public interface RoleApi { - - // TODO: this is not the good REST call !!! Use getDeployment instead :@ - PersistentVMRole getRole(String serviceName, String deploymentName, String roleName); - - String restartRole(String serviceName, String deploymentName, String roleName); - - /** - * http://msdn.microsoft.com/en-us/library/jj157194 - * - * @param serviceName - * @param deploymentParams - * @return - */ - String createDeployment(String serviceName, DeploymentParams deploymentParams); - - /** - * http://msdn.microsoft.com/en-us/library/jj157201 - * - * @return - */ - String captureRole(String serviceName, String deploymentName, String roleName, String imageName, String imageLabel); - - /** - * http://msdn.microsoft.com/en-us/library/jj157195 - * - * @param serviceName - * @param deploymentName - * @param roleName - * @return - */ - String shutdownRole(String serviceName, String deploymentName, String roleName); - - /** - * http://msdn.microsoft.com/en-us/library/jj157189 - * - * @param serviceName - * @param deploymentName - * @param roleName - * @return - */ - String startRole(String serviceName, String deploymentName, String roleName); - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/features/RoleAsyncApi.java b/azure-management/src/main/java/org/jclouds/azure/management/features/RoleAsyncApi.java deleted file mode 100644 index 2b1ee22..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/features/RoleAsyncApi.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azure.management.binders.BindDeploymentParamsToXmlPayload; -import org.jclouds.azure.management.domain.DeploymentParams; -import org.jclouds.azure.management.domain.role.PersistentVMRole; -import org.jclouds.azure.management.functions.ParseRequestIdHeader; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.ResponseParser; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * The Service Management API includes operations for managing the virtual - * machines in your subscription. - * - * @see docs - * @see RoleApi - */ -@Headers(keys = "x-ms-version", values = "2012-03-01") -public interface RoleAsyncApi { - - /** - * @see RoleApi#getRole(String, String, String) - */ - @Named("GetRole") - @GET - @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roles/{roleName}") - @Consumes(MediaType.APPLICATION_ATOM_XML) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getRole(@PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName); - - /** - * @see RoleApi#restartRole(String, String, String) - */ - @Named("RestartRole") - @POST - // Warning : the url in the documentation is WRONG ! @see - // http://social.msdn.microsoft.com/Forums/pl-PL/WAVirtualMachinesforWindows/thread/7ba2367b-e450-49e0-89e4-46c240e9d213 - @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations") - @Consumes(MediaType.APPLICATION_ATOM_XML) - @Produces(MediaType.APPLICATION_ATOM_XML) - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - @Payload(value = "RestartRoleOperation") - ListenableFuture restartRole(@PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName); - - /** - * @see RoleApi#createDeployment(String, DeploymentParams) - */ - @Named("CreateVirtualMachineDeployment") - @POST - @Path("/services/hostedservices/{serviceName}/deployments") - @Produces(MediaType.APPLICATION_ATOM_XML) - @Consumes(MediaType.APPLICATION_ATOM_XML) - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - ListenableFuture createDeployment(@PathParam("serviceName") String serviceName, - @BinderParam(BindDeploymentParamsToXmlPayload.class) DeploymentParams deploymentParams); - - /** - * @see RoleApi#captureRole(String, String, String, String, String) - */ - @Named("CaptureRole") - @POST - @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations") - @Consumes(MediaType.APPLICATION_ATOM_XML) - @Produces(MediaType.APPLICATION_ATOM_XML) - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - @Payload(value = "CaptureRoleOperationDelete{imageLabel}{imageName}") - ListenableFuture captureRole(@PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName, - @PayloadParam("imageName") String imageName, @PayloadParam("imageLabel") String imageLabel); - - /** - * @see RoleApi#shutdownRole(String, String, String) - */ - @Named("ShutdownRole") - @POST - @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations") - @Consumes(MediaType.APPLICATION_ATOM_XML) - @Produces(MediaType.APPLICATION_ATOM_XML) - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - @Payload(value = "ShutdownRoleOperation") - ListenableFuture shutdownRole(@PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName); - - /** - * @see RoleApi#startRole(String, String, String) - */ - @Named("StartRole") - @POST - @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations") - @Consumes(MediaType.APPLICATION_ATOM_XML) - @Produces(MediaType.APPLICATION_ATOM_XML) - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - @Payload(value = "StartRoleOperation") - ListenableFuture startRole(@PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName); - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/functions/OSImageParamsName.java b/azure-management/src/main/java/org/jclouds/azure/management/functions/OSImageParamsName.java deleted file mode 100644 index 7be216a..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/functions/OSImageParamsName.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.functions; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -import org.jclouds.azure.management.domain.OSImageParams; - -import com.google.common.base.Function; - -@Singleton -public class OSImageParamsName implements Function { - @Override - public String apply(Object input) { - checkArgument(checkNotNull(input, "input") instanceof OSImageParams, - "this function is only valid for OSImageParams!"); - return checkNotNull(OSImageParams.class.cast(input), "OSImageParams").getName(); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/functions/ParseRequestIdHeader.java b/azure-management/src/main/java/org/jclouds/azure/management/functions/ParseRequestIdHeader.java deleted file mode 100644 index fe0b517..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/functions/ParseRequestIdHeader.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.functions; - -import static org.jclouds.http.HttpUtils.releasePayload; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; - -/** - * Parses an x-ms-request-id the header - * - * A value that uniquely identifies a request made against the management service. For an - * asynchronous operation, you can call get operation status with the value of the header to - * determine whether the operation is complete, has failed, or is still in progress. - */ -@Singleton -public class ParseRequestIdHeader implements Function { - - public String apply(HttpResponse from) { - releasePayload(from); - String requestId = from.getFirstHeaderOrNull("x-ms-request-id"); - if (requestId != null) { - return requestId; - } - throw new IllegalStateException("did not receive RequestId in: " + from); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/options/CreateHostedServiceOptions.java b/azure-management/src/main/java/org/jclouds/azure/management/options/CreateHostedServiceOptions.java deleted file mode 100644 index f33308a..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/options/CreateHostedServiceOptions.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.options; - -import java.util.Map; - -import com.google.common.base.MoreObjects; -import com.google.common.base.Objects; -import com.google.common.base.Optional; - -/** - * Optional parameters for creating a hosted service - * - * @see docs - */ -public class CreateHostedServiceOptions implements Cloneable { - - private Optional description = Optional.absent(); - private Optional> extendedProperties = Optional.absent(); - - /** - * @see CreateHostedServiceOptions#getDescription() - */ - public CreateHostedServiceOptions description(String description) { - this.description = Optional.fromNullable(description); - return this; - } - - /** - * @see CreateHostedServiceOptions#getExtendedProperties() - */ - public CreateHostedServiceOptions extendedProperties(Map extendedProperties) { - this.extendedProperties = Optional.fromNullable(extendedProperties); - return this; - } - - /** - * A description for the hosted service. The description can be up to 1024 characters in length. - */ - public Optional getDescription() { - return description; - } - - /** - * Represents the name of an extended hosted service property. Each extended property must have - * both a defined name and value. You can have a maximum of 50 extended property name/value - * pairs. - * - * The maximum length of the Name element is 64 characters, only alphanumeric characters and - * underscores are valid in the Name, and the name must start with a letter. Each extended - * property value has a maximum length of 255 characters. - */ - public Optional> getExtendedProperties() { - return extendedProperties; - } - - public static class Builder { - - /** - * @see CreateHostedServiceOptions#getDescription() - */ - public static CreateHostedServiceOptions description(String description) { - return new CreateHostedServiceOptions().description(description); - } - - /** - * @see CreateHostedServiceOptions#getExtendedProperties() - */ - public static CreateHostedServiceOptions extendedProperties(Map extendedProperties) { - return new CreateHostedServiceOptions().extendedProperties(extendedProperties); - } - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(description, extendedProperties); - } - - @Override - public CreateHostedServiceOptions clone() { - return new CreateHostedServiceOptions().description(description.orNull()).extendedProperties( - extendedProperties.orNull()); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - CreateHostedServiceOptions other = CreateHostedServiceOptions.class.cast(obj); - return Objects.equal(this.description, other.description) - && Objects.equal(this.extendedProperties, other.extendedProperties); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return MoreObjects.toStringHelper("").omitNullValues().add("description", description.orNull()) - .add("extendedProperties", extendedProperties.orNull()).toString(); - } -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/suppliers/KeyStoreSupplier.java b/azure-management/src/main/java/org/jclouds/azure/management/suppliers/KeyStoreSupplier.java deleted file mode 100644 index c72257b..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/suppliers/KeyStoreSupplier.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.suppliers; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Throwables.propagate; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.PrivateKey; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; -import java.util.Collection; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.crypto.Crypto; -import org.jclouds.crypto.Pems; -import org.jclouds.domain.Credentials; -import org.jclouds.io.InputSuppliers; -import org.jclouds.location.Provider; - -import com.google.common.base.Charsets; -import com.google.common.base.Supplier; -import com.google.common.io.ByteSource; - -/** - * TODO this code needs to be completely refactored. It needs to stop using KeyStore of at all possible and definitely - * the local filesystem. Please look at oauth for examples on how to do this via PEMs. - */ -@Deprecated -@Singleton -public class KeyStoreSupplier implements Supplier { - private final Crypto crypto; - private final Supplier creds; - - @Inject - KeyStoreSupplier(Crypto crypto, @Provider Supplier creds) { - this.crypto = crypto; - this.creds = creds; - } - - @Override - public KeyStore get() { - Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); - String cert = checkNotNull(currentCreds.identity, "credential supplier returned null identity (should be cert)"); - String keyStorePassword = checkNotNull(currentCreds.credential, - "credential supplier returned null credential (should be keyStorePassword)"); - try { - KeyStore keyStore = KeyStore.getInstance("PKCS12"); - - File certFile = new File(checkNotNull(cert)); - if (certFile.isFile()) { // cert is path to pkcs12 file - FileInputStream stream = new FileInputStream(certFile); - try { - keyStore.load(stream, keyStorePassword.toCharArray()); - } finally { - stream.close(); - } - } else { // cert is PEM encoded, containing private key and certs - - // split in private key and certs - int privateKeyBeginIdx = cert.indexOf("-----BEGIN PRIVATE KEY"); - int privateKeyEndIdx = cert.indexOf("-----END PRIVATE KEY"); - String pemPrivateKey = cert.substring(privateKeyBeginIdx, privateKeyEndIdx + 26); - - StringBuilder pemCerts = new StringBuilder(); - int certsBeginIdx = 0; - - do { - certsBeginIdx = cert.indexOf("-----BEGIN CERTIFICATE", certsBeginIdx); - - if (certsBeginIdx >= 0) { - int certsEndIdx = cert.indexOf("-----END CERTIFICATE", certsBeginIdx) + 26; - pemCerts.append(cert.substring(certsBeginIdx, certsEndIdx)); - certsBeginIdx = certsEndIdx; - } - } while (certsBeginIdx != -1); - - // parse private key - KeySpec keySpec = Pems.privateKeySpec(ByteSource.wrap(pemPrivateKey.getBytes(Charsets.UTF_8))); - PrivateKey privateKey = crypto.rsaKeyFactory().generatePrivate(keySpec); - - // populate keystore with private key and certs - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - @SuppressWarnings("unchecked") - Collection certs = (Collection) cf.generateCertificates(new ByteArrayInputStream( - pemCerts.toString().getBytes(Charsets.UTF_8))); - keyStore.load(null); - keyStore.setKeyEntry("dummy", privateKey, keyStorePassword.toCharArray(), - certs.toArray(new java.security.cert.Certificate[0])); - - } - return keyStore; - } catch (NoSuchAlgorithmException e) { - throw propagate(e); - } catch (KeyStoreException e) { - throw propagate(e); - } catch (CertificateException e) { - throw propagate(e); - } catch (FileNotFoundException e) { - throw propagate(e); - } catch (IOException e) { - throw propagate(e); - } catch (InvalidKeySpecException e) { - throw propagate(e); - } - } -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/suppliers/SSLContextWithKeysSupplier.java b/azure-management/src/main/java/org/jclouds/azure/management/suppliers/SSLContextWithKeysSupplier.java deleted file mode 100644 index 7392b70..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/suppliers/SSLContextWithKeysSupplier.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.suppliers; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Throwables.propagate; - -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.security.UnrecoverableKeyException; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; - -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpUtils; -import org.jclouds.http.config.SSLModule.TrustAllCerts; -import org.jclouds.location.Provider; - -import com.google.common.base.Supplier; - -/** - * TODO this code needs to be completely refactored. It needs to stop using KeyStore of at all possible and definitely - * the local filesystem. Please look at oauth for examples on how to do this via PEMs. - */ -@Deprecated -@Singleton -public class SSLContextWithKeysSupplier implements Supplier { - private final Supplier keyStore; - private final TrustManager[] trustManager; - private final Supplier creds; - - @Inject - SSLContextWithKeysSupplier(Supplier keyStore, @Provider Supplier creds, HttpUtils utils, - TrustAllCerts trustAllCerts) { - this.keyStore = keyStore; - this.trustManager = utils.trustAllCerts() ? new TrustManager[] { trustAllCerts } : null; - this.creds = creds; - } - - @Override - public SSLContext get() { - Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); - String keyStorePassword = checkNotNull(currentCreds.credential, - "credential supplier returned null credential (should be keyStorePassword)"); - KeyManagerFactory kmf; - try { - kmf = KeyManagerFactory.getInstance("SunX509"); - kmf.init(keyStore.get(), keyStorePassword.toCharArray()); - SSLContext sc = SSLContext.getInstance("TLS"); - sc.init(kmf.getKeyManagers(), trustManager, new SecureRandom()); - return sc; - } catch (NoSuchAlgorithmException e) { - throw propagate(e); - } catch (UnrecoverableKeyException e) { - throw propagate(e); - } catch (KeyStoreException e) { - throw propagate(e); - } catch (KeyManagementException e) { - throw propagate(e); - } - } -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/AttachmentHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/AttachmentHandler.java deleted file mode 100644 index 70699d8..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/AttachmentHandler.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import org.jclouds.azure.management.domain.Disk.Attachment; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.SAXException; - -/** - * @see api - */ -public class AttachmentHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - private StringBuilder currentText = new StringBuilder(); - private Attachment.Builder builder = Attachment.builder(); - - /** - * {@inheritDoc} - */ - @Override - public Attachment getResult() { - try { - return builder.build(); - } finally { - builder = Attachment.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (qName.equals("HostedServiceName")) { - builder.hostedService(SaxUtils.currentOrNull(currentText)); - } else if (qName.equals("DeploymentName")) { - builder.deployment(SaxUtils.currentOrNull(currentText)); - } else if (qName.equals("RoleName")) { - builder.role(SaxUtils.currentOrNull(currentText)); - } - currentText.setLength(0); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/DeploymentHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/DeploymentHandler.java deleted file mode 100644 index 68eaf22..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/DeploymentHandler.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import static com.google.common.base.Charsets.UTF_8; -import static com.google.common.io.BaseEncoding.base64; -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.net.URI; -import java.util.List; - -import org.jclouds.azure.management.domain.Deployment; -import org.jclouds.azure.management.domain.DeploymentSlot; -import org.jclouds.azure.management.domain.DeploymentStatus; -import org.jclouds.azure.management.domain.InstanceStatus; -import org.jclouds.azure.management.domain.RoleSize; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.Lists; - -/** - * @see api - */ -public class DeploymentHandler extends - ParseSax.HandlerForGeneratedRequestWithResult { - - private List elements = Lists.newArrayList(); - protected StringBuilder currentText = new StringBuilder(); - private Deployment.Builder builder = Deployment.builder(); - - /** - * {@inheritDoc} - */ - @Override - public Deployment getResult() { - try { - return builder.build(); - } finally { - builder = Deployment.builder(); - } - } - - - @Override - public void startElement(String uri, String localName, String qName, - Attributes attributes) throws SAXException { - elements.add(qName); - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) - throws SAXException { - if (equalsOrSuffix(qName, "Name") && "Deployment".equals(elements.get(elements.size()-2))) { - builder.deploymentName(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "DeploymentSlot")) { - final String dpltSlot = currentOrNull(currentText); - if (dpltSlot != null) - builder.deploymentSlot(DeploymentSlot.fromValue(dpltSlot)); - } else if (equalsOrSuffix(qName, "Status")) { - String deploymentStatus = currentOrNull(currentText); - if (deploymentStatus != null) - builder.deploymentStatus(DeploymentStatus - .fromValue(deploymentStatus)); - } else if (equalsOrSuffix(qName, "Label")) { - String label = currentOrNull(currentText); - if (label != null) - builder.deploymentLabel(new String(base64().decode(label), UTF_8)); - } else if (equalsOrSuffix(qName, "Url")) { - final String url = currentOrNull(currentText); - if (url != null) - builder.deploymentURL(URI.create(url)); - } else if (equalsOrSuffix(qName, "RoleName")) { - builder.roleName(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "InstanceName")) { - builder.instanceName(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "InstanceStatus")) { - String instanceStatus = currentOrNull(currentText); - if (instanceStatus != null) - builder.instanceStatus(InstanceStatus.fromValue(instanceStatus)); - } else if (equalsOrSuffix(qName, "InstanceStateDetails")) { - builder.instanceStateDetails(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "InstanceErrorCode")) { - builder.instanceErrorCode(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "InstanceSize")) { - String instanceSize = currentOrNull(currentText); - if (instanceSize != null) - builder.instanceSize(RoleSize.fromValue(instanceSize)); - } else if (equalsOrSuffix(qName, "IpAddress")) { - builder.privateIpAddress(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Vip")) { - builder.publicIpAddress(currentOrNull(currentText)); - } - - currentText.setLength(0); - elements.remove(elements.size()-1); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/DetailedHostedServicePropertiesHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/DetailedHostedServicePropertiesHandler.java deleted file mode 100644 index fef02d7..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/DetailedHostedServicePropertiesHandler.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import javax.inject.Inject; - -import org.jclouds.azure.management.domain.DetailedHostedServiceProperties; -import org.jclouds.azure.management.domain.HostedService.Status; -import org.jclouds.date.DateService; -import org.xml.sax.SAXException; - -/** - * @see api - */ -public class DetailedHostedServicePropertiesHandler extends HostedServicePropertiesHandler { - - protected final DateService dateService; - - @Inject - protected DetailedHostedServicePropertiesHandler(DateService dateService) { - this.dateService = dateService; - } - - private DetailedHostedServiceProperties.Builder builder = DetailedHostedServiceProperties.builder(); - - private String name; - - /** - * {@inheritDoc} - */ - @Override - public DetailedHostedServiceProperties getResult() { - try { - return builder.fromHostedServiceProperties(super.getResult()).build(); - } finally { - builder = DetailedHostedServiceProperties.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "DateCreated")) { - builder.created(dateService.iso8601SecondsDateParse(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "DateLastModified")) { - builder.lastModified(dateService.iso8601SecondsDateParse(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "Status")) { - String rawStatus = currentOrNull(currentText); - builder.rawStatus(rawStatus); - builder.status(Status.fromValue(rawStatus)); - } else if (equalsOrSuffix(qName, "Name")) { - this.name = currentOrNull(currentText); - } else if (equalsOrSuffix(qName, "Value")) { - builder.addExtendedProperty(this.name, currentOrNull(currentText)); - this.name = null; - } else { - super.endElement(uri, name, qName); - } - currentText.setLength(0); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/DiskHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/DiskHandler.java deleted file mode 100644 index 0dc7fb8..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/DiskHandler.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.net.URI; - -import javax.inject.Inject; - -import org.jclouds.azure.management.domain.Disk; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -/** - * @see api - */ -public class DiskHandler extends - ParseSax.HandlerForGeneratedRequestWithResult { - - protected final AttachmentHandler attachmentHandler; - - @Inject - protected DiskHandler(AttachmentHandler attachmentHandler) { - this.attachmentHandler = attachmentHandler; - } - - protected StringBuilder currentText = new StringBuilder(); - private Disk.Builder builder = Disk.builder(); - - protected boolean inAttachment; - - /** - * {@inheritDoc} - */ - @Override - public Disk getResult() { - try { - return builder.build(); - } finally { - builder = Disk.builder(); - } - } - - @Override - public void startElement(String uri, String localName, String qName, - Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "AttachedTo")) { - inAttachment = true; - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) - throws SAXException { - if (equalsOrSuffix(qName, "AttachedTo")) { - builder.attachedTo(attachmentHandler.getResult()); - inAttachment = false; - } else if (inAttachment) { - attachmentHandler.endElement(uri, name, qName); - } else if (equalsOrSuffix(qName, "OS")) { - builder.os(OSType.fromValue(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "Name")) { - builder.name(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "LogicalDiskSizeInGB")) { - String gb = currentOrNull(currentText); - if (gb != null) - builder.logicalSizeInGB(Integer.parseInt(gb)); - } else if (equalsOrSuffix(qName, "Description")) { - builder.description(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Location")) { - builder.location(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "AffinityGroup")) { - builder.affinityGroup(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "MediaLink")) { - String link = currentOrNull(currentText); - if (link != null) - builder.mediaLink(URI.create(link)); - } else if (equalsOrSuffix(qName, "SourceImageName")) { - builder.sourceImage(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Label")) { - builder.label(currentOrNull(currentText)); - } - currentText.setLength(0); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inAttachment) { - attachmentHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/ErrorHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/ErrorHandler.java deleted file mode 100644 index 459346b..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/ErrorHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import org.jclouds.azure.management.domain.Error; -import org.jclouds.azure.management.domain.Error.Code; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.SAXException; - -/** - * @see api - */ -public class ErrorHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - private StringBuilder currentText = new StringBuilder(); - private Error.Builder builder = Error.builder(); - - /** - * {@inheritDoc} - */ - @Override - public Error getResult() { - try { - return builder.build(); - } finally { - builder = Error.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (qName.equals("Code")) { - String rawCode = SaxUtils.currentOrNull(currentText); - builder.rawCode(rawCode); - builder.code(Code.fromValue(rawCode)); - } else if (qName.equals("Message")) { - builder.message(SaxUtils.currentOrNull(currentText)); - } - currentText.setLength(0); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceHandler.java deleted file mode 100644 index e5060e2..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceHandler.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.net.URI; - -import javax.inject.Inject; - -import org.jclouds.azure.management.domain.HostedService; -import org.jclouds.azure.management.domain.HostedService.Builder; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -/** - * @see api - */ -public class HostedServiceHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - protected final HostedServicePropertiesHandler hostedServicePropertiesHandler; - - @Inject - protected HostedServiceHandler(HostedServicePropertiesHandler hostedServicePropertiesHandler) { - this.hostedServicePropertiesHandler = hostedServicePropertiesHandler; - } - - protected StringBuilder currentText = new StringBuilder(); - protected HostedService.Builder builder = builder(); - - protected Builder builder() { - return HostedService.builder(); - } - - protected boolean inHostedServiceProperties; - - /** - * {@inheritDoc} - */ - @Override - public HostedService getResult() { - try { - return builder.build(); - } finally { - builder = builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "HostedServiceProperties")) { - inHostedServiceProperties = true; - } - if (inHostedServiceProperties) { - hostedServicePropertiesHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - - if (equalsOrSuffix(qName, "HostedServiceProperties")) { - builder.properties(hostedServicePropertiesHandler.getResult()); - inHostedServiceProperties = false; - } else if (inHostedServiceProperties) { - hostedServicePropertiesHandler.endElement(uri, name, qName); - } else if (equalsOrSuffix(qName, "Url")) { - builder.url(URI.create(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "ServiceName")) { - builder.name(currentOrNull(currentText)); - } - currentText.setLength(0); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inHostedServiceProperties) { - hostedServicePropertiesHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServicePropertiesHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServicePropertiesHandler.java deleted file mode 100644 index 3d7dfb2..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServicePropertiesHandler.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import static com.google.common.base.Charsets.UTF_8; -import static com.google.common.io.BaseEncoding.base64; -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import org.jclouds.azure.management.domain.HostedServiceProperties; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.SAXException; - -/** - * @see api - */ -public class HostedServicePropertiesHandler extends - ParseSax.HandlerForGeneratedRequestWithResult { - - protected StringBuilder currentText = new StringBuilder(); - private HostedServiceProperties.Builder builder = HostedServiceProperties.builder(); - - /** - * {@inheritDoc} - */ - @Override - public HostedServiceProperties getResult() { - try { - return builder.build(); - } finally { - builder = HostedServiceProperties.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "Description")) { - builder.description(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Location")) { - builder.location(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "AffinityGroup")) { - builder.affinityGroup(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Label")) { - builder.label(new String(base64().decode(currentOrNull(currentText)), UTF_8)); - } - currentText.setLength(0); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceWithDetailedPropertiesHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceWithDetailedPropertiesHandler.java deleted file mode 100644 index 73a203e..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/HostedServiceWithDetailedPropertiesHandler.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import javax.inject.Inject; - -import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties; - -public class HostedServiceWithDetailedPropertiesHandler extends HostedServiceHandler { - - @Inject - protected HostedServiceWithDetailedPropertiesHandler( - DetailedHostedServicePropertiesHandler hostedServicePropertiesHandler) { - super(hostedServicePropertiesHandler); - } - - @Override - protected HostedServiceWithDetailedProperties.Builder builder() { - return HostedServiceWithDetailedProperties.builder(); - } - - @Override - public HostedServiceWithDetailedProperties getResult() { - try { - return HostedServiceWithDetailedProperties.class.cast(builder.build()); - } finally { - builder = builder(); - } - } -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListDisksHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/ListDisksHandler.java deleted file mode 100644 index b9e4c09..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListDisksHandler.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import java.util.Set; - -import org.jclouds.azure.management.domain.Disk; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.Inject; - -public class ListDisksHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { - - private final DiskHandler diskHandler; - - private Builder disks = ImmutableSet. builder(); - - private boolean inDisk; - - @Inject - public ListDisksHandler(final DiskHandler diskHandler) { - this.diskHandler = diskHandler; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getResult() { - return disks.build(); - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (SaxUtils.equalsOrSuffix(qName, "Disk")) { - inDisk = true; - } - if (inDisk) { - diskHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (qName.equals("Disk")) { - inDisk = false; - disks.add(diskHandler.getResult()); - } else if (inDisk) { - diskHandler.endElement(uri, name, qName); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inDisk) { - diskHandler.characters(ch, start, length); - } - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListHostedServicesHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/ListHostedServicesHandler.java deleted file mode 100644 index aa2dea6..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListHostedServicesHandler.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import java.util.Set; - -import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.Inject; - -/** - * @see doc - */ -public class ListHostedServicesHandler extends - ParseSax.HandlerForGeneratedRequestWithResult> { - - private final HostedServiceWithDetailedPropertiesHandler hostedServiceHandler; - - private Builder hostedServices = ImmutableSet - . builder(); - - private boolean inHostedService; - - @Inject - public ListHostedServicesHandler(HostedServiceWithDetailedPropertiesHandler hostedServiceHandler) { - this.hostedServiceHandler = hostedServiceHandler; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getResult() { - return hostedServices.build(); - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (SaxUtils.equalsOrSuffix(qName, "HostedService")) { - inHostedService = true; - } - if (inHostedService) { - hostedServiceHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (qName.equals("HostedService")) { - inHostedService = false; - hostedServices.add(hostedServiceHandler.getResult()); - } else if (inHostedService) { - hostedServiceHandler.endElement(uri, name, qName); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inHostedService) { - hostedServiceHandler.characters(ch, start, length); - } - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListLocationsHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/ListLocationsHandler.java deleted file mode 100644 index d29a30f..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListLocationsHandler.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import java.util.Set; - -import org.jclouds.azure.management.domain.Location; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.Inject; - -public class ListLocationsHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { - - private final LocationHandler locationHandler; - - private Builder locations = ImmutableSet. builder(); - - private boolean inLocation; - - @Inject - public ListLocationsHandler(LocationHandler locationHandler) { - this.locationHandler = locationHandler; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getResult() { - return locations.build(); - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (SaxUtils.equalsOrSuffix(qName, "Location")) { - inLocation = true; - } - if (inLocation) { - locationHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (qName.equals("Location")) { - inLocation = false; - locations.add(locationHandler.getResult()); - } else if (inLocation) { - locationHandler.endElement(uri, name, qName); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inLocation) { - locationHandler.characters(ch, start, length); - } - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListOSImagesHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/ListOSImagesHandler.java deleted file mode 100644 index 593a0ed..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/ListOSImagesHandler.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import java.util.Set; - -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.Inject; - -public class ListOSImagesHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { - - private final OSImageHandler locationHandler; - - private Builder locations = ImmutableSet. builder(); - - private boolean inOSImage; - - @Inject - public ListOSImagesHandler(OSImageHandler locationHandler) { - this.locationHandler = locationHandler; - } - - /** - * {@inheritDoc} - */ - @Override - public Set getResult() { - return locations.build(); - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (SaxUtils.equalsOrSuffix(qName, "OSImage")) { - inOSImage = true; - } - if (inOSImage) { - locationHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (qName.equals("OSImage")) { - inOSImage = false; - locations.add(locationHandler.getResult()); - } else if (inOSImage) { - locationHandler.endElement(uri, name, qName); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inOSImage) { - locationHandler.characters(ch, start, length); - } - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/LocationHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/LocationHandler.java deleted file mode 100644 index 6313820..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/LocationHandler.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import org.jclouds.azure.management.domain.Location; -import org.jclouds.http.functions.ParseSax; -import org.jclouds.util.SaxUtils; -import org.xml.sax.SAXException; - -/** - * @see api - */ -public class LocationHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - private StringBuilder currentText = new StringBuilder(); - private Location.Builder builder = Location.builder(); - - /** - * {@inheritDoc} - */ - @Override - public Location getResult() { - try { - return builder.build(); - } finally { - builder = Location.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (qName.equals("Name")) { - builder.name(SaxUtils.currentOrNull(currentText)); - } else if (qName.equals("DisplayName")) { - builder.displayName(SaxUtils.currentOrNull(currentText)); - } else if (qName.equals("AvailableService")) { - builder.addAvailableService(SaxUtils.currentOrNull(currentText)); - } - currentText.setLength(0); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/OSImageHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/OSImageHandler.java deleted file mode 100644 index 22508e8..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/OSImageHandler.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import java.net.URI; - -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.SAXException; - -/** - * @see api - */ -public class OSImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - protected StringBuilder currentText = new StringBuilder(); - private OSImage.Builder builder = OSImage.builder(); - - /** - * {@inheritDoc} - */ - @Override - public OSImage getResult() { - try { - return builder.build(); - } finally { - builder = OSImage.builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "OS")) { - builder.os(OSType.fromValue(currentOrNull(currentText))); - } else if (equalsOrSuffix(qName, "Name")) { - builder.name(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "LogicalSizeInGB")) { - String gb = currentOrNull(currentText); - if (gb != null) - builder.logicalSizeInGB(Integer.parseInt(gb)); - } else if (equalsOrSuffix(qName, "Description")) { - builder.description(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Category")) { - builder.category(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "Location")) { - builder.location(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "AffinityGroup")) { - builder.affinityGroup(currentOrNull(currentText)); - } else if (equalsOrSuffix(qName, "MediaLink")) { - String link = currentOrNull(currentText); - if (link != null) - builder.mediaLink(URI.create(link)); - } else if (equalsOrSuffix(qName, "Eula")) { - String eula = currentOrNull(currentText); - if (eula != null) - builder.eula(URI.create(eula)); - } else if (equalsOrSuffix(qName, "Label")) { - builder.label(currentOrNull(currentText)); - } - currentText.setLength(0); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - currentText.append(ch, start, length); - } - -} diff --git a/azure-management/src/main/java/org/jclouds/azure/management/xml/OperationHandler.java b/azure-management/src/main/java/org/jclouds/azure/management/xml/OperationHandler.java deleted file mode 100644 index 816a0d7..0000000 --- a/azure-management/src/main/java/org/jclouds/azure/management/xml/OperationHandler.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.xml; - -import static org.jclouds.util.SaxUtils.currentOrNull; -import static org.jclouds.util.SaxUtils.equalsOrSuffix; - -import javax.inject.Inject; - -import org.jclouds.azure.management.domain.Operation; -import org.jclouds.azure.management.domain.Operation.Builder; -import org.jclouds.azure.management.domain.Operation.Status; -import org.jclouds.http.functions.ParseSax; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; - -/** - * @see api - */ -public class OperationHandler extends ParseSax.HandlerForGeneratedRequestWithResult { - - protected final ErrorHandler errorHandler; - - @Inject - protected OperationHandler(ErrorHandler errorHandler) { - this.errorHandler = errorHandler; - } - - protected StringBuilder currentText = new StringBuilder(); - protected Operation.Builder builder = builder(); - - protected Builder builder() { - return Operation.builder(); - } - - protected boolean inError; - - /** - * {@inheritDoc} - */ - @Override - public Operation getResult() { - try { - return builder.build(); - } finally { - builder = builder(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { - if (equalsOrSuffix(qName, "Error")) { - inError = true; - } - if (inError) { - errorHandler.startElement(url, name, qName, attributes); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void endElement(String uri, String name, String qName) throws SAXException { - if (equalsOrSuffix(qName, "Error")) { - builder.error(errorHandler.getResult()); - inError = false; - } else if (inError) { - errorHandler.endElement(uri, name, qName); - } else if (equalsOrSuffix(qName, "ID")) { - builder.id(currentOrNull(currentText)); - } else if (qName.equals("Status")) { - String rawStatus = currentOrNull(currentText); - builder.rawStatus(rawStatus); - builder.status(Status.fromValue(rawStatus)); - } else if (equalsOrSuffix(qName, "HttpStatusCode")) { - builder.httpStatusCode(Integer.parseInt(currentOrNull(currentText))); - } - currentText.setLength(0); - } - - /** - * {@inheritDoc} - */ - @Override - public void characters(char ch[], int start, int length) { - if (inError) { - errorHandler.characters(ch, start, length); - } else { - currentText.append(ch, start, length); - } - } - -} diff --git a/azure-management/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/azure-management/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata deleted file mode 100644 index 03fb1db..0000000 --- a/azure-management/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata +++ /dev/null @@ -1 +0,0 @@ -org.jclouds.azure.management.AzureManagementProviderMetadata diff --git a/azure-management/src/test/java/org/jclouds/azure/management/AzureManagementProviderMetadataTest.java b/azure-management/src/test/java/org/jclouds/azure/management/AzureManagementProviderMetadataTest.java deleted file mode 100644 index a8cf4a7..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/AzureManagementProviderMetadataTest.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management; - -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "AzureManagementProviderMetadataTest") -public class AzureManagementProviderMetadataTest extends BaseProviderMetadataTest { - - public AzureManagementProviderMetadataTest() { - super(new AzureManagementProviderMetadata(), new AzureManagementApiMetadata()); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiExpectTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiExpectTest.java deleted file mode 100644 index c2fbd08..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiExpectTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest; -import org.jclouds.azure.management.parse.ListDisksTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -@Test(groups = "unit", testName = "DiskApiExpectTest") -public class DiskApiExpectTest extends BaseAzureManagementApiExpectTest { - - private static final String DISK_NAME = "mydisk"; - - HttpRequest list = HttpRequest.builder().method("GET") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/disks") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/xml").build(); - - public void testListWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/disks.xml", "application/xml")).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenExist.getDiskApi().list().toString(), new ListDisksTest().expected().toString()); - } - - public void testListWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenDontExist.getDiskApi().list(), ImmutableSet.of()); - } - - HttpRequest delete = HttpRequest.builder().method("DELETE") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/disks/" + DISK_NAME) - .addHeader("x-ms-version", "2012-03-01") - .build(); - - public void testDeleteWhenResponseIs2xx() throws Exception { - HttpResponse deleteResponse = HttpResponse.builder().statusCode(200).addHeader("x-ms-request-id", "fakerequestid").build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(delete, deleteResponse); - - apiWhenExist.getDiskApi().delete(DISK_NAME); - } - - public void testDeleteWhenResponseIs404() throws Exception { - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse(delete, deleteResponse); - - apiWhenDontExist.getDiskApi().delete(DISK_NAME); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiLiveTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiLiveTest.java deleted file mode 100644 index 7299bdf..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/features/DiskApiLiveTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.transform; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertTrue; - -import java.util.Set; - -import org.jclouds.azure.management.domain.Disk; -import org.jclouds.azure.management.domain.Location; -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.azure.management.internal.BaseAzureManagementApiLiveTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; - -@Test(groups = "live", testName = "DiskApiLiveTest") -public class DiskApiLiveTest extends BaseAzureManagementApiLiveTest { - - private ImmutableSet locations; - private ImmutableSet images; - - @BeforeClass(groups = { "integration", "live" }) - public void setupContext() { - super.initializeContext(); - - locations = ImmutableSet.copyOf(transform(context.getApi().getLocationApi().list(), - new Function() { - @Override - public String apply(Location in) { - return in.getName(); - } - })); - images = ImmutableSet.copyOf(transform(context.getApi().getOSImageApi().list(), new Function() { - @Override - public String apply(OSImage in) { - return in.getName(); - } - })); - } - - @Test - protected void testList() { - Set response = api().list(); - - for (Disk disk : response) { - checkDisk(disk); - } - } - - private void checkDisk(Disk disk) { - checkNotNull(disk.getName(), "Name cannot be null for Disk %s", disk.getLabel()); - checkNotNull(disk.getOS(), "OS cannot be null for Disk: %s", disk); - assertNotEquals(disk.getOS(), OSType.UNRECOGNIZED, "Status cannot be UNRECOGNIZED for Disk: " + disk); - - checkNotNull(disk.getAttachedTo(), "While AttachedTo can be null for Disk, its Optional wrapper cannot: %s", disk); - if (disk.getAttachedTo().isPresent()) { - // TODO: verify you can lookup the role - } - - checkNotNull(disk.getLogicalSizeInGB(), - "While LogicalSizeInGB can be null for Disk, its Optional wrapper cannot: %s", disk); - - if (disk.getLogicalSizeInGB().isPresent()) - assertTrue(disk.getLogicalSizeInGB().get() > 0, "LogicalSizeInGB should be positive, if set" + disk.toString()); - - checkNotNull(disk.getMediaLink(), "While MediaLink can be null for Disk, its Optional wrapper cannot: %s", disk); - - if (disk.getMediaLink().isPresent()) - assertTrue(ImmutableSet.of("http", "https").contains(disk.getMediaLink().get().getScheme()), - "MediaLink should be an http(s) url" + disk.toString()); - - checkNotNull(disk.getLabel(), "While Label can be null for Disk, its Optional wrapper cannot: %s", - disk); - - checkNotNull(disk.getDescription(), "While Description can be null for Disk, its Optional wrapper cannot: %s", - disk); - - checkNotNull(disk.getLocation(), "While Location can be null for Disk, its Optional wrapper cannot: %s", disk); - if (disk.getLocation().isPresent()) { - assertTrue(locations.contains(disk.getLocation().get()), - "Location not in " + locations + " :" + disk.toString()); - } - - checkNotNull(disk.getSourceImage(), "While SourceImage can be null for Disk, its Optional wrapper cannot: %s", - disk); - if (disk.getSourceImage().isPresent()) { - assertTrue(images.contains(disk.getSourceImage().get()), - "SourceImage not in " + images + " :" + disk.toString()); - } - - checkNotNull(disk.getAffinityGroup(), - "While AffinityGroup can be null for Disk, its Optional wrapper cannot: %s", disk); - if (disk.getAffinityGroup().isPresent()) { - // TODO: list getAffinityGroups and check if there - } - } - - protected DiskApi api() { - return context.getApi().getDiskApi(); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiExpectTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiExpectTest.java deleted file mode 100644 index 31aec87..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiExpectTest.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import static org.jclouds.azure.management.options.CreateHostedServiceOptions.Builder.description; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest; -import org.jclouds.azure.management.parse.GetHostedServiceDetailsTest; -import org.jclouds.azure.management.parse.GetHostedServiceTest; -import org.jclouds.azure.management.parse.ListHostedServicesTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - -@Test(groups = "unit", testName = "HostedServiceApiExpectTest") -public class HostedServiceApiExpectTest extends BaseAzureManagementApiExpectTest { - - private static final String SERVICE_NAME = "myservice"; - HttpRequest list = HttpRequest.builder().method("GET") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/xml").build(); - - public void testListWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/hostedservices.xml", "application")).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenExist.getHostedServiceApi().list().toString(), new ListHostedServicesTest().expected().toString()); - } - - public void testListWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenDontExist.getHostedServiceApi().list(), ImmutableSet.of()); - } - - - public void testCreateServiceWithLabelInLocationWhenResponseIs2xx() throws Exception { - HttpRequest create = HttpRequest.builder().method("POST") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices") - .addHeader("x-ms-version", "2012-03-01") - .payload(payloadFromResourceWithContentType("/create_hostedservice_location.xml", "application/xml")).build(); - - HttpResponse createResponse = HttpResponse.builder() - .addHeader("x-ms-request-id", "171f77920784404db208200702e59227") - .statusCode(201).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(create, createResponse); - - assertEquals( - apiWhenExist.getHostedServiceApi().createServiceWithLabelInLocation(SERVICE_NAME, "service mine", - "West US"), "171f77920784404db208200702e59227"); - } - - public void testCreateWithOptionalParamsWhenResponseIs2xx() throws Exception { - HttpRequest create = HttpRequest.builder().method("POST") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices") - .addHeader("x-ms-version", "2012-03-01") - .payload(payloadFromResourceWithContentType("/create_hostedservice_location_options.xml", "application/xml")).build(); - - HttpResponse createResponse = HttpResponse.builder() - .addHeader("x-ms-request-id", "171f77920784404db208200702e59227") - .statusCode(201).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(create, createResponse); - - assertEquals( - apiWhenExist.getHostedServiceApi().createServiceWithLabelInLocation(SERVICE_NAME, "service mine", - "West US", - description("my description").extendedProperties(ImmutableMap.of("Role", "Production"))), - "171f77920784404db208200702e59227"); - } - - HttpRequest get = HttpRequest.builder().method("GET") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices/" + SERVICE_NAME) - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/xml").build(); - - public void testGetWhenResponseIs2xx() throws Exception { - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/hostedservice.xml", "application")).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(get, getResponse); - - assertEquals(apiWhenExist.getHostedServiceApi().get(SERVICE_NAME).toString(), new GetHostedServiceTest().expected().toString()); - } - - public void testGetWhenResponseIs404() throws Exception { - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse(get, getResponse); - - assertNull(apiWhenDontExist.getHostedServiceApi().get(SERVICE_NAME)); - } - - HttpRequest getDetails = HttpRequest.builder().method("GET") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices/" + SERVICE_NAME + "?embed-detail=true") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/xml").build(); - - public void testGetDetailsWhenResponseIs2xx() throws Exception { - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/hostedservice_details.xml", "application")).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(getDetails, getResponse); - - assertEquals(apiWhenExist.getHostedServiceApi().getDetails(SERVICE_NAME).toString(), new GetHostedServiceDetailsTest().expected().toString()); - } - - public void testGetDetailsWhenResponseIs404() throws Exception { - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse(getDetails, getResponse); - - assertNull(apiWhenDontExist.getHostedServiceApi().getDetails(SERVICE_NAME)); - } - - HttpRequest delete = HttpRequest.builder().method("DELETE") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/hostedservices/" + SERVICE_NAME) - .addHeader("x-ms-version", "2012-03-01") - .build(); - - public void testDeleteWhenResponseIs2xx() throws Exception { - HttpResponse deleteResponse = HttpResponse.builder() - .addHeader("x-ms-request-id", "171f77920784404db208200702e59227") - .statusCode(200).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(delete, deleteResponse); - - assertEquals(apiWhenExist.getHostedServiceApi().delete(SERVICE_NAME), "171f77920784404db208200702e59227"); - } - - public void testDeleteWhenResponseIs404() throws Exception { - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse(delete, deleteResponse); - - assertNull(apiWhenDontExist.getHostedServiceApi().delete(SERVICE_NAME)); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiLiveTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiLiveTest.java deleted file mode 100644 index 4789541..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/features/HostedServiceApiLiveTest.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static java.util.concurrent.TimeUnit.SECONDS; -import static org.jclouds.util.Predicates2.retry; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertTrue; - -import java.util.Set; -import java.util.logging.Logger; - -import org.jclouds.azure.management.domain.DetailedHostedServiceProperties; -import org.jclouds.azure.management.domain.HostedService; -import org.jclouds.azure.management.domain.HostedService.Status; -import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties; -import org.jclouds.azure.management.domain.Operation; -import org.jclouds.azure.management.internal.BaseAzureManagementApiLiveTest; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; - -@Test(groups = "live", testName = "HostedServiceApiLiveTest") -public class HostedServiceApiLiveTest extends BaseAzureManagementApiLiveTest { - - public static final String HOSTED_SERVICE = (System.getProperty("user.name") + "-jclouds-hostedService") - .toLowerCase(); - - private Predicate operationSucceeded; - private Predicate hostedServiceCreated; - private Predicate hostedServiceGone; - - private String location; - - @BeforeClass(groups = "live") - @Override - public void setupContext() { - super.setupContext(); - // TODO: filter locations on those who have compute - location = Iterables.get(context.getApi().getLocationApi().list(), 0).getName(); - operationSucceeded = retry(new Predicate() { - public boolean apply(String input) { - return context.getApi().getOperationApi().get(input).getStatus() == Operation.Status.SUCCEEDED; - } - }, 600, 5, 5, SECONDS); - hostedServiceCreated = retry(new Predicate() { - public boolean apply(HostedServiceWithDetailedProperties input) { - return api().getDetails(input.getName()).getProperties().getStatus() == Status.CREATED; - } - }, 600, 5, 5, SECONDS); - hostedServiceGone = retry(new Predicate() { - public boolean apply(HostedService input) { - return api().get(input.getName()) == null; - } - }, 600, 5, 5, SECONDS); - } - - private HostedServiceWithDetailedProperties hostedService; - - public void testCreateHostedService() { - - String requestId = api().createServiceWithLabelInLocation(HOSTED_SERVICE, HOSTED_SERVICE, location); - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().info("operation succeeded: " + requestId); - - hostedService = api().getDetails(HOSTED_SERVICE); - Logger.getAnonymousLogger().info("created hostedService: " + hostedService); - - assertEquals(hostedService.getName(), HOSTED_SERVICE); - - checkHostedService(hostedService); - - assertTrue(hostedServiceCreated.apply(hostedService), hostedService.toString()); - hostedService = api().getDetails(hostedService.getName()); - Logger.getAnonymousLogger().info("hostedService available: " + hostedService); - - } - - @Test(dependsOnMethods = "testCreateHostedService") - public void testDeleteHostedService() { - String requestId = api().delete(hostedService.getName()); - assertTrue(operationSucceeded.apply(requestId), requestId); - Logger.getAnonymousLogger().info("operation succeeded: " + requestId); - - assertTrue(hostedServiceGone.apply(hostedService), hostedService.toString()); - Logger.getAnonymousLogger().info("hostedService deleted: " + hostedService); - } - - @Override - @AfterClass(groups = "live") - protected void tearDownContext() { - String requestId = api().delete(HOSTED_SERVICE); - if (requestId != null) - operationSucceeded.apply(requestId); - - super.tearDownContext(); - } - - @Test - protected void testList() { - Set response = api().list(); - - for (HostedServiceWithDetailedProperties hostedService : response) { - checkHostedService(hostedService); - } - - if (response.size() > 0) { - HostedService hostedService = response.iterator().next(); - Assert.assertEquals(api().getDetails(hostedService.getName()), hostedService); - } - } - - private void checkHostedService(HostedServiceWithDetailedProperties hostedService) { - checkNotNull(hostedService.getUrl(), "Url cannot be null for a HostedService."); - checkNotNull(hostedService.getName(), "ServiceName cannot be null for HostedService %s", hostedService.getUrl()); - checkNotNull(hostedService.getProperties(), "Properties cannot be null for HostedService %s", - hostedService.getUrl()); - checkProperties(hostedService.getProperties()); - } - - private void checkProperties(DetailedHostedServiceProperties hostedService) { - checkNotNull(hostedService.getDescription(), - "While Description can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s", - hostedService); - checkNotNull(hostedService.getLocation(), - "While Location can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s", - hostedService); - checkNotNull(hostedService.getAffinityGroup(), - "While AffinityGroup can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s", - hostedService); - checkState(hostedService.getLocation().isPresent() || hostedService.getAffinityGroup().isPresent(), - "Location or AffinityGroup must be present for DetailedHostedServiceProperties: %s", hostedService); - checkNotNull(hostedService.getLabel(), "Label cannot be null for HostedService %s", hostedService); - - checkNotNull(hostedService.getStatus(), "Status cannot be null for DetailedHostedServiceProperties: %s", - hostedService); - assertNotEquals(hostedService.getStatus(), Status.UNRECOGNIZED, - "Status cannot be UNRECOGNIZED for DetailedHostedServiceProperties: " + hostedService); - checkNotNull(hostedService.getCreated(), "Created cannot be null for DetailedHostedServiceProperties %s", - hostedService); - checkNotNull(hostedService.getLastModified(), - "LastModified cannot be null for DetailedHostedServiceProperties %s", hostedService); - checkNotNull(hostedService.getExtendedProperties(), - "ExtendedProperties cannot be null for DetailedHostedServiceProperties %s", hostedService); - } - - protected HostedServiceApi api() { - return context.getApi().getHostedServiceApi(); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiExpectTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiExpectTest.java deleted file mode 100644 index 3eae54e..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiExpectTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import static org.testng.Assert.assertEquals; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest; -import org.jclouds.azure.management.parse.ListLocationsTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -@Test(groups = "unit", testName = "LocationApiExpectTest") -public class LocationApiExpectTest extends BaseAzureManagementApiExpectTest { - - HttpRequest list = HttpRequest.builder() - .method("GET") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/locations") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/xml").build(); - - public void testListWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/locations.xml", "application")).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenExist.getLocationApi().list().toString(), new ListLocationsTest().expected().toString()); - } - - public void testListWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenDontExist.getLocationApi().list(), ImmutableSet.of()); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiLiveTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiLiveTest.java deleted file mode 100644 index 713c9c5..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/features/LocationApiLiveTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import java.util.Set; - -import org.jclouds.azure.management.domain.Location; -import org.jclouds.azure.management.internal.BaseAzureManagementApiLiveTest; -import org.testng.annotations.Test; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -@Test(groups = "live", testName = "LocationApiLiveTest") -public class LocationApiLiveTest extends BaseAzureManagementApiLiveTest { - - @Test - protected void testList() { - Set response = api().list(); - - for (Location location : response) { - checkLocation(location); - } - - } - - protected Predicate knownServices = Predicates.in(ImmutableSet.of("Compute", "Storage", "PersistentVMRole")); - - private void checkLocation(Location location) { - checkNotNull(location.getName(), "Name cannot be null for a Location."); - checkNotNull(location.getDisplayName(), "DisplayName cannot be null for Location %s", location.getName()); - checkNotNull(location.getAvailableServices(), "AvailableServices cannot be null for Location %s", - location.getName()); - checkState(Iterables.all(location.getAvailableServices(), knownServices), - "AvailableServices in Location %s didn't match %s: %s", location.getName(), knownServices, - location.getAvailableServices()); - } - - protected LocationApi api() { - return context.getApi().getLocationApi(); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiExpectTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiExpectTest.java deleted file mode 100644 index 0b3e849..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiExpectTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.domain.OSImageParams; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest; -import org.jclouds.azure.management.parse.ListOSImagesTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -@Test(groups = "unit", testName = "OSImageApiExpectTest") -public class OSImageApiExpectTest extends BaseAzureManagementApiExpectTest { - - private static final String IMAGE_NAME = "myimage"; - - HttpRequest list = HttpRequest.builder().method("GET") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/images") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/xml").build(); - - public void testListWhenResponseIs2xx() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/images.xml", "application/xml")).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenExist.getOSImageApi().list().toString(), new ListOSImagesTest().expected().toString()); - } - - public void testListWhenResponseIs404() throws Exception { - - HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse( - list, listResponse); - - assertEquals(apiWhenDontExist.getOSImageApi().list(), ImmutableSet.of()); - } - - HttpRequest add = HttpRequest.builder().method("POST") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/images") - .addHeader("x-ms-version", "2012-03-01") - .payload(payloadFromResourceWithContentType("/imageparams.xml", "application/xml")).build(); - - public void testAddWhenResponseIs2xx() throws Exception { - HttpResponse addResponse = HttpResponse.builder().statusCode(200).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(add, addResponse); - - OSImageParams params = OSImageParams.builder().name(IMAGE_NAME).label("foo").os(OSType.LINUX) - .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build(); - apiWhenExist.getOSImageApi().add(params); - } - - HttpRequest update = HttpRequest.builder().method("PUT") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/images/" + IMAGE_NAME) - .addHeader("x-ms-version", "2012-03-01") - .payload(payloadFromResourceWithContentType("/imageparams.xml", "application/xml")).build(); - - public void testUpdateWhenResponseIs2xx() throws Exception { - HttpResponse updateResponse = HttpResponse.builder().statusCode(200).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(update, updateResponse); - - OSImageParams params = OSImageParams.builder().name(IMAGE_NAME).label("foo").os(OSType.LINUX) - .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build(); - apiWhenExist.getOSImageApi().update(params); - } - - HttpRequest delete = HttpRequest.builder().method("DELETE") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/services/images/" + IMAGE_NAME) - .addHeader("x-ms-version", "2012-03-01") - .build(); - - public void testDeleteWhenResponseIs2xx() throws Exception { - HttpResponse deleteResponse = HttpResponse.builder().statusCode(200).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(delete, deleteResponse); - - apiWhenExist.getOSImageApi().delete(IMAGE_NAME); - } - - public void testDeleteWhenResponseIs404() throws Exception { - HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse(delete, deleteResponse); - - apiWhenDontExist.getOSImageApi().delete(IMAGE_NAME); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiLiveTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiLiveTest.java deleted file mode 100644 index 355617a..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/features/OSImageApiLiveTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.transform; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertTrue; - -import java.util.Set; - -import org.jclouds.azure.management.domain.Location; -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.azure.management.internal.BaseAzureManagementApiLiveTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; - -@Test(groups = "live", testName = "OSImageApiLiveTest") -public class OSImageApiLiveTest extends BaseAzureManagementApiLiveTest { - - private ImmutableSet locations; - - @BeforeClass(groups = { "integration", "live" }) - public void setupContext() { - super.initializeContext(); - - locations = ImmutableSet.copyOf(transform(context.getApi().getLocationApi().list(), - new Function() { - @Override - public String apply(Location in) { - return in.getName(); - } - })); - } - - @Test - protected void testList() { - Set response = api().list(); - - for (OSImage image : response) { - checkOSImage(image); - } - } - - private void checkOSImage(OSImage image) { - checkNotNull(image.getLabel(), "Label cannot be null for OSImage %s", image); - checkNotNull(image.getName(), "Name cannot be null for OSImage %s", image.getLabel()); - checkNotNull(image.getOS(), "OS cannot be null for OSImage: %s", image); - assertNotEquals(image.getOS(), OSType.UNRECOGNIZED, "Status cannot be UNRECOGNIZED for OSImage: " + image); - - checkNotNull(image.getCategory(), "While Category can be null for OSImage, its Optional wrapper cannot: %s", - image); - if (image.getCategory().isPresent()) - assertNotEquals("", image.getCategory().get().trim(), "Invalid Category: " + image.toString()); - - checkNotNull(image.getLogicalSizeInGB(), - "While LogicalSizeInGB can be null for OSImage, its Optional wrapper cannot: %s", image); - - if (image.getLogicalSizeInGB().isPresent()) - assertTrue(image.getLogicalSizeInGB().get() > 0, - "LogicalSizeInGB should be positive, if set" + image.toString()); - - checkNotNull(image.getMediaLink(), "While MediaLink can be null for OSImage, its Optional wrapper cannot: %s", - image); - - if (image.getMediaLink().isPresent()) - assertTrue(ImmutableSet.of("http", "https").contains(image.getMediaLink().get().getScheme()), - "MediaLink should be an http(s) url" + image.toString()); - - checkNotNull(image.getDescription(), - "While Description can be null for OSImage, its Optional wrapper cannot: %s", image); - - checkNotNull(image.getLocation(), "While Location can be null for OSImage, its Optional wrapper cannot: %s", - image); - if (image.getLocation().isPresent()) { - assertTrue(locations.contains(image.getLocation().get()), - "Location not in " + locations + " :" + image.toString()); - } - - checkNotNull(image.getEula(), "While Eula can be null for OSImage, its Optional wrapper cannot: %s", - image); - if (image.getEula().isPresent()) { - assertTrue(ImmutableSet.of("http", "https").contains(image.getEula().get().getScheme()), - "Eula should be an http(s) url" + image.toString()); - } - - checkNotNull(image.getAffinityGroup(), - "While AffinityGroup can be null for OSImage, its Optional wrapper cannot: %s", image); - if (image.getAffinityGroup().isPresent()) { - // TODO: list getAffinityGroups and check if there - } - } - - protected OSImageApi api() { - return context.getApi().getOSImageApi(); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/OperationApiExpectTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/OperationApiExpectTest.java deleted file mode 100644 index 3989681..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/features/OperationApiExpectTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest; -import org.jclouds.azure.management.parse.GetOperationTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "OperationApiExpectTest") -public class OperationApiExpectTest extends BaseAzureManagementApiExpectTest { - private static final String REQUEST_ID ="request-id"; - - HttpRequest get = HttpRequest.builder().method("GET") - .endpoint("https://management.core.windows.net/" + subscriptionId + "/operations/" + REQUEST_ID) - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/xml").build(); - - public void testGetWhenResponseIs2xx() throws Exception { - HttpResponse getResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType("/operation.xml", "application")).build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(get, getResponse); - - assertEquals(apiWhenExist.getOperationApi().get(REQUEST_ID).toString(), new GetOperationTest().expected().toString()); - } - - public void testGetWhenResponseIs404() throws Exception { - HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); - - AzureManagementApi apiWhenDontExist = requestSendsResponse(get, getResponse); - - assertNull(apiWhenDontExist.getOperationApi().get(REQUEST_ID)); - } - -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/features/RoleApiExpectTest.java b/azure-management/src/test/java/org/jclouds/azure/management/features/RoleApiExpectTest.java deleted file mode 100644 index bfb38dd..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/features/RoleApiExpectTest.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.features; - -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.domain.DeploymentParams; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.azure.management.domain.RoleSize; -import org.jclouds.azure.management.internal.BaseAzureManagementApiExpectTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "RoleApiExpectTest") -public class RoleApiExpectTest extends BaseAzureManagementApiExpectTest { - - private static final String DEPLOYMENT_NAME = "mydeployment"; - private static final String IMAGE_NAME = "myImageName"; - private static final String IMAGE_LABEL = "myImageLabel"; - - HttpRequest add = HttpRequest - .builder() - .method("POST") - .endpoint( - "https://management.core.windows.net/" + subscriptionId - + "/services/hostedservices/" + DEPLOYMENT_NAME - + "/deployments") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/atom+xml") - .payload( - payloadFromResourceWithContentType("/deploymentparams.xml", - "application/atom+xml")).build(); - - public void testAddWhenResponseIs2xx() throws Exception { - HttpResponse addResponse = HttpResponse.builder().statusCode(200) - .addHeader("x-ms-request-id", "fakerequestid").build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(add, addResponse); - DeploymentParams params = DeploymentParams - .builder() - .osType(OSType.LINUX) - .name(DEPLOYMENT_NAME) - .username("username") - .password("testpwd") - .size(RoleSize.MEDIUM) - .sourceImageName( - "OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd") - .storageAccount("portalvhds0g7xhnq2x7t21").build(); - - apiWhenExist.getRoleApi().createDeployment(DEPLOYMENT_NAME, params); - } - - HttpRequest start = HttpRequest - .builder() - .method("POST") - .endpoint( - "https://management.core.windows.net/" + subscriptionId - + "/services/hostedservices/" + DEPLOYMENT_NAME - + "/deployments/" + DEPLOYMENT_NAME - + "/roleInstances/" + DEPLOYMENT_NAME - + "/Operations") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/atom+xml") - .payload( - payloadFromResourceWithContentType("/startrolepayload.xml", - "application/atom+xml")).build(); - - public void testStartWhenResponseIs2xx() throws Exception { - HttpResponse addResponse = HttpResponse.builder().statusCode(200) - .addHeader("x-ms-request-id", "fakerequestid").build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(start, - addResponse); - - apiWhenExist.getRoleApi().startRole(DEPLOYMENT_NAME, DEPLOYMENT_NAME, - DEPLOYMENT_NAME); - } - - HttpRequest shutdown = HttpRequest - .builder() - .method("POST") - .endpoint( - "https://management.core.windows.net/" + subscriptionId - + "/services/hostedservices/" + DEPLOYMENT_NAME - + "/deployments/" + DEPLOYMENT_NAME - + "/roleInstances/" + DEPLOYMENT_NAME - + "/Operations") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/atom+xml") - .payload( - payloadFromResourceWithContentType( - "/shutdownrolepayload.xml", "application/atom+xml")) - .build(); - - public void testShutdownWhenResponseIs2xx() throws Exception { - HttpResponse addResponse = HttpResponse.builder().statusCode(200) - .addHeader("x-ms-request-id", "fakerequestid").build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(shutdown, - addResponse); - - apiWhenExist.getRoleApi().shutdownRole(DEPLOYMENT_NAME, - DEPLOYMENT_NAME, DEPLOYMENT_NAME); - } - - HttpRequest restart = HttpRequest - .builder() - .method("POST") - .endpoint( - "https://management.core.windows.net/" + subscriptionId - + "/services/hostedservices/" + DEPLOYMENT_NAME - + "/deployments/" + DEPLOYMENT_NAME - + "/roleInstances/" + DEPLOYMENT_NAME - + "/Operations") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/atom+xml") - .payload( - payloadFromResourceWithContentType( - "/restartrolepayload.xml", "application/atom+xml")) - .build(); - - public void testRestartWhenResponseIs2xx() throws Exception { - HttpResponse addResponse = HttpResponse.builder().statusCode(200) - .addHeader("x-ms-request-id", "fakerequestid").build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(restart, - addResponse); - - apiWhenExist.getRoleApi().restartRole(DEPLOYMENT_NAME, DEPLOYMENT_NAME, - DEPLOYMENT_NAME); - } - - HttpRequest capture = HttpRequest - .builder() - .method("POST") - .endpoint( - "https://management.core.windows.net/" + subscriptionId - + "/services/hostedservices/" + DEPLOYMENT_NAME - + "/deployments/" + DEPLOYMENT_NAME - + "/roleInstances/" + DEPLOYMENT_NAME - + "/Operations") - .addHeader("x-ms-version", "2012-03-01") - .addHeader("Accept", "application/atom+xml") - .payload( - payloadFromResourceWithContentType( - "/capturerolepayload.xml", "application/atom+xml")) - .build(); - - public void testCaptureWhenResponseIs2xx() throws Exception { - HttpResponse addResponse = HttpResponse.builder().statusCode(200) - .addHeader("x-ms-request-id", "fakerequestid").build(); - - AzureManagementApi apiWhenExist = requestSendsResponse(capture, - addResponse); - - apiWhenExist.getRoleApi().captureRole(DEPLOYMENT_NAME, DEPLOYMENT_NAME, - DEPLOYMENT_NAME, IMAGE_NAME, IMAGE_LABEL); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementApiExpectTest.java b/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementApiExpectTest.java deleted file mode 100644 index 2300b64..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementApiExpectTest.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.internal; - -import org.jclouds.azure.management.AzureManagementApi; - -public class BaseAzureManagementApiExpectTest extends BaseAzureManagementExpectTest { - -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementApiLiveTest.java b/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementApiLiveTest.java deleted file mode 100644 index c7d2984..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementApiLiveTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.internal; - -import java.util.Properties; - -import org.jclouds.apis.BaseContextLiveTest; -import org.jclouds.azure.management.AzureManagementApi; -import org.jclouds.azure.management.AzureManagementApiMetadata; -import org.jclouds.azure.management.AzureManagementAsyncApi; -import org.jclouds.azure.management.config.AzureManagementProperties; -import org.jclouds.rest.RestContext; - -import com.google.common.reflect.TypeToken; - -public class BaseAzureManagementApiLiveTest extends - BaseContextLiveTest> { - - protected String subscriptionId; - - public BaseAzureManagementApiLiveTest() { - provider = "azure-management"; - } - - @Override - protected Properties setupProperties() { - Properties props = super.setupProperties(); - subscriptionId = setIfTestSystemPropertyPresent(props, AzureManagementProperties.SUBSCRIPTION_ID); - return props; - } - - @Override - protected TypeToken> contextType() { - return AzureManagementApiMetadata.CONTEXT_TOKEN; - } - -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementAsyncApiExpectTest.java b/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementAsyncApiExpectTest.java deleted file mode 100644 index 1a1f395..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementAsyncApiExpectTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.internal; - -import java.util.Properties; - -import org.jclouds.azure.management.AzureManagementAsyncApi; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; -import com.google.inject.Module; - -public class BaseAzureManagementAsyncApiExpectTest extends BaseAzureManagementExpectTest { - public AzureManagementAsyncApi createApi(Function fn, Module module, Properties props) { - return createInjector(fn, module, props).getInstance(AzureManagementAsyncApi.class); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementExpectTest.java b/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementExpectTest.java deleted file mode 100644 index bc40116..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/internal/BaseAzureManagementExpectTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.internal; - -import java.util.Properties; - -import org.jclouds.azure.management.config.AzureManagementProperties; -import org.jclouds.azure.management.config.AzureManagementRestClientModule; -import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.internal.BaseRestApiExpectTest; - -import com.google.inject.Module; - -public class BaseAzureManagementExpectTest extends BaseRestApiExpectTest { - protected String subscriptionId = "a01234b5c-d6e7-8f9g-h0123-4567i890j1k"; - - public BaseAzureManagementExpectTest() { - provider = "azure-management"; - // self-signed dummy cert: - // keytool -genkey -alias test -keyalg RSA -keysize 1024 -validity 5475 -dname "CN=localhost" -keystore azure-test.p12 -storepass azurepass -storetype pkcs12 - identity = this.getClass().getResource("/azure-test.p12").getFile(); - credential = "azurepass"; - } - - @Override - protected Properties setupProperties() { - Properties props = super.setupProperties(); - props.put(AzureManagementProperties.SUBSCRIPTION_ID, subscriptionId); - return props; - } - - @ConfiguresRestClient - private static final class TestAzureManagementRestClientModule extends AzureManagementRestClientModule { - - } - - @Override - protected Module createModule() { - return new TestAzureManagementRestClientModule(); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/parse/ErrorTest.java b/azure-management/src/test/java/org/jclouds/azure/management/parse/ErrorTest.java deleted file mode 100644 index 6de18dc..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/parse/ErrorTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.azure.management.domain.Error; -import org.jclouds.azure.management.domain.Error.Code; -import org.jclouds.azure.management.xml.ErrorHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ErrorTest") -public class ErrorTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/error.xml"); - - Error expected = expected(); - - ErrorHandler handler = injector.getInstance(ErrorHandler.class); - Error result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Error expected() { - return Error.builder() - .rawCode("MissingOrInvalidRequiredQueryParameter") - .code(Code.MISSING_OR_INVALID_REQUIRED_QUERY_PARAMETER) - .message("A required query parameter was not specified for this request or was specified incorrectly.") - .build(); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/parse/GetDeploymentTest.java b/azure-management/src/test/java/org/jclouds/azure/management/parse/GetDeploymentTest.java deleted file mode 100644 index 12d10a1..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/parse/GetDeploymentTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.azure.management.domain.Deployment; -import org.jclouds.azure.management.domain.DeploymentSlot; -import org.jclouds.azure.management.domain.DeploymentStatus; -import org.jclouds.azure.management.domain.InstanceStatus; -import org.jclouds.azure.management.domain.RoleSize; -import org.jclouds.azure.management.xml.DeploymentHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetDeploymentTest") -public class GetDeploymentTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/deployment.xml"); - - Deployment expected = expected(); - - DeploymentHandler handler = injector.getInstance(DeploymentHandler.class); - Deployment result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Deployment expected() { - return Deployment.builder() - .deploymentName("neotysss") - .deploymentSlot(DeploymentSlot.PRODUCTION) - .deploymentStatus(DeploymentStatus.RUNNING) - .deploymentLabel("neotysss") - .deploymentURL(URI.create("http://neotysss.cloudapp.net/")) - .roleName("neotysss") - .instanceName("neotysss") - .instanceStatus(InstanceStatus.READY_ROLE) - .instanceSize(RoleSize.MEDIUM) - .privateIpAddress("10.59.244.162") - .publicIpAddress("168.63.27.148") - .build(); - } - -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/parse/GetHostedServiceDetailsTest.java b/azure-management/src/test/java/org/jclouds/azure/management/parse/GetHostedServiceDetailsTest.java deleted file mode 100644 index a6e2dcb..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/parse/GetHostedServiceDetailsTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.azure.management.domain.DetailedHostedServiceProperties; -import org.jclouds.azure.management.domain.HostedService; -import org.jclouds.azure.management.domain.HostedService.Status; -import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties; -import org.jclouds.azure.management.xml.HostedServiceWithDetailedPropertiesHandler; -import org.jclouds.date.DateService; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "DetailedHostedServiceProperties") -public class GetHostedServiceDetailsTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/hostedservice_details.xml"); - - HostedService expected = expected(); - - HostedServiceWithDetailedPropertiesHandler handler = injector.getInstance(HostedServiceWithDetailedPropertiesHandler.class); - HostedServiceWithDetailedProperties result = HostedServiceWithDetailedProperties.class.cast(factory.create(handler).parse(is)); - - assertEquals(result.toString(), expected.toString()); - - } - - protected final DateService dateService = new SimpleDateFormatDateService(); - - public HostedServiceWithDetailedProperties expected() { - return HostedServiceWithDetailedProperties.builder() - .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys")) - .name("neotys") - .properties(DetailedHostedServiceProperties.builder() - .description("Implicitly created hosted service2012-08-06 14:55") - .location("West Europe") - .label("neotys") - .rawStatus("Created") - .status(Status.CREATED) - .created(dateService.iso8601SecondsDateParse("2012-08-06T14:55:17Z")) - .lastModified(dateService.iso8601SecondsDateParse("2012-08-06T15:50:34Z")) - .build()) - .build(); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/parse/GetHostedServiceTest.java b/azure-management/src/test/java/org/jclouds/azure/management/parse/GetHostedServiceTest.java deleted file mode 100644 index 7469591..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/parse/GetHostedServiceTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.azure.management.domain.HostedService; -import org.jclouds.azure.management.domain.HostedServiceProperties; -import org.jclouds.azure.management.xml.HostedServiceHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetHostedServiceTest") -public class GetHostedServiceTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/hostedservice.xml"); - - HostedService expected = expected(); - - HostedServiceHandler handler = injector.getInstance(HostedServiceHandler.class); - HostedService result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public HostedService expected() { - return HostedService.builder() - .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys")) - .name("neotys") - .properties(HostedServiceProperties.builder() - .description("Implicitly created hosted service2012-08-06 14:55") - .location("West Europe") - .label("neotys") - .build()) - .build(); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/parse/GetOperationTest.java b/azure-management/src/test/java/org/jclouds/azure/management/parse/GetOperationTest.java deleted file mode 100644 index 1b8458e..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/parse/GetOperationTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; - -import org.jclouds.azure.management.domain.Error; -import org.jclouds.azure.management.domain.Error.Code; -import org.jclouds.azure.management.domain.Operation; -import org.jclouds.azure.management.domain.Operation.Status; -import org.jclouds.azure.management.xml.OperationHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GetOperationTest") -public class GetOperationTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/operation.xml"); - - Operation expected = expected(); - - OperationHandler handler = injector.getInstance(OperationHandler.class); - Operation result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Operation expected() { - return Operation.builder() - .id("request-id") - .rawStatus("Failed") - .status(Status.FAILED) - .httpStatusCode(400) - .error(Error.builder() - .rawCode("MissingOrInvalidRequiredQueryParameter") - .code(Code.MISSING_OR_INVALID_REQUIRED_QUERY_PARAMETER) - .message("A required query parameter was not specified for this request or was specified incorrectly.") - .build()) - .build(); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/parse/ListDisksTest.java b/azure-management/src/test/java/org/jclouds/azure/management/parse/ListDisksTest.java deleted file mode 100644 index 814eeed..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/parse/ListDisksTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.util.Set; - -import org.jclouds.azure.management.domain.Disk; -import org.jclouds.azure.management.domain.Disk.Attachment; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.azure.management.xml.ListDisksHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ListDisksTest") -public class ListDisksTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/disks.xml"); - - Set expected = expected(); - - ListDisksHandler handler = injector.getInstance(ListDisksHandler.class); - Set result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Set expected() { - - return ImmutableSet.builder() - .add(Disk.builder() - .os(OSType.LINUX) - .location("West Europe") - .logicalSizeInGB(30) - .mediaLink(URI.create("http://neotysbucket1.blob.core.windows.net/vhds/testimage2-testimage2-2012-08-17.vhd")) - .name("testimage2-testimage2-0-20120817095145") - .sourceImage("OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd") - .build()) - .add(Disk.builder() - .attachedTo(Attachment.builder().deployment("neotysss").hostedService("neotysss").role("neotysss").build()) - .os(OSType.WINDOWS) - .location("West Europe") - .logicalSizeInGB(30) - .mediaLink(URI.create("http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/neotysss/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd")) - .name("neotysss-neotysss-0-20120824091357") - .sourceImage("MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd") - .build()) - .build(); - } - -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/parse/ListHostedServicesTest.java b/azure-management/src/test/java/org/jclouds/azure/management/parse/ListHostedServicesTest.java deleted file mode 100644 index eb8993d..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/parse/ListHostedServicesTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.util.Set; - -import org.jclouds.azure.management.domain.DetailedHostedServiceProperties; -import org.jclouds.azure.management.domain.HostedService.Status; -import org.jclouds.azure.management.domain.HostedServiceWithDetailedProperties; -import org.jclouds.azure.management.xml.ListHostedServicesHandler; -import org.jclouds.date.DateService; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ListHostedServicesTest") -public class ListHostedServicesTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/hostedservices.xml"); - - Set expected = expected(); - - ListHostedServicesHandler handler = injector.getInstance(ListHostedServicesHandler.class); - Set result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - protected final DateService dateService = new SimpleDateFormatDateService(); - - public Set expected() { - return ImmutableSet.builder() - .add(HostedServiceWithDetailedProperties.builder() - .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys")) - .name("neotys") - .properties(DetailedHostedServiceProperties.builder() - .description("Implicitly created hosted service2012-08-06 14:55") - .location("West Europe") - .label("neotys") - .rawStatus("Created") - .status(Status.CREATED) - .created(dateService.iso8601SecondsDateParse("2012-08-06T14:55:17Z")) - .lastModified(dateService.iso8601SecondsDateParse("2012-08-06T15:50:34Z")) - .build()) - .build()) - .add(HostedServiceWithDetailedProperties.builder() - .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys3")) - .name("neotys3") - .properties(DetailedHostedServiceProperties.builder() - .location("West Europe") - .label("neotys3") - .rawStatus("Created") - .status(Status.CREATED) - .created(dateService.iso8601SecondsDateParse("2012-08-07T09:00:02Z")) - .lastModified(dateService.iso8601SecondsDateParse("2012-08-07T09:00:02Z")) - .build()) - .build()).build(); - } -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/parse/ListLocationsTest.java b/azure-management/src/test/java/org/jclouds/azure/management/parse/ListLocationsTest.java deleted file mode 100644 index 7e26f18..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/parse/ListLocationsTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.util.Set; - -import org.jclouds.azure.management.domain.Location; -import org.jclouds.azure.management.xml.ListLocationsHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "LocationsTest") -public class ListLocationsTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/locations.xml"); - - Set expected = expected(); - - ListLocationsHandler handler = injector.getInstance(ListLocationsHandler.class); - Set result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Set expected() { - Set availableServices = ImmutableSet.of("Compute", "Storage","PersistentVMRole"); - return ImmutableSet.builder() - .add(Location.builder() - .name("West US") - .displayName("West US") - .availableServices(availableServices) - .build()) - .add(Location.builder() - .name("East US") - .displayName("East US") - .availableServices(availableServices) - .build()) - .add(Location.builder() - .name("East Asia") - .displayName("East Asia") - .availableServices(availableServices) - .build()) - .add(Location.builder() - .name("Southeast Asia") - .displayName("Southeast Asia") - .availableServices(availableServices) - .build()) - .add(Location.builder() - .name("North Europe") - .displayName("North Europe") - .availableServices(availableServices) - .build()) - .add(Location.builder() - .name("West Europe") - .displayName("West Europe") - .availableServices(availableServices) - .build()).build(); - } - -} diff --git a/azure-management/src/test/java/org/jclouds/azure/management/parse/ListOSImagesTest.java b/azure-management/src/test/java/org/jclouds/azure/management/parse/ListOSImagesTest.java deleted file mode 100644 index 4b05491..0000000 --- a/azure-management/src/test/java/org/jclouds/azure/management/parse/ListOSImagesTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.azure.management.parse; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.util.Set; - -import org.jclouds.azure.management.domain.OSImage; -import org.jclouds.azure.management.domain.OSType; -import org.jclouds.azure.management.xml.ListOSImagesHandler; -import org.jclouds.http.functions.BaseHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "ListOSImagesTest") -public class ListOSImagesTest extends BaseHandlerTest { - - public void test() { - InputStream is = getClass().getResourceAsStream("/images.xml"); - - Set expected = expected(); - - ListOSImagesHandler handler = injector.getInstance(ListOSImagesHandler.class); - Set result = factory.create(handler).parse(is); - - assertEquals(result.toString(), expected.toString()); - - } - - public Set expected() { - return ImmutableSet.builder() - .add(OSImage.builder() - .category("Canonical") - .label("Ubuntu Server 12.04 LTS") - .logicalSizeInGB(30) - .name("CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd") - .os(OSType.LINUX) - .eula(URI.create("http://www.ubuntu.com/project/about-ubuntu/licensing")) - .description("Ubuntu Server 12.04 LTS amd64 20120528 Cloud Image") - .build()) - .add(OSImage.builder() - .category("Microsoft") - .label("Windows Server 2008 R2 SP1, June 2012") - .logicalSizeInGB(30) - .name("MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd") - .os(OSType.WINDOWS) - .description("Windows Server 2008 R2 is a multi-purpose server.") - .build()) - .add(OSImage.builder() - .category("Microsoft") - .label("Microsoft SQL Server 2012 Evaluation Edition") - .logicalSizeInGB(30) - .name("MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd") - .os(OSType.WINDOWS) - .eula(URI.create("http://go.microsoft.com/fwlink/?LinkID=251820;http://go.microsoft.com/fwlink/?LinkID=131004")) - .description("SQL Server 2012 Evaluation Edition (64-bit).") - .build()) - .add(OSImage.builder() - .category("Microsoft") - .label("Windows Server 2012 Release Candidate, July 2012") - .logicalSizeInGB(30) - .name("MSFT__Win2K12RC-Datacenter-201207.02-en.us-30GB.vhd") - .os(OSType.WINDOWS) - .description("Windows Server 2012 incorporates Microsoft's experience building.") - .build()) - .add(OSImage.builder() - .category("Microsoft") - .label("Windows Server 2008 R2 SP1, July 2012") - .logicalSizeInGB(30) - .name("MSFT__Win2K8R2SP1-Datacenter-201207.01-en.us-30GB.vhd") - .os(OSType.WINDOWS) - .description("Windows Server 2008 R2 is a multi-purpose server.") - .build()) - .add(OSImage.builder() - .category("OpenLogic") - .label("OpenLogic CentOS 6.2") - .logicalSizeInGB(30) - .name("OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd") - .os(OSType.LINUX) - .eula(URI.create("http://www.openlogic.com/azure/service-agreement/")) - .description("This distribution of Linux is based on CentOS.") - .build()) - .add(OSImage.builder() - .category("SUSE") - .label("openSUSE 12.1") - .logicalSizeInGB(30) - .name("SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd") - .os(OSType.LINUX) - .eula(URI.create("http://opensuse.org/")) - .description("openSUSE is a free and Linux-based operating system!") - .build()) - .add(OSImage.builder() - .category("SUSE") - .label("SUSE Linux Enterprise Server") - .logicalSizeInGB(30) - .name("SUSE__SUSE-Linux-Enterprise-Server-11SP2-20120601-en-us-30GB.vhd") - .os(OSType.LINUX) - .eula(URI.create("http://www.novell.com/licensing/eula/")) - .description("SUSE Linux Enterprise Server is a highly reliable value.") - .build()).build(); - } - -} diff --git a/azure-management/src/test/resources/azure-test.p12 b/azure-management/src/test/resources/azure-test.p12 deleted file mode 100644 index 5250dd6ec2554e87216a48aab04594968e14a325..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1536 zcmY+DdpOg39LM+j?V@4svs|W@`;d(#%c6_>N?U{|DTalLp;4AI)g(uXQ7*aU(v#Fd zZj~hK$gP@DBFVK_qJ-GN(es>BPk(%$&-1+ApU?NN_lv-V{{sS00vBG5K;q9ko}Whn zQa~OTUIOF7Z>-{60vD?JTLeYHxKQLOhOa&VA@kprtTX`Talr}#7ra9-KuG_OS3g&W zsW@<(uTScw7v(mcc}cQr>ltPrcLqTi1jYs9l*M^1()-uj+G z9(^cOUs@3Uv4|qMYG5N}*&j1A7d&)&9b6uKj0lG0mJCEiA1RSJuxuT*GSZjMlx;W4 zkjc}7PuqM(bVi@hbr+8}&`Z7|#0=H^iIG|Rck=h_Jj3MlsG0e1Ixc32E6-gic`XpNOp;;UJl^E0>p zQC$go>4ed`)G@ixo1&1qLovWUq3Dg^+YC?Lt%5(X=eZQ=np;@LzC|z7heCEt-}6}x zV3hO0bEvfec&&hepZy~Ei(nw%(2`6eVp*93TDki6c_tVNHSoCdogme|8y^{3{?!W) z;vSidVDVq}ZEZV!vB~7KW+`d?vHE$*IfXE$6SZ)@r-tlDFVAUV!VrZhG^Wiyj@i8^ zu6q4;;QJPIfTz^-s2%6%0Z!Co9N}Q%0F+W-XW;WpF$&@)gL~huU8* zg+Zdrc0P%H5gpgbVoqYm943us)Gc=TBrnAJnW)ZJ8T(6S1v<;7WzZy!gnUY|s~$>p zxcK#c1w-wrwSxbUzm@A7rm5Dgk0kfdxND}jlND;>c4Onx&c~y5wh&H>^{hB>_pE_do z{uI!nx+ojfBSvXm9_VZiUPb<(x4Ykt*))n%)aZA7>B=@Qb+BcSf!|WBS{o=Lcg~I1 zeH8DFx6L+GQVctwBpA5j6ijS}Sq6Xmn{TGOTbt#k*R(WMs+O)A^LQerdhLiy{?Wwz z?X(i240|&ouuXVbw1yIT~1J*Wdkb?;YvQ5Weu35}wLKdfM+ zqB>*s5LfR#+O1FQHcc7}XA`j}uDGzW`t{#?hw!iv-|)9i>wk`u478jhK!QvLaKQ2ows9MOlYAK!g~TDpR+;PvH=93;`(-{5EH*XQ*w&(N)I;|w zNR=Y+qDzXWQoqw^z*5*1IWnk=ONyUE;UC_^0p{@29@{fP9rMhXN{`Ho9!j#DS`@%k4F9+khuO)i TZKnCCnfbVf&9oPI{HWT$N{yS1 diff --git a/azure-management/src/test/resources/capturerolepayload.xml b/azure-management/src/test/resources/capturerolepayload.xml deleted file mode 100644 index 9414c52..0000000 --- a/azure-management/src/test/resources/capturerolepayload.xml +++ /dev/null @@ -1 +0,0 @@ -CaptureRoleOperationDeletemyImageLabelmyImageName \ No newline at end of file diff --git a/azure-management/src/test/resources/create_hostedservice_location.xml b/azure-management/src/test/resources/create_hostedservice_location.xml deleted file mode 100644 index 076f562..0000000 --- a/azure-management/src/test/resources/create_hostedservice_location.xml +++ /dev/null @@ -1 +0,0 @@ -myserviceWest US \ No newline at end of file diff --git a/azure-management/src/test/resources/create_hostedservice_location_options.xml b/azure-management/src/test/resources/create_hostedservice_location_options.xml deleted file mode 100644 index 9f7f8f0..0000000 --- a/azure-management/src/test/resources/create_hostedservice_location_options.xml +++ /dev/null @@ -1 +0,0 @@ -myservicemy descriptionWest USRoleProduction \ No newline at end of file diff --git a/azure-management/src/test/resources/deployment.xml b/azure-management/src/test/resources/deployment.xml deleted file mode 100644 index 94cebc9..0000000 --- a/azure-management/src/test/resources/deployment.xml +++ /dev/null @@ -1,70 +0,0 @@ - - neotysss - Production - 05aa8ec5d8ee4215894431c7db401b31 - Running - - http://neotysss.cloudapp.net/ - PFNlcnZpY2VDb25maWd1cmF0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL1NlcnZpY2VIb3N0aW5nLzIwMDgvMTAvU2VydmljZUNvbmZpZ3VyYXRpb24iPg0KICA8Um9sZSBuYW1lPSJuZW90eXNzcyI+DQogICAgPEluc3RhbmNlcyBjb3VudD0iMSIgLz4NCiAgPC9Sb2xlPg0KPC9TZXJ2aWNlQ29uZmlndXJhdGlvbj4= - - - neotysss - neotysss - ReadyRole - 0 - 0 - Medium - - 10.59.244.162 - - - SSH - 168.63.27.148 - 22 - 22 - tcp - - - Started - neotys - - - 1 - - - neotysss - - PersistentVMRole - - - NetworkConfiguration - - - 22 - SSH - 22 - tcp - 168.63.27.148 - - - - - - - - ReadWrite - neotysss-neotysss-0-20120824091357 - http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/neotysss/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd - MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd - Windows - - Medium - - - - false - false - 2012-08-24T09:13:53Z - 2012-08-27T08:55:13Z - - \ No newline at end of file diff --git a/azure-management/src/test/resources/deploymentparams.xml b/azure-management/src/test/resources/deploymentparams.xml deleted file mode 100644 index fadaff1..0000000 --- a/azure-management/src/test/resources/deploymentparams.xml +++ /dev/null @@ -1 +0,0 @@ -mydeploymentProductionmydeploymentPersistentVMRoleLinuxProvisioningConfigurationmydeploymentusernametestpwdfalseNetworkConfigurationReadWritehttp://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhdOpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhdLinuxMedium \ No newline at end of file diff --git a/azure-management/src/test/resources/disks.xml b/azure-management/src/test/resources/disks.xml deleted file mode 100644 index 9290a9a..0000000 --- a/azure-management/src/test/resources/disks.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - Linux - West Europe - 30 - http://neotysbucket1.blob.core.windows.net/vhds/testimage2-testimage2-2012-08-17.vhd - testimage2-testimage2-0-20120817095145 - OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd - - - - neotysss - neotysss - neotysss - - Windows - West Europe - 30 - http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/neotysss/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd - neotysss-neotysss-0-20120824091357 - MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd - - diff --git a/azure-management/src/test/resources/error.xml b/azure-management/src/test/resources/error.xml deleted file mode 100644 index a9f9b2f..0000000 --- a/azure-management/src/test/resources/error.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - MissingOrInvalidRequiredQueryParameter - A required query parameter was not specified for this request or was specified incorrectly. - \ No newline at end of file diff --git a/azure-management/src/test/resources/hostedservice.xml b/azure-management/src/test/resources/hostedservice.xml deleted file mode 100644 index 625aeb3..0000000 --- a/azure-management/src/test/resources/hostedservice.xml +++ /dev/null @@ -1,10 +0,0 @@ - - https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys - neotys - - Implicitly created hosted service2012-08-06 14:55 - - West Europe - - - \ No newline at end of file diff --git a/azure-management/src/test/resources/hostedservice_details.xml b/azure-management/src/test/resources/hostedservice_details.xml deleted file mode 100644 index d730cc7..0000000 --- a/azure-management/src/test/resources/hostedservice_details.xml +++ /dev/null @@ -1,13 +0,0 @@ - - https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys - neotys - - Implicitly created hosted service2012-08-06 14:55 - West Europe - - Created - 2012-08-06T14:55:17Z - 2012-08-06T15:50:34Z - - - \ No newline at end of file diff --git a/azure-management/src/test/resources/hostedservices.xml b/azure-management/src/test/resources/hostedservices.xml deleted file mode 100644 index 66b7589..0000000 --- a/azure-management/src/test/resources/hostedservices.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys - neotys - - Implicitly created hosted service2012-08-06 14:55 - West Europe - - Created - 2012-08-06T14:55:17Z - 2012-08-06T15:50:34Z - - - - - https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys3 - neotys3 - - - West Europe - - Created - 2012-08-07T09:00:02Z - 2012-08-07T09:00:02Z - - - - \ No newline at end of file diff --git a/azure-management/src/test/resources/imageparams.xml b/azure-management/src/test/resources/imageparams.xml deleted file mode 100644 index d3279ba..0000000 --- a/azure-management/src/test/resources/imageparams.xml +++ /dev/null @@ -1 +0,0 @@ -http://example.blob.core.windows.net/disks/mydisk.vhdmyimageLinux \ No newline at end of file diff --git a/azure-management/src/test/resources/images.xml b/azure-management/src/test/resources/images.xml deleted file mode 100644 index aa6efca..0000000 --- a/azure-management/src/test/resources/images.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - Canonical - - 30 - CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd - Linux - http://www.ubuntu.com/project/about-ubuntu/licensing - Ubuntu Server 12.04 LTS amd64 20120528 Cloud Image - - - Microsoft - - 30 - MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd - Windows - - Windows Server 2008 R2 is a multi-purpose server. - - - Microsoft - - 30 - MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd - Windows - http://go.microsoft.com/fwlink/?LinkID=251820;http://go.microsoft.com/fwlink/?LinkID=131004 - SQL Server 2012 Evaluation Edition (64-bit). - - - Microsoft - - 30 - MSFT__Win2K12RC-Datacenter-201207.02-en.us-30GB.vhd - Windows - - Windows Server 2012 incorporates Microsoft's experience building. - - - Microsoft - - 30 - MSFT__Win2K8R2SP1-Datacenter-201207.01-en.us-30GB.vhd - Windows - - Windows Server 2008 R2 is a multi-purpose server. - - - OpenLogic - - 30 - OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd - Linux - http://www.openlogic.com/azure/service-agreement/ - This distribution of Linux is based on CentOS. - - - SUSE - - 30 - SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd - Linux - http://opensuse.org/ - openSUSE is a free and Linux-based operating system! - - - SUSE - - 30 - SUSE__SUSE-Linux-Enterprise-Server-11SP2-20120601-en-us-30GB.vhd - Linux - http://www.novell.com/licensing/eula/ - SUSE Linux Enterprise Server is a highly reliable value. - - \ No newline at end of file diff --git a/azure-management/src/test/resources/locations.xml b/azure-management/src/test/resources/locations.xml deleted file mode 100644 index 1c7dcc8..0000000 --- a/azure-management/src/test/resources/locations.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - West US - West US - - Compute - Storage - PersistentVMRole - - - - East US - East US - - Compute - Storage - PersistentVMRole - - - - East Asia - East Asia - - Compute - Storage - PersistentVMRole - - - - Southeast Asia - Southeast Asia - - Compute - Storage - PersistentVMRole - - - - North Europe - North Europe - - Compute - Storage - PersistentVMRole - - - - West Europe - West Europe - - Compute - Storage - PersistentVMRole - - - \ No newline at end of file diff --git a/azure-management/src/test/resources/operation.xml b/azure-management/src/test/resources/operation.xml deleted file mode 100644 index 498d1f0..0000000 --- a/azure-management/src/test/resources/operation.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - request-id - Failed - 400 - - MissingOrInvalidRequiredQueryParameter - A required query parameter was not specified for this request or was specified incorrectly. - - diff --git a/azure-management/src/test/resources/restartrolepayload.xml b/azure-management/src/test/resources/restartrolepayload.xml deleted file mode 100644 index 4eca508..0000000 --- a/azure-management/src/test/resources/restartrolepayload.xml +++ /dev/null @@ -1 +0,0 @@ -RestartRoleOperation \ No newline at end of file diff --git a/azure-management/src/test/resources/shutdownrolepayload.xml b/azure-management/src/test/resources/shutdownrolepayload.xml deleted file mode 100644 index 27beee8..0000000 --- a/azure-management/src/test/resources/shutdownrolepayload.xml +++ /dev/null @@ -1 +0,0 @@ -ShutdownRoleOperation \ No newline at end of file diff --git a/azure-management/src/test/resources/startrolepayload.xml b/azure-management/src/test/resources/startrolepayload.xml deleted file mode 100644 index 4e82022..0000000 --- a/azure-management/src/test/resources/startrolepayload.xml +++ /dev/null @@ -1 +0,0 @@ -StartRoleOperation \ No newline at end of file diff --git a/azurecompute/.gitignore b/azurecompute/.gitignore new file mode 100644 index 0000000..8fb7bef --- /dev/null +++ b/azurecompute/.gitignore @@ -0,0 +1,9 @@ +# use glob syntax. +syntax: glob +target +.settings +.classpath +.project +jclouds-azurecompute.iml +jclouds-azurecompute.ipr +jclouds-azurecompute.iws diff --git a/azurecompute/README.md b/azurecompute/README.md new file mode 100644 index 0000000..022abde --- /dev/null +++ b/azurecompute/README.md @@ -0,0 +1,23 @@ + +=== Setting up test credentials + +Azure requests are signed by via SSL certificate. You need to upload one into your account in order to run tests. + +```bash +# create the certificate request +mkdir -m 700 $HOME/.jclouds +openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout $HOME/.jclouds/azure.pem -out $HOME/.jclouds/azure.pem +# create the p12 file, and note your export password. This will be your test credentials. +openssl pkcs12 -export -out $HOME/.jclouds/azure.p12 -in $HOME/.jclouds/azure.pem -name "jclouds :: $USER" +# create a cer file which you upload to the management console to authorize this certificate. +# https://manage.windowsazure.com/@ignasibarreragmail.onmicrosoft.com#Workspaces/AdminTasks/ListManagementCertificates +# note you need to press command+shift+. to display hidden directories in a open dialog in osx +openssl x509 -inform pem -in $HOME/.jclouds/azure.p12 -outform der -out $HOME/.jclouds/azure.cer +``` + +Once you do this, you will set the following to run the live tests. +```bash +mvn -Plive -Dtest.jclouds.azurecompute.subscription-id=12345678-abcd-dcba-abdc-ba0987654321 +-Dtest.azurecompute.credential=P12_EXPORT_PASSWORD +-Dtest.azurecompute.identity=$HOME/.jclouds/azure.p12 +``` \ No newline at end of file diff --git a/azurecompute/pom.xml b/azurecompute/pom.xml new file mode 100644 index 0000000..c0be3fc --- /dev/null +++ b/azurecompute/pom.xml @@ -0,0 +1,151 @@ + + + + 4.0.0 + + org.apache.jclouds + jclouds-project + 2.0.0-SNAPSHOT + + + + + org.apache.jclouds.labs + azurecompute + 2.0.0-SNAPSHOT + Apache jclouds :: Azure :: Compute API + jclouds components to access an implementation of Azure's Compute Service + bundle + + + FIXME_subscription-id + + https://management.core.windows.net/${jclouds.azurecompute.subscription-id} + 2012-03-01 + + /path/to/cert.p12 + password to cert + org.jclouds.azure.management*;version="${project.version}" + org.jclouds*;version="${project.version}",* + + + + + apache-snapshots + https://repository.apache.org/content/repositories/snapshots + + false + + + true + + + + + + + com.jamesmurty.utils + java-xmlbuilder + 1.1 + + + org.apache.jclouds + jclouds-compute + ${project.parent.version} + + + org.apache.jclouds + jclouds-compute + ${project.parent.version} + test-jar + test + + + org.apache.jclouds + jclouds-core + ${project.parent.version} + test-jar + test + + + org.apache.jclouds.driver + jclouds-slf4j + ${project.parent.version} + test + + + org.apache.jclouds.driver + jclouds-sshj + ${project.parent.version} + test + + + ch.qos.logback + logback-classic + test + + + com.squareup.okhttp + mockwebserver + test + + + + org.bouncycastle + bcprov-jdk15on + + + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + ${test.azurecompute.endpoint} + ${test.azurecompute.api-version} + ${test.azurecompute.build-version} + ${test.azurecompute.identity} + ${test.azurecompute.credential} + ${test.jclouds.azurecompute.subscription-id} + + + + + + + + + + + diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java new file mode 100644 index 0000000..7dc946b --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute; + +import java.io.Closeable; +import javax.ws.rs.PathParam; +import org.jclouds.azurecompute.features.DeploymentApi; +import org.jclouds.azurecompute.features.DiskApi; +import org.jclouds.azurecompute.features.HostedServiceApi; +import org.jclouds.azurecompute.features.ImageApi; +import org.jclouds.azurecompute.features.LocationApi; +import org.jclouds.azurecompute.features.OperationApi; +import org.jclouds.azurecompute.features.VirtualMachineApi; +import org.jclouds.rest.annotations.Delegate; + +/** + * The Windows Azure Service Management API is a REST API for managing your services and + * deployments. + *

+ * + * @see doc + */ +public interface AzureComputeApi extends Closeable { + /** + * The Service Management API includes operations for listing the available data center locations + * for a hosted service in your subscription. + * + * @see docs + */ + @Delegate + LocationApi getLocationApi(); + + /** + * The Service Management API includes operations for managing the hosted services beneath your + * subscription. + * + * @see docs + */ + @Delegate + HostedServiceApi getHostedServiceApi(); + + /** + * The Service Management API includes operations for managing the virtual machines in your + * subscription. + * + * @see docs + */ + @Delegate + DeploymentApi getDeploymentApiForService(@PathParam("serviceName") String serviceName); + + /** + * The Service Management API includes operations for managing the virtual machines in your + * subscription. + * + * @see docs + */ + // TODO: revisit once we have multi-level @Delegate working + @Delegate + VirtualMachineApi getVirtualMachineApiForDeploymentInService(@PathParam("deploymentName") String deploymentName, + @PathParam("serviceName") String serviceName); + + /** + * The Service Management API includes operations for managing the OS images in your + * subscription. + * + * @see docs + */ + @Delegate + ImageApi getImageApi(); + + /** + * The Service Management API includes operations for Tracking Asynchronous Service Management + * Requests. + * + * @see docs + */ + @Delegate + OperationApi getOperationApi(); + + /** + * The Service Management API includes operations for managing Disks in your subscription. + * + * @see docs + */ + @Delegate + DiskApi getDiskApi(); +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeProviderMetadata.java b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeProviderMetadata.java new file mode 100644 index 0000000..8fcb560 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeProviderMetadata.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute; + +import java.net.URI; +import java.util.Properties; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; + +import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID; + +/** + * Implementation of {@link ProviderMetadata} for Microsoft Azure Service Management Service. + */ +public class AzureComputeProviderMetadata extends BaseProviderMetadata { + + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public AzureComputeProviderMetadata() { + super(builder()); + } + + public AzureComputeProviderMetadata(Builder builder) { + super(builder); + } + + public static Properties defaultProperties() { + Properties properties = new Properties(); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder { + + protected Builder() { + id("azurecompute") + .name("Microsoft Azure Service Management Service") + .apiMetadata(new AzureManagementApiMetadata()) + .endpoint("https://management.core.windows.net/${" + SUBSCRIPTION_ID + "}") + .homepage(URI.create("https://www.windowsazure.com/")) + .console(URI.create("https://windows.azure.com/default.aspx")) + .linkedServices("azureblob", "azurequeue", "azuretable") + .iso3166Codes("US-TX", "US-IL", "IE-D", "SG", "NL-NH", "HK") + .defaultProperties(AzureComputeProviderMetadata.defaultProperties()); + } + + @Override + public AzureComputeProviderMetadata build() { + return new AzureComputeProviderMetadata(this); + } + + @Override + public Builder fromProviderMetadata(ProviderMetadata in) { + super.fromProviderMetadata(in); + return this; + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java new file mode 100644 index 0000000..e941dfa --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureManagementApiMetadata.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; +import java.net.URI; +import java.util.Properties; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.azurecompute.compute.config.AzureComputeServiceContextModule; +import org.jclouds.azurecompute.config.AzureComputeHttpApiModule; +import org.jclouds.rest.internal.BaseHttpApiMetadata; + +import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID; + +/** + * Implementation of {@link ApiMetadata} for Microsoft Service Management Service API + */ +public class AzureManagementApiMetadata extends BaseHttpApiMetadata { + + @Override + public Builder toBuilder() { + return new Builder().fromApiMetadata(this); + } + + public AzureManagementApiMetadata() { + this(new Builder()); + } + + protected AzureManagementApiMetadata(Builder builder) { + super(builder); + } + + public static Properties defaultProperties() { + Properties properties = BaseHttpApiMetadata.defaultProperties(); + return properties; + } + + public static class Builder extends BaseHttpApiMetadata.Builder { + + protected Builder() { + id("azurecompute") + .name("Microsoft Azure Service Management Service API") + .version("2012-03-01") + .identityName("Path to Management Certificate .p12 file, or PEM string") + .credentialName("Password to Management Certificate") + .defaultEndpoint("https://management.core.windows.net/${" + SUBSCRIPTION_ID + "}") + .endpointName("Service Management Endpoint ending in your Subscription Id") + .documentation(URI.create("http://msdn.microsoft.com/en-us/library/ee460799")) + .defaultProperties(AzureManagementApiMetadata.defaultProperties()) + .defaultModules(ImmutableSet.>builder() + .add(AzureComputeServiceContextModule.class) + .add(AzureComputeHttpApiModule.class).build()); + } + + @Override + public AzureManagementApiMetadata build() { + return new AzureManagementApiMetadata(this); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindCreateHostedServiceToXmlPayload.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindCreateHostedServiceToXmlPayload.java new file mode 100644 index 0000000..900c9a7 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindCreateHostedServiceToXmlPayload.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.binders; + +import com.google.common.base.Optional; +import com.google.common.base.Throwables; +import com.jamesmurty.utils.XMLBuilder; +import java.util.Map; +import java.util.Map.Entry; +import javax.inject.Singleton; +import org.jclouds.azurecompute.options.CreateHostedServiceOptions; +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.MapBinder; + +import static com.google.common.base.Charsets.UTF_8; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.io.BaseEncoding.base64; + +@Singleton +public class BindCreateHostedServiceToXmlPayload implements MapBinder { + + private static final CreateHostedServiceOptions NO_OPTIONS = new CreateHostedServiceOptions(); + + @Override + public R bindToRequest(R request, Map postParams) { + String serviceName = checkNotNull(postParams.get("name"), "name").toString(); + String label = base64().encode(checkNotNull(postParams.get("label"), "label").toString().getBytes(UTF_8)); + + Optional location = Optional.fromNullable((String) postParams.get("location")); + Optional affinityGroup = Optional.fromNullable((String) postParams.get("affinityGroup")); + CreateHostedServiceOptions options = Optional + .fromNullable((CreateHostedServiceOptions) postParams.get("options")).or(NO_OPTIONS); + try { + XMLBuilder createHostedService = XMLBuilder.create("CreateHostedService") + .a("xmlns", "http://schemas.microsoft.com/windowsazure").e("ServiceName").t(serviceName).up() + .e("Label").t(label).up(); + + if (options.getDescription().isPresent()) + createHostedService.e("Description").t(options.getDescription().get()).up(); + + if (location.isPresent()) + createHostedService.e("Location").t(location.get()).up(); + else if (affinityGroup.isPresent()) + createHostedService.e("AffinityGroup").t(affinityGroup.get()).up(); + else + throw new IllegalArgumentException("you must specify either Location or AffinityGroup!"); + + if (options.getExtendedProperties().isPresent() && options.getExtendedProperties().get().size() > 0) { + XMLBuilder extendedProperties = createHostedService.e("ExtendedProperties"); + for (Entry entry : options.getExtendedProperties().get().entrySet()) + extendedProperties.e("ExtendedProperty").e("Name").t(entry.getKey()).up().e("Value").t(entry.getValue()); + } + return (R) request.toBuilder().payload(createHostedService.asString()).build(); + } catch (Exception e) { + throw Throwables.propagate(e); + } + + } + + @Override + public R bindToRequest(R request, Object input) { + throw new IllegalStateException("BindCreateHostedServiceToXmlPayload is needs parameters"); + } + +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java new file mode 100644 index 0000000..1b36209 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindDeploymentParamsToXmlPayload.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.binders; + +import com.google.common.base.Throwables; +import com.jamesmurty.utils.XMLBuilder; +import javax.inject.Singleton; +import org.jclouds.azurecompute.domain.DeploymentParams; +import org.jclouds.azurecompute.domain.InputEndpoint; +import org.jclouds.azurecompute.domain.OSType; +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.Binder; + +@Singleton +public class BindDeploymentParamsToXmlPayload implements Binder { + + @Override + public R bindToRequest(R request, Object input) { + DeploymentParams params = DeploymentParams.class.cast(input); + try { + XMLBuilder builder = XMLBuilder.create("Deployment").a("xmlns", "http://schemas.microsoft.com/windowsazure") + .e("Name").t(params.getName()).up() + .e("DeploymentSlot").t("Production").up() + .e("Label").t(params.getName()).up() + .e("RoleList") + .e("Role") + .e("RoleName").t(params.getName()).up() + .e("RoleType").t("PersistentVMRole").up() + .e("ConfigurationSets"); + + if (params.getOsType() == OSType.WINDOWS) { + XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Windows + configBuilder.e("ConfigurationSetType").t("WindowsProvisioningConfiguration").up() + .e("ComputerName").t(params.getUsername()).up() + .e("AdminPassword").t(params.getPassword()).up() + .e("ResetPasswordOnFirstLogon").t("false").up() + .e("EnableAutomaticUpdate").t("false").up() + .e("DomainJoin") + .e("Credentials") + .e("Domain").t(params.getName()).up() + .e("Username").t(params.getUsername()).up() + .e("Password").t(params.getPassword()).up() + .up() // Credentials + .e("JoinDomain").t(params.getName()).up() + .up() // Domain Join + .e("StoredCertificateSettings").up() + .up(); // Windows ConfigurationSet + } else if (params.getOsType() == OSType.LINUX) { + XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Linux + configBuilder.e("ConfigurationSetType").t("LinuxProvisioningConfiguration").up() + .e("HostName").t(params.getName()).up() + .e("UserName").t(params.getUsername()).up() + .e("UserPassword").t(params.getPassword()).up() + .e("DisableSshPasswordAuthentication").t("false").up() + .e("SSH").up() + .up(); // Linux ConfigurationSet + } + + XMLBuilder configBuilder = builder.e("ConfigurationSet"); // Network + configBuilder.e("ConfigurationSetType").t("NetworkConfiguration").up(); + + XMLBuilder inputEndpoints = configBuilder.e("InputEndpoints"); + for (InputEndpoint endpoint : params.getEndpoints()) { + XMLBuilder inputBuilder = inputEndpoints.e("InputEndpoint"); + inputBuilder.e("LocalPort").t(endpoint.getLocalPort().toString()).up() + .e("Name").t(endpoint.getName()).up() + .e("Port").t(endpoint.getExternalPort().toString()).up() + .e("Protocol").t(endpoint.getProtocol().name()).up() + .up(); //InputEndpoint + } + + inputEndpoints.up(); + configBuilder.e("SubnetNames").up() + .up(); + + builder.up() //ConfigurationSets + .e("DataVirtualHardDisks").up() + .e("OSVirtualHardDisk") + .e("HostCaching").t("ReadWrite").up() + .e("MediaLink").t(url(params)).up() + .e("SourceImageName").t(params.getSourceImageName()).up() + .e("OS").t("Linux").up() + .up() //OSVirtualHardDisk + .e("RoleSize").t(params.getSize().value()).up() + .up() //Role + .up(); //RoleList + + return (R) request.toBuilder().payload(builder.asString()).build(); + } catch (Exception e) { + throw Throwables.propagate(e); + } + } + + private static String url(DeploymentParams params) { + return String.format("http://%s.blob.core.windows.net/disks/%s/%s", params.getStorageAccount(), params.getName(), + params.getSourceImageName()); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindOSImageParamsToXmlPayload.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindOSImageParamsToXmlPayload.java new file mode 100644 index 0000000..bbe0459 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/BindOSImageParamsToXmlPayload.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.binders; + +import com.google.common.base.Throwables; +import com.jamesmurty.utils.XMLBuilder; +import javax.inject.Singleton; +import org.jclouds.azurecompute.domain.ImageParams; +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.Binder; + +@Singleton +public class BindOSImageParamsToXmlPayload implements Binder { + + + @Override + public R bindToRequest(R request, Object input) { + ImageParams params = ImageParams.class.cast(input); + try { + return (R) request.toBuilder().payload(XMLBuilder.create("OSImage").a("xmlns", "http://schemas.microsoft.com/windowsazure") + .e("Label").t(params.getLabel()).up() + .e("MediaLink").t(params.getMediaLink().toASCIIString()).up() + .e("Name").t(params.getName()).up() + .e("OS").t(params.getOS().toString()).up() + .up().asString()).build(); + } catch (Exception e) { + throw Throwables.propagate(e); + } + + } + +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/AzureComputeServiceAdapter.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/AzureComputeServiceAdapter.java new file mode 100644 index 0000000..4ce0ee4 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/AzureComputeServiceAdapter.java @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.compute; + +import javax.inject.Singleton; +import org.jclouds.azurecompute.AzureComputeApi; +import org.jclouds.azurecompute.domain.Deployment; +import org.jclouds.azurecompute.domain.Image; +import org.jclouds.azurecompute.domain.RoleSize; +import org.jclouds.compute.ComputeServiceAdapter; +import org.jclouds.compute.domain.Template; + +/** + * defines the connection between the {@link AzureComputeApi} implementation and the + * jclouds {@link org.jclouds.compute.ComputeService} + */ +@Singleton +public class AzureComputeServiceAdapter implements ComputeServiceAdapter { + + @Override + public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName( + String group, String name, Template template) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Iterable listHardwareProfiles() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Iterable listImages() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Image getImage(String id) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Iterable listLocations() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Deployment getNode(String id) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void destroyNode(String id) { + // TODO Auto-generated method stub + + } + + @Override + public void rebootNode(String id) { + // TODO Auto-generated method stub + } + + @Override + public void resumeNode(String id) { + // TODO Auto-generated method stub + } + + @Override + public void suspendNode(String id) { + // TODO Auto-generated method stub + + } + + @Override + public Iterable listNodes() { + // TODO Auto-generated method stub + return null; + } + + @Override public Iterable listNodesByIds(Iterable ids) { + // TODO Auto-generated method stub + return null; + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/config/AzureComputeServiceContextModule.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/config/AzureComputeServiceContextModule.java new file mode 100644 index 0000000..2edd8a0 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/config/AzureComputeServiceContextModule.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.compute.config; + +import com.google.common.base.Function; +import com.google.inject.TypeLiteral; +import org.jclouds.azurecompute.compute.AzureComputeServiceAdapter; +import org.jclouds.azurecompute.compute.functions.AzureImageToImage; +import org.jclouds.azurecompute.compute.functions.DeploymentToNodeMetadata; +import org.jclouds.azurecompute.compute.functions.RoleSizeToHardware; +import org.jclouds.azurecompute.domain.Deployment; +import org.jclouds.azurecompute.domain.Image; +import org.jclouds.azurecompute.domain.RoleSize; +import org.jclouds.compute.ComputeServiceAdapter; +import org.jclouds.compute.config.ComputeServiceAdapterContextModule; +import org.jclouds.compute.domain.Hardware; +import org.jclouds.compute.domain.NodeMetadata; + +public class AzureComputeServiceContextModule + extends ComputeServiceAdapterContextModule { + + @Override + protected void configure() { + super.configure(); + bind(new TypeLiteral>() { + }).to(AzureComputeServiceAdapter.class); + bind(new TypeLiteral>() { + }).to(AzureImageToImage.class); + bind(new TypeLiteral>() { + }).to(RoleSizeToHardware.class); + bind(new TypeLiteral>() { + }).to(DeploymentToNodeMetadata.class); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/AzureImageToImage.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/AzureImageToImage.java new file mode 100644 index 0000000..4da1c34 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/AzureImageToImage.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.compute.functions; + +import com.google.common.base.Function; +import org.jclouds.azurecompute.domain.Image; + +public class AzureImageToImage implements Function { + + @Override + public org.jclouds.compute.domain.Image apply(Image input) { + return null; + } + +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java new file mode 100644 index 0000000..7e02ee6 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/DeploymentToNodeMetadata.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.compute.functions; + +import com.google.common.base.Function; +import org.jclouds.azurecompute.domain.Deployment; +import org.jclouds.compute.domain.NodeMetadata; + +public class DeploymentToNodeMetadata implements Function { + + @Override + public NodeMetadata apply(Deployment input) { + return null; + } + +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/RoleSizeToHardware.java b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/RoleSizeToHardware.java new file mode 100644 index 0000000..09dbf78 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/compute/functions/RoleSizeToHardware.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.compute.functions; + +import com.google.common.base.Function; +import org.jclouds.azurecompute.domain.RoleSize; +import org.jclouds.compute.domain.Hardware; + +public class RoleSizeToHardware implements Function { + + @Override + public Hardware apply(RoleSize input) { + return null; + } + +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java b/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java new file mode 100644 index 0000000..8c85c0a --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeHttpApiModule.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.config; + +import com.google.common.base.Supplier; +import com.google.inject.TypeLiteral; +import java.security.KeyStore; +import javax.net.ssl.SSLContext; +import org.jclouds.azurecompute.AzureComputeApi; +import org.jclouds.azurecompute.suppliers.KeyStoreSupplier; +import org.jclouds.azurecompute.suppliers.SSLContextWithKeysSupplier; +import org.jclouds.rest.ConfiguresHttpApi; +import org.jclouds.rest.config.HttpApiModule; + +@ConfiguresHttpApi +public class AzureComputeHttpApiModule extends HttpApiModule { + @Override + protected void configure() { + super.configure(); + bind(new TypeLiteral>() { + }).to(new TypeLiteral() { + }); + bind(new TypeLiteral>() { + }).to(new TypeLiteral() { + }); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeProperties.java b/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeProperties.java new file mode 100644 index 0000000..0981c7c --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/config/AzureComputeProperties.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.config; + +/** + * Configuration properties and constants used in Azure Service Management + * connections. + */ +public class AzureComputeProperties { + /** + * Every call to the Service Management API must include the subscription ID + * for your subscription. The subscription ID is appended to the base URI, + * as follows: + * + *

+	 * https://management.core.windows.net/${subscriptionId}
+	 * 
+ * + * @see docs + */ + public static final String SUBSCRIPTION_ID = "jclouds.azurecompute.subscription-id"; +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java new file mode 100644 index 0000000..6bd179b --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Deployment.java @@ -0,0 +1,309 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import java.net.URI; + +public class Deployment { + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String deploymentName; + private DeploymentSlot deploymentSlot; + private DeploymentStatus deploymentStatus; + private String deploymentLabel; + private URI deploymentURL; + private String roleName; + private String instanceName; + private InstanceStatus instanceStatus; + private String instanceStateDetails; + private String instanceErrorCode; + private RoleSize instanceSize; + private String privateIpAddress; + private String publicIpAddress; + + public Builder deploymentName(final String deploymentName) { + this.deploymentName = deploymentName; + return this; + } + + public Builder deploymentSlot(final DeploymentSlot deploymentSlot) { + this.deploymentSlot = deploymentSlot; + return this; + } + + public Builder deploymentStatus(final DeploymentStatus deploymentStatus) { + this.deploymentStatus = deploymentStatus; + return this; + } + + public Builder deploymentLabel(final String deploymentLabel) { + this.deploymentLabel = deploymentLabel; + return this; + } + + public Builder deploymentURL(final URI deploymentURL) { + this.deploymentURL = deploymentURL; + return this; + } + + public Builder instanceSize(final RoleSize instanceSize) { + this.instanceSize = instanceSize; + return this; + } + + public Builder instanceName(final String instanceName) { + this.instanceName = instanceName; + return this; + } + + public Builder instanceStatus(final InstanceStatus instanceStatus) { + this.instanceStatus = instanceStatus; + return this; + } + + public Builder instanceStateDetails(final String instanceStateDetails) { + this.instanceStateDetails = instanceStateDetails; + return this; + } + + public Builder instanceErrorCode(final String instanceErrorCode) { + this.instanceErrorCode = instanceErrorCode; + return this; + } + + public Builder privateIpAddress(final String privateIpAddress) { + this.privateIpAddress = privateIpAddress; + return this; + } + + public Builder publicIpAddress(final String publicIpAddress) { + this.publicIpAddress = publicIpAddress; + return this; + } + + public Builder roleName(final String roleName) { + this.roleName = roleName; + return this; + } + + public Deployment build() { + return new Deployment(deploymentName, deploymentSlot, deploymentStatus, deploymentLabel, deploymentURL, + roleName, instanceName, instanceStatus, instanceStateDetails, instanceErrorCode, instanceSize, + privateIpAddress, publicIpAddress); + } + + } + + /** + * The user-supplied name for this deployment. + */ + private final String deploymentName; + + /** + * The environment to which the hosted service is deployed, either staging + * or production. + */ + private final DeploymentSlot deploymentSlot; + + /** + * The status of the deployment. + */ + private final DeploymentStatus deploymentStatus; + + /** + * The user-supplied name of the deployment returned as a base-64 encoded + * string. This name can be used identify the deployment for your tracking + * purposes. + */ + private final String deploymentLabel; + + /** + * The URL used to access the hosted service. For example, if the service + * name is MyService you could access the access the service by calling: + * http://MyService.cloudapp.net + */ + private final URI deploymentURL; + + /** + * Specifies the name for the virtual machine. The name must be unique + * within Windows Azure. + */ + private final String roleName; + + /** + * The name of the specific role instance (if any). + */ + private final String instanceName; + + /** + * The current status of this instance. + */ + private final InstanceStatus instanceStatus; + + /** + * The instance state is returned as an English human-readable string that, + * when present, provides a snapshot of the state of the virtual machine at + * the time the operation was called. + * + * For example, when the instance is first being initialized a + * "Preparing Windows for first use." could be returned. + */ + private final String instanceStateDetails; + + /** + * Error code of the latest role or VM start + * + * For VMRoles the error codes are: + * + * WaitTimeout - The virtual machine did not communicate back to Azure + * infrastructure within 25 minutes. Typically this indicates that the + * virtual machine did not start or that the guest agent is not installed. + * + * VhdTooLarge - The VHD image selected was too large for the virtual + * machine hosting the role. + * + * AzureInternalError – An internal error has occurred that has caused to + * virtual machine to fail to start. Contact support for additional + * assistance. + * + * For web and worker roles this field returns an error code that can be provided to Windows Azure support to assist + * in resolution of errors. Typically this field will be empty. + */ + private final String instanceErrorCode; + + /** + * The size of the role instance + */ + private final RoleSize instanceSize; + private final String privateIpAddress; + private final String publicIpAddress; + + public Deployment(String deploymentName, DeploymentSlot deploymentSlot, DeploymentStatus deploymentStatus, + String deploymentLabel, URI deploymentURL, String roleName, String instanceName, InstanceStatus instanceStatus, + String instanceStateDetails, String instanceErrorCode, RoleSize instanceSize, String privateIpAddress, + String publicIpAddress) { + this.deploymentName = deploymentName; + this.deploymentSlot = deploymentSlot; + this.deploymentStatus = deploymentStatus; + this.deploymentLabel = deploymentLabel; + this.deploymentURL = deploymentURL; + this.roleName = roleName; + this.instanceName = instanceName; + this.instanceStatus = instanceStatus; + this.instanceStateDetails = instanceStateDetails; + this.instanceErrorCode = instanceErrorCode; + this.instanceSize = instanceSize; + this.privateIpAddress = privateIpAddress; + this.publicIpAddress = publicIpAddress; + } + + public String getDeploymentName() { + return deploymentName; + } + + public DeploymentSlot getDeploymentSlot() { + return deploymentSlot; + } + + public DeploymentStatus getDeploymentStatus() { + return deploymentStatus; + } + + public String getDeploymentLabel() { + return deploymentLabel; + } + + public URI getDeploymentURL() { + return deploymentURL; + } + + public String getRoleName() { + return roleName; + } + + public String getInstanceName() { + return instanceName; + } + + public InstanceStatus getInstanceStatus() { + return instanceStatus; + } + + public String getInstanceStateDetails() { + return instanceStateDetails; + } + + public String getInstanceErrorCode() { + return instanceErrorCode; + } + + public RoleSize getInstanceSize() { + return instanceSize; + } + + public String getPrivateIpAddress() { + return privateIpAddress; + } + + public String getPublicIpAddress() { + return publicIpAddress; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((deploymentName == null) ? 0 : deploymentName.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Deployment other = (Deployment) obj; + if (deploymentName == null) { + if (other.deploymentName != null) { + return false; + } + } else if (!deploymentName.equals(other.deploymentName)) { + return false; + } + return true; + } + + @Override + public String toString() { + return "Deployment [deploymentName=" + deploymentName + ", deploymentSlot=" + deploymentSlot + + ", deploymentStatus=" + deploymentStatus + ", deploymentLabel=" + deploymentLabel + ", deploymentURL=" + + deploymentURL + ", roleName=" + roleName + ", instanceName=" + instanceName + ", instanceStatus=" + + instanceStatus + ", instanceStateDetails=" + instanceStateDetails + ", instanceErrorCode=" + + instanceErrorCode + ", instanceSize=" + instanceSize + ", privateIpAddress=" + privateIpAddress + + ", publicIpAddress=" + publicIpAddress + "]"; + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java new file mode 100644 index 0000000..9ee4423 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentParams.java @@ -0,0 +1,208 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.base.Objects; +import com.google.common.collect.Lists; +import java.util.List; + +/** + * To create a new deployment/role + * + * Warning : the OSType must be the one of the source image used to create the VM + */ +public class DeploymentParams { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromDeploymentParams(this); + } + + public static class Builder { + + private String name; + private String sourceImageName; + private String username; + private String password; + private String storageAccount; + private OSType osType; + private RoleSize size = RoleSize.SMALL; + private List endpoints = Lists.newArrayList(); + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder sourceImageName(String sourceImageName) { + this.sourceImageName = sourceImageName; + return this; + } + + public Builder username(String username) { + this.username = username; + return this; + } + + public Builder password(String password) { + this.password = password; + return this; + } + + public Builder storageAccount(String storageAccount) { + this.storageAccount = storageAccount; + return this; + } + + public Builder size(RoleSize size) { + this.size = size; + return this; + } + + public Builder osType(OSType osType) { + this.osType = osType; + return this; + } + + public Builder endpoint(InputEndpoint endpoint) { + endpoints.add(endpoint); + return this; + } + + public DeploymentParams build() { + return new DeploymentParams(name, sourceImageName, username, password, storageAccount, size, osType, + endpoints); + } + + public Builder fromDeploymentParams(DeploymentParams in) { + // TODO Since the roleName should be unique, is it a good idea to copy it ? + return this.name(in.getName()).sourceImageName(in.getSourceImageName()).username(in.getUsername()) + .password(in.getPassword()).size(in.getSize()); + } + } + + private final String name; + private final String sourceImageName; + private final String username; + private final String password; + private final String storageAccount; + private final RoleSize size; + private final OSType osType; + private final List endpoints; + + public DeploymentParams(String name, String sourceImageName, String username, String password, String storageAccount, + RoleSize size, OSType osType, final List endpoints) { + this.name = name; + this.sourceImageName = sourceImageName; + this.username = username; + this.password = password; + this.storageAccount = storageAccount; + this.size = size; + this.osType = osType; + this.endpoints = endpoints; + } + + /** + * Specifies the name for the deployment and its virtual machine. The name must be unique + * within Windows Azure. + */ + public String getName() { + return name; + } + + /** + * Specifies the name of an operating system image in the image repository. + */ + public String getSourceImageName() { + return sourceImageName; + } + + /** + * Specifies the name of a user to be created in the sudoer group of the + * virtual machine. User names are ASCII character strings 1 to 32 + * characters in length. + */ + public String getUsername() { + return username; + } + + /** + * Specifies the associated password for the user name. + * PasswoazureManagement are ASCII character strings 6 to 72 characters in + * length. + */ + public String getPassword() { + return password; + } + + public String getStorageAccount() { + return storageAccount; + } + + /** + * The size of the virtual machine to allocate. The default value is Small. + */ + public RoleSize getSize() { + return size; + } + + /** + * Os type of the given sourceImage + */ + public OSType getOsType() { + return osType; + } + + public List getEndpoints() { + return endpoints; + } + + @Override + public int hashCode() { + return Objects.hashCode(name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + DeploymentParams other = (DeploymentParams) obj; + return Objects.equal(this.name, other.name); + } + + @Override + public String toString() { + return string().toString(); + } + + private ToStringHelper string() { + return MoreObjects.toStringHelper(this).add("name", name).add("sourceImageName", sourceImageName) + .add("size", size); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentSlot.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentSlot.java new file mode 100644 index 0000000..2e76b88 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentSlot.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.CaseFormat; + +import static com.google.common.base.Preconditions.checkNotNull; + +public enum DeploymentSlot { + PRODUCTION, STAGING; + + public String value() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); + } + + @Override + public String toString() { + return value(); + } + + public static DeploymentSlot fromValue(String type) { + try { + return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); + } catch (IllegalArgumentException e) { + return null; + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentStatus.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentStatus.java new file mode 100644 index 0000000..eb34aa5 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DeploymentStatus.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.CaseFormat; + +import static com.google.common.base.Preconditions.checkNotNull; + +public enum DeploymentStatus { + RUNNING, SUSPENDED, RUNNING_TRANSITIONING, SUSPENDED_TRANSITIONING, STARTING, SUSPENDING, DEPLOYING, DELETING; + + public String value() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); + } + + @Override + public String toString() { + return value(); + } + + public static DeploymentStatus fromValue(String type) { + try { + return valueOf(CaseFormat.UPPER_CAMEL.to( + CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); + } catch (IllegalArgumentException e) { + return null; + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DetailedHostedServiceProperties.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DetailedHostedServiceProperties.java new file mode 100644 index 0000000..f954fd0 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/DetailedHostedServiceProperties.java @@ -0,0 +1,173 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.base.Optional; +import com.google.common.collect.ImmutableMap; +import java.util.Date; +import java.util.Map; +import org.jclouds.azurecompute.domain.HostedService.Status; + +import static com.google.common.base.Preconditions.checkNotNull; + +public class DetailedHostedServiceProperties extends HostedServiceProperties { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromDetailedHostedServiceProperties(this); + } + + public static class Builder extends HostedServiceProperties.Builder { + + protected String rawStatus; + protected Status status; + protected Date created; + protected Date lastModified; + protected ImmutableMap.Builder extendedProperties = ImmutableMap.builder(); + + /** + * @see DetailedHostedServiceProperties#getRawStatus() + */ + public Builder rawStatus(String rawStatus) { + this.rawStatus = rawStatus; + return this; + } + + /** + * @see DetailedHostedServiceProperties#getStatus() + */ + public Builder status(Status status) { + this.status = status; + return this; + } + + /** + * @see DetailedHostedServiceProperties#getCreated() + */ + public Builder created(Date created) { + this.created = created; + return this; + } + + /** + * @see DetailedHostedServiceProperties#getLastModified() + */ + public Builder lastModified(Date lastModified) { + this.lastModified = lastModified; + return this; + } + + /** + * @see DetailedHostedServiceProperties#getExtendedProperties() + */ + public Builder extendedProperties(Map extendedProperties) { + this.extendedProperties.putAll(checkNotNull(extendedProperties, "extendedProperties")); + return this; + } + + /** + * @see DetailedHostedServiceProperties#getExtendedProperties() + */ + public Builder addExtendedProperty(String name, String value) { + this.extendedProperties.put(checkNotNull(name, "name"), checkNotNull(value, "value")); + return this; + } + + @Override protected Builder self() { + return this; + } + + public DetailedHostedServiceProperties build() { + return new DetailedHostedServiceProperties(description, location, affinityGroup, label, rawStatus, status, + created, lastModified, extendedProperties.build()); + } + + public Builder fromDetailedHostedServiceProperties(DetailedHostedServiceProperties in) { + return fromHostedServiceProperties(in).rawStatus(in.getRawStatus()).status(in.getStatus()) + .created(in.getCreated()).lastModified(in.getLastModified()) + .extendedProperties(in.getExtendedProperties()); + } + } + + protected final String rawStatus; + protected final Status status; + protected final Date created; + protected final Date lastModified; + protected final Map extendedProperties; + + protected DetailedHostedServiceProperties(Optional description, Optional location, + Optional affinityGroup, String label, String rawStatus, Status status, Date created, Date lastModified, + Map extendedProperties) { + super(description, location, affinityGroup, label); + this.rawStatus = checkNotNull(rawStatus, "rawStatus of %s", description); + this.status = checkNotNull(status, "status of %s", description); + this.created = checkNotNull(created, "created of %s", description); + this.lastModified = checkNotNull(lastModified, "lastModified of %s", description); + this.extendedProperties = ImmutableMap + .copyOf(checkNotNull(extendedProperties, "extendedProperties of %s", description)); + } + + /** + * The status of the hosted service. + */ + public Status getStatus() { + return status; + } + + /** + * The status of the hosted service unparsed. + */ + public String getRawStatus() { + return rawStatus; + } + + /** + * The date that the hosted service was created. + */ + public Date getCreated() { + return created; + } + + /** + * The date that the hosted service was last updated. + */ + public Date getLastModified() { + return lastModified; + } + + /** + * Represents the name of an extended hosted service property. Each extended property must have + * both a defined name and value. You can have a maximum of 50 extended property name/value + * pairs. + * + * The maximum length of the Name element is 64 characters, only alphanumeric characters and + * underscores are valid in the Name, and the name must start with a letter. Each extended + * property value has a maximum length of 255 characters. + */ + public Map getExtendedProperties() { + return extendedProperties; + } + + @Override + public ToStringHelper string() { + return super.string().add("status", rawStatus).add("created", created).add("lastModified", lastModified) + .add("extendedProperties", extendedProperties); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java new file mode 100644 index 0000000..d257709 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Disk.java @@ -0,0 +1,442 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.base.Objects; +import com.google.common.base.Optional; +import java.net.URI; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * disk in the image repository + * + * @see api + */ +public class Disk { + public static class Attachment { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromAttachment(this); + } + + public static class Builder { + + private String hostedService; + private String deployment; + private String role; + + /** + * @see Attachment#getHostedService() + */ + public Builder hostedService(String hostedService) { + this.hostedService = hostedService; + return this; + } + + /** + * @see Attachment#getDeployment() + */ + public Builder deployment(String deployment) { + this.deployment = deployment; + return this; + } + + /** + * @see Attachment#getRole() + */ + public Builder role(String role) { + this.role = role; + return this; + } + + public Attachment build() { + return new Attachment(hostedService, deployment, role); + } + + public Builder fromAttachment(Attachment in) { + return this.hostedService(in.hostedService).deployment(in.deployment).role(in.role); + } + } + + private final String hostedService; + private final String deployment; + private final String role; + + private Attachment(String hostedService, String deployment, String role) { + this.hostedService = checkNotNull(hostedService, "hostedService"); + this.deployment = checkNotNull(deployment, "deployment"); + this.role = checkNotNull(role, "role"); + } + + /** + * The deployment in which the disk is being used. + */ + public String getDeployment() { + return deployment; + } + + /** + * The hosted service in which the disk is being used. + */ + public String getHostedService() { + return hostedService; + } + + /** + * The virtual machine that the disk is attached to. + */ + public String getRole() { + return role; + } + + @Override + public int hashCode() { + return Objects.hashCode(hostedService, deployment, role); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Attachment other = (Attachment) obj; + return Objects.equal(this.hostedService, other.hostedService) && Objects + .equal(this.deployment, other.deployment) && Objects.equal(this.role, other.role); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).omitNullValues().add("deployment", hostedService).add("role", role) + .toString(); + } + + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromHostedService(this); + } + + public static class Builder { + + private Optional attachedTo = Optional.absent(); + private OSType os; + private String name; + private Optional logicalSizeInGB = Optional.absent(); + private Optional description = Optional.absent(); + private Optional location = Optional.absent(); + private Optional affinityGroup = Optional.absent(); + private Optional mediaLink = Optional.absent(); + private Optional sourceImage = Optional.absent(); + private Optional label = Optional.absent(); + private boolean hasOperatingSystem; + private boolean isCorrupted; + + /** + * @see Disk#getAttachedTo() + */ + public Builder attachedTo(Attachment attachedTo) { + this.attachedTo = Optional.fromNullable(attachedTo); + return this; + } + + /** + * @see Disk#getOS() + */ + public Builder os(OSType os) { + this.os = os; + return this; + } + + /** + * @see Disk#getName() + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see Disk#getDescription() + */ + public Builder description(String description) { + this.description = Optional.fromNullable(description); + return this; + } + + /** + * @see Disk#getLogicalSizeInGB() + */ + public Builder logicalSizeInGB(Integer logicalSizeInGB) { + this.logicalSizeInGB = Optional.fromNullable(logicalSizeInGB); + return this; + } + + /** + * @see Disk#getLocation() + */ + public Builder location(String location) { + this.location = Optional.fromNullable(location); + return this; + } + + /** + * @see Disk#getAffinityGroup() + */ + public Builder affinityGroup(String affinityGroup) { + this.affinityGroup = Optional.fromNullable(affinityGroup); + return this; + } + + /** + * @see Disk#getMediaLink() + */ + public Builder mediaLink(URI mediaLink) { + this.mediaLink = Optional.fromNullable(mediaLink); + return this; + } + + /** + * @see Disk#getSourceImage() + */ + public Builder sourceImage(String sourceImage) { + this.sourceImage = Optional.fromNullable(sourceImage); + return this; + } + + /** + * @see Disk#getLabel() + */ + public Builder label(String label) { + this.label = Optional.fromNullable(label); + return this; + } + + /** + * @see Disk#hasOperatingSystem() + */ + public Builder hasOperatingSystem(boolean hasOperatingSystem) { + this.hasOperatingSystem = hasOperatingSystem; + return this; + } + + /** + * @see Disk#isCorrupted() + */ + public Builder isCorrupted(boolean isCorrupted) { + this.isCorrupted = isCorrupted; + return this; + } + + public Disk build() { + return new Disk(attachedTo, os, name, logicalSizeInGB, description, location, affinityGroup, mediaLink, + sourceImage, label, hasOperatingSystem, isCorrupted); + } + + public Builder fromHostedService(Disk in) { + return this.attachedTo(in.attachedTo.orNull()).os(in.getOS()).name(in.getName()) + .logicalSizeInGB(in.getLogicalSizeInGB().orNull()).description(in.getDescription().orNull()) + .location(in.getLocation().orNull()).affinityGroup(in.getAffinityGroup().orNull()) + .mediaLink(in.getMediaLink().orNull()).sourceImage(in.getSourceImage().orNull()) + .label(in.getLabel().orNull()).hasOperatingSystem(in.hasOperatingSystem).isCorrupted(in.isCorrupted); + } + } + + private final Optional attachedTo; + private final OSType os; + private final String name; + private final Optional logicalSizeInGB; + private final Optional description; + private final Optional location; + private final Optional affinityGroup; + private final Optional mediaLink; + private final Optional sourceImage; + private final Optional label; + private final boolean hasOperatingSystem; + private final boolean isCorrupted; + + private Disk(Optional attachedTo, OSType os, String name, Optional logicalSizeInGB, + Optional description, Optional location, Optional affinityGroup, + Optional mediaLink, Optional sourceImage, Optional label, boolean hasOperatingSystem, + boolean isCorrupted) { + this.name = checkNotNull(name, "name"); + this.attachedTo = checkNotNull(attachedTo, "attachedTo for %s", name); + this.logicalSizeInGB = checkNotNull(logicalSizeInGB, "logicalSizeInGB for %s", name); + this.description = checkNotNull(description, "description for %s", name); + this.os = checkNotNull(os, "os for %s", name); + this.location = checkNotNull(location, "location for %s", name); + this.affinityGroup = checkNotNull(affinityGroup, "affinityGroup for %s", name); + this.mediaLink = checkNotNull(mediaLink, "mediaLink for %s", name); + this.sourceImage = checkNotNull(sourceImage, "sourceImage for %s", name); + this.label = checkNotNull(label, "label for %s", name); + this.hasOperatingSystem = hasOperatingSystem; + this.isCorrupted = isCorrupted; + } + + /** + * Contains properties that specify a virtual machine that currently using the disk. A disk + * cannot be deleted as long as it is attached to a virtual machine. + */ + public Optional getAttachedTo() { + return attachedTo; + } + + /** + * The operating system type of the OS image. + */ + public OSType getOS() { + return os; + } + + /** + * The name of the disk. This is the name that is used when creating one or more virtual machines + * using the disk. + */ + public String getName() { + return name; + } + + /** + * The size, in GB, of the image. + */ + public Optional getLogicalSizeInGB() { + return logicalSizeInGB; + } + + /** + * The description for the image. + */ + public Optional getDescription() { + return description; + } + + /** + * The geo-location in which this media is located. The Location value is derived from storage + * account that contains the blob in which the media is located. If the storage account belongs + * to an affinity group the value is absent. + */ + public Optional getLocation() { + return location; + } + + /** + * The affinity in which the media is located. The AffinityGroup value is derived from storage + * account that contains the blob in which the media is located. If the storage account does not + * belong to an affinity group the value is absent. + */ + public Optional getAffinityGroup() { + return affinityGroup; + } + + /** + * The location of the blob in the blob store in which the media for the disk is located. The + * blob location belongs to a storage account in the subscription specified by the + * value in the operation call. + * + * Example: + * + * http://example.blob.core.windows.net/disks/mydisk.vhd + */ + public Optional getMediaLink() { + return mediaLink; + } + + /** + * The name of the OS Image from which the disk was created. This property is populated + * automatically when a disk is created from an OS image by calling the Add Role, Create + * Deployment, or Provision Disk operations. + */ + public Optional getSourceImage() { + return sourceImage; + } + + /** + * The description of the image. + */ + public Optional getLabel() { + return label; + } + + /** + * Returns whether this disk contains operation system. Only disks that have an operating system + * installed can be mounted as an OS Drive. + */ + public boolean hasOperatingSystem() { + return hasOperatingSystem; + } + + /** + * Returns whether there is a consistency failure detected with this disk. If a disk fails the + * consistency check, you delete any virtual machines using it, delete the disk, and inspect the + * blob media to see if the content is intact. You can then reregister the media in the blob as a + * disk. + */ + public boolean isCorrupted() { + return isCorrupted; + } + + @Override + public int hashCode() { + return Objects.hashCode(name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Disk other = (Disk) obj; + return Objects.equal(this.name, other.name); + } + + @Override + public String toString() { + return string().toString(); + } + + private ToStringHelper string() { + return MoreObjects.toStringHelper(this).omitNullValues().add("os", os).add("name", name) + .add("attachedTo", attachedTo.orNull()).add("logicalSizeInGB", logicalSizeInGB.orNull()) + .add("description", description).add("location", location.orNull()) + .add("affinityGroup", affinityGroup.orNull()).add("mediaLink", mediaLink.orNull()) + .add("sourceImage", sourceImage.orNull()).add("label", label.orNull()) + .add("hasOperatingSystem", hasOperatingSystem).add("isCorrupted", isCorrupted); + } + +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Error.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Error.java new file mode 100644 index 0000000..e8947ab --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Error.java @@ -0,0 +1,240 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.CaseFormat; +import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * additional error information that is defined by the management service. Th + * + * @see api + */ +public class Error { + + public static enum Code { + + /** + * Bad Request (400) + * + * The versioning header is not specified or was specified incorrectly. + */ + MISSING_OR_INCORRECT_VERSION_HEADER, + + /** + * Bad Request (400) + * + * The request body’s XML was invalid or not correctly specified. + */ + INVALID_XML_REQUEST, + + /** + * Bad Request (400) + * + * A required query parameter was not specified for this request or was specified incorrectly. + */ + MISSING_OR_INVALID_REQUIRED_QUERY_PARAMETER, + + /** + * Bad Request (400) + * + * The HTTP verb specified was not recognized by the server or isn’t valid for this resource. + */ + INVALID_HTTP_VERB, + + /** + * Forbidden (403) + * + * The server failed to authenticate the request. Verify that the certificate is valid and is + * associated with this subscription. + */ + AUTHENTICATION_FAILED, + + /** + * Not Found (404) + * + * The specified resource does not exist. + */ + RESOURCE_NOT_FOUND, + + /** + * Internal Server Error (500) + * + * The server encountered an internal error. Please retry the request. + */ + INTERNAL_ERROR, + + /** + * Internal Server Error (500) + * + * The operation could not be completed within the permitted time. + */ + OPERATION_TIMED_OUT, + + /** + * Service Unavailable (503) + * + * The server (or an internal component) is currently unavailable to receive requests. Please + * retry your request + */ + SERVER_BUSY, + + /** + * Forbidden (403) + * + * The subscription is in a disabled state. + */ + SUBSCRIPTION_DISABLED, + + /** + * Bad Request (400) + * + * A parameter was incorrect. + */ + BAD_REQUEST, + + /** + * Conflict (409) + * + * A conflict occurred to prevent the operation from completing. + */ + CONFLICT_ERROR, + + UNRECOGNIZED; + + public String value() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); + } + + @Override + public String toString() { + return value(); + } + + public static Code fromValue(String code) { + try { + return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(code, "code"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromError(this); + } + + public static class Builder { + + private String rawCode; + private Code code; + private String message; + + /** + * @see Error#getRawCode() + */ + public Builder rawCode(String rawCode) { + this.rawCode = rawCode; + return this; + } + + /** + * @see Error#getCode() + */ + public Builder code(Code code) { + this.code = code; + return this; + } + + /** + * @see Error#getMessage() + */ + public Builder message(String message) { + this.message = message; + return this; + } + + public Error build() { + return new Error(rawCode, code, message); + } + + public Builder fromError(Error in) { + return this.rawCode(in.rawCode).code(in.code).message(in.message); + } + } + + private final String rawCode; + private final Code code; + private final String message; + + protected Error(String rawCode, Code code, String message) { + this.rawCode = checkNotNull(rawCode, "rawCode for %s", message); + this.code = checkNotNull(code, "code for %s", message); + this.message = checkNotNull(message, "message"); + } + + /** + * Error code + */ + public Code getCode() { + return code; + } + + /** + * Error code, unparsed + */ + public String getRawCode() { + return rawCode; + } + + /** + * User message + */ + public String getMessage() { + return message; + } + + @Override + public int hashCode() { + return Objects.hashCode(rawCode, code, message); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Error other = (Error) obj; + return Objects.equal(this.rawCode, other.rawCode) && Objects.equal(this.code, other.code) + && Objects.equal(this.message, other.message); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).omitNullValues().add("code", rawCode).add("message", message).toString(); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedService.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedService.java new file mode 100644 index 0000000..f1e0584 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedService.java @@ -0,0 +1,184 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.CaseFormat; +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.base.Objects; +import java.net.URI; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * System properties for the specified hosted service + * + * @see api + */ +public class HostedService { + public static enum Status { + + CREATING, + + CREATED, + + DELETING, + + DELETED, + + CHANGING, + + RESOLVING_DNS, + + UNRECOGNIZED; + + public String value() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); + } + + @Override + public String toString() { + return value(); + } + + public static Status fromValue(String status) { + try { + return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + } + + public static Builder builder() { + return new ConcreteBuilder(); + } + + public Builder toBuilder() { + return new ConcreteBuilder().fromHostedService(this); + } + + public abstract static class Builder> { + protected abstract T self(); + + protected URI url; + protected String name; + protected HostedServiceProperties properties; + + /** + * @see HostedService#getUrl() + */ + public T url(URI url) { + this.url = url; + return self(); + } + + /** + * @see HostedService#getName() + */ + public T name(String name) { + this.name = name; + return self(); + } + + /** + * @see HostedService#getProperties() + */ + public T properties(HostedServiceProperties properties) { + this.properties = properties; + return self(); + } + + public HostedService build() { + return new HostedService(url, name, properties); + } + + public T fromHostedService(HostedService in) { + return this.url(in.getUrl()).name(in.getName()).properties(in.getProperties()); + } + } + + private static class ConcreteBuilder extends Builder { + @Override + protected ConcreteBuilder self() { + return this; + } + } + + protected final URI url; + protected final String name; + protected final HostedServiceProperties properties; + + protected HostedService(URI url, String name, HostedServiceProperties properties) { + this.url = checkNotNull(url, "url"); + this.name = checkNotNull(name, "name"); + this.properties = checkNotNull(properties, "properties"); + } + + /** + * The Service Management API request URI used to perform Get Hosted Service Properties requests + * against the hosted service. + */ + public URI getUrl() { + return url; + } + + /** + * The name of the hosted service. This name is the DNS prefix name and can be used to access the + * hosted service. + * + * For example, if the service name is MyService you could access the access the service by + * calling: http://MyService.cloudapp.net + */ + public String getName() { + return name; + } + + /** + * Provides the url of the database properties to be used for this DB HostedService. + */ + public HostedServiceProperties getProperties() { + return properties; + } + + @Override + public int hashCode() { + return Objects.hashCode(url); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + HostedService other = (HostedService) obj; + return Objects.equal(this.url, other.url); + } + + @Override + public String toString() { + return string().toString(); + } + + protected ToStringHelper string() { + return MoreObjects.toStringHelper(this).omitNullValues().add("url", url).add("name", name) + .add("properties", properties); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceProperties.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceProperties.java new file mode 100644 index 0000000..4793785 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceProperties.java @@ -0,0 +1,170 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.base.Objects; +import com.google.common.base.Optional; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * System properties for the specified hosted service. These properties include the service name and + * service type; the name of the affinity group to which the service belongs, or its location if it + * is not part of an affinity group. + * + * @see api + */ +public class HostedServiceProperties { + public static Builder builder() { + return new ConcreteBuilder(); + } + + public Builder toBuilder() { + return new ConcreteBuilder().fromHostedServiceProperties(this); + } + + public abstract static class Builder> { + protected abstract T self(); + + protected Optional description = Optional.absent(); + protected Optional location = Optional.absent(); + protected Optional affinityGroup = Optional.absent(); + protected String label; + + /** + * @see HostedServiceProperties#getDescription() + */ + public T description(String description) { + this.description = Optional.fromNullable(description); + return self(); + } + + /** + * @see HostedServiceProperties#getLocation() + */ + public T location(String location) { + this.location = Optional.fromNullable(location); + return self(); + } + + /** + * @see HostedServiceProperties#getAffinityGroup() + */ + public T affinityGroup(String affinityGroup) { + this.affinityGroup = Optional.fromNullable(affinityGroup); + return self(); + } + + /** + * @see HostedServiceProperties#getLabel() + */ + public T label(String label) { + this.label = label; + return self(); + } + + public HostedServiceProperties build() { + return new HostedServiceProperties(description, location, affinityGroup, label); + } + + public T fromHostedServiceProperties(HostedServiceProperties in) { + return this.description(in.getDescription().orNull()).location(in.getLocation().orNull()) + .affinityGroup(in.getAffinityGroup().orNull()).label(in.getLabel()); + } + } + + private static class ConcreteBuilder extends Builder { + @Override + protected ConcreteBuilder self() { + return this; + } + } + + protected final Optional description; + protected final Optional location; + protected final Optional affinityGroup; + protected final String label; + + protected HostedServiceProperties(Optional description, Optional location, + Optional affinityGroup, String label) { + this.description = checkNotNull(description, "description"); + this.location = checkNotNull(location, "location"); + this.affinityGroup = checkNotNull(affinityGroup, "affinityGroup"); + this.label = checkNotNull(label, "label"); + } + + /** + * The description for the hosted service.. + */ + public Optional getDescription() { + return description; + } + + /** + * The geo-location of the hosted service in Windows Azure, if the hosted service is not + * associated with an affinity group. If a location has been specified, the AffinityGroup element + * is not returned. + */ + public Optional getLocation() { + return location; + } + + /** + * The affinity group with which this hosted service is associated, if any. If the service is + * associated with an affinity group, the Location element is not returned. + */ + public Optional getAffinityGroup() { + return affinityGroup; + } + + /** + * The name can be up to 100 characters in length. The name can be used identify the storage account for your tracking purposes. + */ + public String getLabel() { + return label; + } + + @Override + public int hashCode() { + return Objects.hashCode(description, location, affinityGroup, label); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + HostedServiceProperties other = (HostedServiceProperties) obj; + return Objects.equal(this.description, other.description) && Objects.equal(this.location, other.location) + && Objects.equal(this.affinityGroup, other.affinityGroup) && Objects.equal(this.label, other.label); + } + + @Override + public String toString() { + return string().toString(); + } + + protected ToStringHelper string() { + return MoreObjects.toStringHelper(this).omitNullValues().add("description", description.orNull()) + .add("location", location.orNull()).add("affinityGroup", affinityGroup.orNull()).add("label", label); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceWithDetailedProperties.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceWithDetailedProperties.java new file mode 100644 index 0000000..66c6640 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/HostedServiceWithDetailedProperties.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import java.net.URI; + +public class HostedServiceWithDetailedProperties extends HostedService { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromHostedServiceWithDetailedProperties(this); + } + + public static class Builder extends HostedService.Builder { + + @Override + public Builder properties(HostedServiceProperties properties) { + this.properties = DetailedHostedServiceProperties.class.cast(properties); + return this; + } + + public HostedServiceWithDetailedProperties build() { + return new HostedServiceWithDetailedProperties(url, name, + DetailedHostedServiceProperties.class.cast(properties)); + } + + public Builder fromHostedServiceWithDetailedProperties(HostedServiceWithDetailedProperties in) { + return fromHostedService(in); + } + + @Override protected Builder self() { + return this; + } + } + + protected HostedServiceWithDetailedProperties(URI url, String serviceName, + DetailedHostedServiceProperties properties) { + super(url, serviceName, properties); + } + + @Override + public DetailedHostedServiceProperties getProperties() { + return DetailedHostedServiceProperties.class.cast(properties); + } + +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java new file mode 100644 index 0000000..0bde175 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Image.java @@ -0,0 +1,298 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.base.Objects; +import com.google.common.base.Optional; +import com.google.common.collect.ImmutableList; +import java.net.URI; +import java.util.List; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * OS images from the image repository + * + * @see api + */ +public class Image { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromOSImage(this); + } + + public static class Builder { + private OSType os; + private String name; + private Optional logicalSizeInGB = Optional.absent(); + private Optional description = Optional.absent(); + private Optional category = Optional.absent(); + private Optional location = Optional.absent(); + private Optional affinityGroup = Optional.absent(); + private Optional mediaLink = Optional.absent(); + private ImmutableList.Builder eula = ImmutableList.builder(); + private String label; + + /** + * @see Image#getOS() + */ + public Builder os(OSType os) { + this.os = os; + return this; + } + + /** + * @see Image#getName() + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see Image#getDescription() + */ + public Builder description(String description) { + this.description = Optional.fromNullable(description); + return this; + } + + /** + * @see Image#getLogicalSizeInGB() + */ + public Builder logicalSizeInGB(Integer logicalSizeInGB) { + this.logicalSizeInGB = Optional.fromNullable(logicalSizeInGB); + return this; + } + + /** + * @see Image#getCategory() + */ + public Builder category(String category) { + this.category = Optional.fromNullable(category); + return this; + } + + /** + * @see Image#getLocation() + */ + public Builder location(String location) { + this.location = Optional.fromNullable(location); + return this; + } + + /** + * @see Image#getAffinityGroup() + */ + public Builder affinityGroup(String affinityGroup) { + this.affinityGroup = Optional.fromNullable(affinityGroup); + return this; + } + + /** + * @see Image#getMediaLink() + */ + public Builder mediaLink(URI mediaLink) { + this.mediaLink = Optional.fromNullable(mediaLink); + return this; + } + + /** + * @see Image#getEula() + */ + public Builder eula(Iterable eula) { + this.eula.addAll(eula); + return this; + } + + /** + * @see Image#getEula() + */ + public Builder eula(String eula) { + this.eula.add(eula); + return this; + } + + /** + * @see Image#getLabel() + */ + public Builder label(String label) { + this.label = label; + return this; + } + + public Image build() { + return new Image(os, name, logicalSizeInGB, description, category, location, affinityGroup, mediaLink, + eula.build(), label); + } + + public Builder fromOSImage(Image in) { + return this.os(in.getOS()).name(in.getName()).logicalSizeInGB(in.getLogicalSizeInGB().orNull()) + .description(in.getDescription().orNull()).category(in.getCategory().orNull()) + .location(in.getLocation().orNull()).affinityGroup(in.getAffinityGroup().orNull()) + .mediaLink(in.getMediaLink().orNull()).eula(in.getEula()).label(in.getLabel()); + } + } + + private final OSType os; + private final String name; + private final Optional logicalSizeInGB; + private final Optional description; + private final Optional category; + private final Optional location; + private final Optional affinityGroup; + private final Optional mediaLink; + private final List eula; + private final String label; + + private Image(OSType os, String name, Optional logicalSizeInGB, Optional description, + Optional category, Optional location, Optional affinityGroup, Optional mediaLink, + List eula, String label) { + this.name = checkNotNull(name, "name"); + this.logicalSizeInGB = checkNotNull(logicalSizeInGB, "logicalSizeInGB for %s", name); + this.description = checkNotNull(description, "description for %s", name); + this.os = checkNotNull(os, "os for %s", name); + this.category = checkNotNull(category, "category for %s", name); + this.location = checkNotNull(location, "location for %s", name); + this.affinityGroup = checkNotNull(affinityGroup, "affinityGroup for %s", name); + this.mediaLink = checkNotNull(mediaLink, "mediaLink for %s", name); + this.eula = checkNotNull(eula, "eula for %s", name); + this.label = checkNotNull(label, "label for %s", name); + } + + /** + * The operating system type of the OS image. + */ + public OSType getOS() { + return os; + } + + /** + * The name of the hosted service. This name is the DNS prefix name and can be used to access the + * hosted service. + * + * For example, if the service name is MyService you could access the access the service by + * calling: http://MyService.cloudapp.net + */ + public String getName() { + return name; + } + + /** + * The size, in GB, of the image. + */ + public Optional getLogicalSizeInGB() { + return logicalSizeInGB; + } + + /** + * The description for the image. + */ + public Optional getDescription() { + return description; + } + + /** + * The repository classification of image. All user images have the category "User", but + * categories for other images could be, for example "Canonical" + */ + public Optional getCategory() { + return category; + } + + /** + * The geo-location in which this media is located. The Location value is derived from storage + * account that contains the blob in which the media is located. If the storage account belongs + * to an affinity group the value is absent. + */ + public Optional getLocation() { + return location; + } + + /** + * The affinity in which the media is located. The AffinityGroup value is derived from storage + * account that contains the blob in which the media is located. If the storage account does not + * belong to an affinity group the value is absent. + */ + public Optional getAffinityGroup() { + return affinityGroup; + } + + /** + * The location of the blob in the blob store in which the media for the image is located. The + * blob location belongs to a storage account in the subscription specified by the + * value in the operation call. + * + * Example: + * + * http://example.blob.core.windows.net/disks/myimage.vhd + */ + public Optional getMediaLink() { + return mediaLink; + } + + /** + * The eulas for the image, if available. + */ + // Not URI as some providers put non-uri data in, such as riverbed. + public List getEula() { + return eula; + } + + /** + * The description of the image. + */ + public String getLabel() { + return label; + } + + @Override + public int hashCode() { + return Objects.hashCode(name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Image other = (Image) obj; + return Objects.equal(this.name, other.name); + } + + @Override + public String toString() { + return string().toString(); + } + + private ToStringHelper string() { + return MoreObjects.toStringHelper(this).omitNullValues().add("os", os).add("name", name) + .add("logicalSizeInGB", logicalSizeInGB.orNull()).add("description", description) + .add("category", category.orNull()).add("location", location.orNull()) + .add("affinityGroup", affinityGroup.orNull()).add("mediaLink", mediaLink.orNull()) + .add("eula", eula).add("label", label); + } + +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java new file mode 100644 index 0000000..3de38a5 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ImageParams.java @@ -0,0 +1,165 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.base.Objects; +import java.net.URI; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * The Add OS Image operation adds an OS image that is currently stored in a storage account in your + * subscription to the image repository. + * + * @see api + */ +public class ImageParams { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromImageParams(this); + } + + public static class Builder { + private String label; + private URI mediaLink; + private OSType os; + private String name; + + /** + * @see ImageParams#getLabel() + */ + public Builder label(String label) { + this.label = label; + return this; + } + + /** + * @see ImageParams#getMediaLink() + */ + public Builder mediaLink(URI mediaLink) { + this.mediaLink = mediaLink; + return this; + } + + /** + * @see ImageParams#getName() + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see ImageParams#getOS() + */ + public Builder os(OSType os) { + this.os = os; + return this; + } + + public ImageParams build() { + return new ImageParams(label, mediaLink, name, os); + } + + public Builder fromImageParams(ImageParams in) { + return this.label(in.getLabel()).mediaLink(in.getMediaLink()).name(in.getName()).os(in.getOS()); + } + } + + private final String label; + private final URI mediaLink; + private final String name; + private final OSType os; + + private ImageParams(String label, URI mediaLink, String name, OSType os) { + this.label = checkNotNull(label, "label"); + this.name = checkNotNull(name, "name for %s", label); + this.mediaLink = checkNotNull(mediaLink, "mediaLink for %s", label); + this.os = checkNotNull(os, "os for %s", label); + } + + /** + * The operating system type of the OS image. + */ + public OSType getOS() { + return os; + } + + /** + * The name of the hosted service. This name is the DNS prefix name and can be used to access the + * hosted service. + * + * For example, if the service name is MyService you could access the access the service by + * calling: http://MyService.cloudapp.net + */ + public String getName() { + return name; + } + + /** + * The location of the blob in the blob store in which the media for the image is located. The + * blob location belongs to a storage account in the subscription specified by the + * value in the operation call. + * + * Example: + * + * http://example.blob.core.windows.net/disks/myimage.vhd + */ + public URI getMediaLink() { + return mediaLink; + } + + /** + * The description of the image. + */ + public String getLabel() { + return label; + } + + @Override + public int hashCode() { + return Objects.hashCode(name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ImageParams other = (ImageParams) obj; + return Objects.equal(this.name, other.name); + } + + @Override + public String toString() { + return string().toString(); + } + + private ToStringHelper string() { + return MoreObjects.toStringHelper(this).add("label", label).add("mediaLink", mediaLink).add("name", name) + .add("os", os); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/InputEndpoint.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/InputEndpoint.java new file mode 100644 index 0000000..a06c0f5 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/InputEndpoint.java @@ -0,0 +1,137 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +public class InputEndpoint { + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private Integer localPort; + private Integer externalPort; + private String name; + private Protocol protocol; + + public Builder localPort(Integer localPort) { + this.localPort = localPort; + return this; + } + + public Builder externalPort(Integer externalPort) { + this.externalPort = externalPort; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder protocol(Protocol protocol) { + this.protocol = protocol; + return this; + } + + public InputEndpoint build(){ + return new InputEndpoint(localPort, externalPort, name, protocol); + } + + } + + private final Integer localPort; + private final Integer externalPort; + private final String name; + private final Protocol protocol; + + public InputEndpoint(Integer localPort, Integer externalPort, String name, + Protocol protocol) { + super(); + this.localPort = localPort; + this.externalPort = externalPort; + this.name = name; + this.protocol = protocol; + } + + public Integer getLocalPort() { + return localPort; + } + + public Integer getExternalPort() { + return externalPort; + } + + public String getName() { + return name; + } + + public Protocol getProtocol() { + return protocol; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((externalPort == null) ? 0 : externalPort.hashCode()); + result = prime * result + + ((localPort == null) ? 0 : localPort.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + + ((protocol == null) ? 0 : protocol.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + InputEndpoint other = (InputEndpoint) obj; + if (externalPort == null) { + if (other.externalPort != null) + return false; + } else if (!externalPort.equals(other.externalPort)) + return false; + if (localPort == null) { + if (other.localPort != null) + return false; + } else if (!localPort.equals(other.localPort)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (protocol != other.protocol) + return false; + return true; + } + + @Override + public String toString() { + return "InputEndPoint [localPort=" + localPort + ", externalPort=" + + externalPort + ", name=" + name + ", protocol=" + protocol + + "]"; + } + +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/InstanceStatus.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/InstanceStatus.java new file mode 100644 index 0000000..51b5d24 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/InstanceStatus.java @@ -0,0 +1,155 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.CaseFormat; + +import static com.google.common.base.Preconditions.checkNotNull; + +public enum InstanceStatus { + + /** + * The role state is currently unknown. The state should automatically be + * resolved once the role state is detected, so no action is required. + */ + ROLE_STATE_UNKNOWN, + + /** + * The host agent is currently creating resources for the Virtual Machine + * (VM). + */ + CREATING_V_M, + + /** + * The host agent is starting the Virtual Machine. + */ + STARTING_V_M, + + /** + * Windows Azure is creating resources for the role. + */ + CREATING_ROLE, + + /** + * Windows Azure is starting the role. + */ + STARTING_ROLE, + + /** + * The role instance has started and is ready to be used. + */ + READY_ROLE, + + /** + * The role instance is unavailable for requests. This state is usually + * generated while the role is being created or stopped. + */ + BUSY_ROLE, + + /** + * Windows Azure is stopping the role. + */ + STOPPING_ROLE, + + /** + * The host agent is stopping the Virtual Machine. This status also + * indicates that the role has already been stopped. + */ + STOPPING_V_M, + + /** + * The Virtual Machine is being deleted by the host agent. + */ + DELETING_V_M, + + /** + * The Virtual Machine is not running. This is the final state of the + * shutdown process, and no other status messages should be received after + * StoppedVM. + */ + STOPPED_V_M, + + /** + * The role has unexpectedly stopped or has failed to start. This status + * indicates that there is a problem with the role that is causing it to + * crash or preventing it from starting, and must be corrected before the + * role can be started. The InstanceStateDetails and InstanceErrorCode + * fields can hold information about the role error that caused this state, + * which may be useful for identifying and debugging the problem. + */ + RESTARTING_ROLE, + + /** + * The role has continually crashed after being started by Windows Azure. + * This status indicates that there is a problem with the role that prevents + * it from starting, and may be generated after the StartingRole even + * ReadyRole statuses are received. The problem in the role must be found + * and corrected before the role can be started. The InstanceStateDetails + * and InstanceErrorCode fields can hold information about the role error + * that caused this state, which may be useful for identifying and debugging + * the problem. + */ + CYCLING_ROLE, + + /** + * The role has continually failed to start. This status indicates that + * there is a problem with the role that prevents it from starting, and may + * be generated after the process returns StartingRole. The problem in the + * role must be found and corrected before the role can be started. The + * InstanceStateDetails and InstanceErrorCode fields can hold information + * about the role error that caused this state, which may be useful for + * identifying and debugging the problem. + */ + FAILED_STARTING_ROLE, + + /** + * A Windows Azure or container error is preventing the Virtual Machine from + * starting. This status is generated by Windows Azure, and does not + * indicate an error with the role. It may be generated after the + * StartingRole state. + */ + FAILED_STARTING_V_M, + + /** + * The role has timed out before receiving a status message and is not + * responding to requests. + */ + UNRESPONSIVE_ROLE, + + /** + * UNDOCUMENTED BY AZURE + */ + PROVISIONING; + + public String value() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); + } + + @Override + public String toString() { + return value(); + } + + public static InstanceStatus fromValue(String type) { + try { + return valueOf(CaseFormat.UPPER_CAMEL.to( + CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); + } catch (IllegalArgumentException e) { + return ROLE_STATE_UNKNOWN; + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Location.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Location.java new file mode 100644 index 0000000..2b51a58 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Location.java @@ -0,0 +1,150 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import java.util.Set; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * + * A geographical region in which a service or storage account will be hosted. + * + * @see api + */ +public class Location { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromLocation(this); + } + + public static class Builder { + + private String name; + private String displayName; + private ImmutableSet.Builder availableServices = ImmutableSet. builder(); + + /** + * @see Location#getName() + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see Location#getDisplayName() + */ + public Builder displayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * @see Location#getAvailableServices() + */ + public Builder addAvailableService(String availableService) { + this.availableServices.add(checkNotNull(availableService, "availableService")); + return this; + } + + /** + * @see Location#getAvailableServices() + */ + public Builder availableServices(Iterable availableServices) { + this.availableServices = ImmutableSet. builder().addAll( + checkNotNull(availableServices, "availableServices")); + return this; + } + + public Location build() { + return new Location(name, displayName, availableServices.build()); + } + + public Builder fromLocation(Location in) { + return this.name(in.getName()).displayName(in.getDisplayName()).availableServices(in.getAvailableServices()); + } + } + + private final String name; + private final String displayName; + private final Set availableServices; + + protected Location(String name, String displayName, Iterable availableServices) { + this.name = checkNotNull(name, "name"); + this.displayName = checkNotNull(displayName, "displayName for %s", name); + this.availableServices = ImmutableSet.copyOf(checkNotNull(availableServices, "availableServices for %s", name)); + } + + /** + * + * The name of a data center location that is valid for your subscription. For example: + * {@code West Europe} + */ + public String getName() { + return name; + } + + /** + * The localized name of data center location. + */ + public String getDisplayName() { + return displayName; + } + + /** + * Indicates the services available at a location. + * + * Returned values are none, one, or both of the values listed below. + * + * Compute + * + * Storage + */ + public Set getAvailableServices() { + return availableServices; + } + + @Override + public int hashCode() { + return Objects.hashCode(name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Location other = (Location) obj; + return Objects.equal(this.name, other.name); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).omitNullValues().add("name", name).add("displayName", displayName) + .add("availableServices", availableServices).toString(); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSType.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSType.java new file mode 100644 index 0000000..fd85bde --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/OSType.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.CaseFormat; + +import static com.google.common.base.Preconditions.checkNotNull; + +public enum OSType { + + LINUX, + + WINDOWS, + + UNRECOGNIZED; + + public String value() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); + } + + @Override + public String toString() { + return value(); + } + + public static OSType fromValue(String type) { + try { + return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Operation.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Operation.java new file mode 100644 index 0000000..eb336f4 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Operation.java @@ -0,0 +1,200 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.CaseFormat; +import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; +import com.google.common.base.Optional; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * + * Determines whether the operation has succeeded, failed, or is still in progress. + * + * @see api + */ +public class Operation { + + public static enum Status { + + IN_PROGRESS, + + SUCCEEDED, + + FAILED, + + UNRECOGNIZED; + + public String value() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); + } + + @Override + public String toString() { + return value(); + } + + public static Status fromValue(String status) { + try { + return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromOperation(this); + } + + public static class Builder { + + private String id; + private String rawStatus; + private Status status; + // When the operation is in progress, no status code is returned + private Optional httpStatusCode = Optional.absent(); + private Optional error = Optional.absent(); + + /** + * @see Operation#getId() + */ + public Builder id(String id) { + this.id = id; + return this; + } + + /** + * @see Operation#getRawStatus() + */ + public Builder rawStatus(String rawStatus) { + this.rawStatus = rawStatus; + return this; + } + + /** + * @see Operation#getStatus() + */ + public Builder status(Status status) { + this.status = status; + return this; + } + + /** + * @see Operation#getHttpStatusCode() + */ + public Builder httpStatusCode(Integer httpStatusCode) { + this.httpStatusCode = Optional.fromNullable(httpStatusCode); + return this; + } + + /** + * @see Operation#getError() + */ + public Builder error(Error error) { + this.error = Optional.fromNullable(error); + return this; + } + + public Operation build() { + return new Operation(id, rawStatus, status, httpStatusCode, error); + } + + public Builder fromOperation(Operation in) { + return this.id(in.id).rawStatus(in.rawStatus).status(in.status).httpStatusCode(in.httpStatusCode.orNull()) + .error(in.error.orNull()); + } + } + + private final String id; + private final String rawStatus; + private final Status status; + private final Optional httpStatusCode; + private final Optional error; + + protected Operation(String id, String rawStatus, Status status, Optional httpStatusCode, Optional error) { + this.id = checkNotNull(id, "id"); + this.rawStatus = checkNotNull(rawStatus, "rawStatus for %s", id); + this.status = checkNotNull(status, "status for %s", id); + this.httpStatusCode = checkNotNull(httpStatusCode, "httpStatusCode for %s", id); + this.error = checkNotNull(error, "error for %s", id); + } + + /** + * The request ID of the asynchronous request. + */ + public String getId() { + return id; + } + + /** + * The status of the asynchronous request. + */ + public Status getStatus() { + return status; + } + + /** + * The status of the asynchronous request, unparsed + */ + public String getRawStatus() { + return rawStatus; + } + + /** + * The HTTP status code for the asynchronous request. + */ + public Optional getHttpStatusCode() { + return httpStatusCode; + } + + /** + * The management service error returned if the asynchronous request failed. + */ + public Optional getError() { + return error; + } + + @Override + public int hashCode() { + return Objects.hashCode(id); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Operation other = (Operation) obj; + return Objects.equal(this.id, other.id); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).omitNullValues().add("id", id).add("status", rawStatus) + .add("httpStatusCode", httpStatusCode).add("error", error.orNull()).toString(); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Protocol.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Protocol.java new file mode 100644 index 0000000..add7ee0 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Protocol.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name = "Protocol") @XmlEnum +public enum Protocol { + @XmlEnumValue("tcp") + TCP, + @XmlEnumValue("http") + HTTP, + @XmlEnumValue("udp") + UDP +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/RoleSize.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/RoleSize.java new file mode 100644 index 0000000..6839091 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/RoleSize.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.common.base.CaseFormat; + +import static com.google.common.base.Preconditions.checkNotNull; + +public enum RoleSize { + EXTRA_SMALL, SMALL, MEDIUM, LARGE, EXTRA_LARGE; + + public String value() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); + } + + @Override + public String toString() { + return value(); + } + + public static RoleSize fromValue(String type) { + try { + return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(type, "type"))); + } catch (IllegalArgumentException e) { + return null; + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/DeploymentApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/DeploymentApi.java new file mode 100644 index 0000000..ada88ac --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/DeploymentApi.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import org.jclouds.azurecompute.binders.BindDeploymentParamsToXmlPayload; +import org.jclouds.azurecompute.domain.Deployment; +import org.jclouds.azurecompute.domain.DeploymentParams; +import org.jclouds.azurecompute.functions.ParseRequestIdHeader; +import org.jclouds.azurecompute.xml.DeploymentHandler; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.Headers; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.XMLResponseParser; + +import static org.jclouds.Fallbacks.NullOnNotFoundOr404; + +@Path("/services/hostedservices/{serviceName}/deployments") +@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") +@Consumes(MediaType.APPLICATION_XML) +public interface DeploymentApi { + + /** + * The Get Deployment operation returns the specified deployment from Windows Azure. + * + * @param name + * the unique DNS Prefix value in the Windows Azure Management Portal + */ + @Named("GetDeployment") + @GET + @Path("/{name}") + @XMLResponseParser(DeploymentHandler.class) + @Fallback(NullOnNotFoundOr404.class) + Deployment get(@PathParam("name") String name); + + /** + * http://msdn.microsoft.com/en-us/library/jj157194 + */ + @Named("CreateVirtualMachineDeployment") + @POST + @Produces(MediaType.APPLICATION_XML) + @ResponseParser(ParseRequestIdHeader.class) + String create(@BinderParam(BindDeploymentParamsToXmlPayload.class) DeploymentParams deploymentParams); + + /** + * The Delete Deployment operation deletes the specified deployment from Windows Azure. + * + * @param name + * the unique DNS Prefix value in the Windows Azure Management Portal + */ + @Named("DeleteDeployment") + @DELETE + @Path("/{name}") + @Fallback(NullOnNotFoundOr404.class) + @ResponseParser(ParseRequestIdHeader.class) + String delete(@PathParam("name") String name); +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java new file mode 100644 index 0000000..1d43707 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import java.util.List; +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; +import org.jclouds.azurecompute.domain.Disk; +import org.jclouds.azurecompute.functions.ParseRequestIdHeader; +import org.jclouds.azurecompute.xml.ListDisksHandler; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.Headers; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.XMLResponseParser; + +import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; +import static org.jclouds.Fallbacks.NullOnNotFoundOr404; + +/** + * The Service Management API includes operations for managing the disks in your subscription. + * + * @see docs + */ +@Path("/services/disks") +@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") +@Consumes(MediaType.APPLICATION_XML) +public interface DiskApi { + + /** + * The List Disks operation retrieves a list of the disks in your image repository. + */ + @Named("ListDisks") + @GET + @XMLResponseParser(ListDisksHandler.class) + @Fallback(EmptyListOnNotFoundOr404.class) + List list(); + + /** + * The Delete Disk operation deletes the specified data or operating system disk from your image + * repository. + * + * @return request id or null, if not found + */ + @Named("DeleteDisk") + @DELETE + @Path("/{diskName}") + @Fallback(NullOnNotFoundOr404.class) + @ResponseParser(ParseRequestIdHeader.class) + String delete(@PathParam("diskName") String diskName); +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java new file mode 100644 index 0000000..9e6b9a2 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/HostedServiceApi.java @@ -0,0 +1,157 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import java.util.List; +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import org.jclouds.azurecompute.binders.BindCreateHostedServiceToXmlPayload; +import org.jclouds.azurecompute.domain.HostedService; +import org.jclouds.azurecompute.domain.HostedServiceWithDetailedProperties; +import org.jclouds.azurecompute.functions.ParseRequestIdHeader; +import org.jclouds.azurecompute.options.CreateHostedServiceOptions; +import org.jclouds.azurecompute.xml.HostedServiceHandler; +import org.jclouds.azurecompute.xml.HostedServiceWithDetailedPropertiesHandler; +import org.jclouds.azurecompute.xml.ListHostedServicesHandler; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.Headers; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.XMLResponseParser; + +import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; +import static org.jclouds.Fallbacks.NullOnNotFoundOr404; + +/** + * The Service Management API includes operations for managing the hosted services beneath your + * subscription. + * + * @see docs + */ +@Path("/services/hostedservices") +@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") +@Consumes(MediaType.APPLICATION_XML) +public interface HostedServiceApi { + + /** + * The List Hosted Services operation lists the hosted services available under the current + * subscription. + * + * @return the response object + */ + @Named("ListHostedServices") + @GET + @XMLResponseParser(ListHostedServicesHandler.class) + @Fallback(EmptyListOnNotFoundOr404.class) + List list(); + + /** + * The Create Hosted Service operation creates a new hosted service in Windows Azure. + * + * @param name + * A name for the hosted service that is unique within Windows Azure. This name is the + * DNS prefix name and can be used to access the hosted service. + * + * For example: http://name.cloudapp.net// + * @param label + * The name can be used identify the storage account for your tracking purposes. The + * name can be up to 100 characters in length. + * @param location + * The location where the hosted service will be created. + * @return the requestId to track this async request progress + * + * @see docs + */ + @Named("CreateHostedService") + @POST + @MapBinder(BindCreateHostedServiceToXmlPayload.class) + @Produces(MediaType.APPLICATION_XML) + @ResponseParser(ParseRequestIdHeader.class) + String createServiceWithLabelInLocation(@PayloadParam("name") String name, + @PayloadParam("label") String label, @PayloadParam("location") String location); + + /** + * same as {@link #createServiceWithLabelInLocation(String, String, String)} , except you can + * specify optional parameters such as extended properties or a description. + * + * @param options + * parameters such as extended properties or a description. + */ + @Named("CreateHostedService") + @POST + @MapBinder(BindCreateHostedServiceToXmlPayload.class) + @Produces(MediaType.APPLICATION_XML) + @ResponseParser(ParseRequestIdHeader.class) + String createServiceWithLabelInLocation(@PayloadParam("name") String name, + @PayloadParam("label") String label, @PayloadParam("location") String location, + @PayloadParam("options") CreateHostedServiceOptions options); + + /** + * The Get Hosted Service Properties operation retrieves system properties for the specified + * hosted service. These properties include the service name and service type; the name of the + * affinity group to which the service belongs, or its location if it is not part of an affinity + * group. + * + * @param name + * the unique DNS Prefix value in the Windows Azure Management Portal + */ + @Named("GetHostedServiceProperties") + @GET + @Path("/{name}") + @XMLResponseParser(HostedServiceHandler.class) + @Fallback(NullOnNotFoundOr404.class) + HostedService get(@PathParam("name") String name); + + /** + * like {@link #get(String)}, except additional data such as status and deployment information is + * returned. + * + * @param name + * the unique DNS Prefix value in the Windows Azure Management Portal + */ + @Named("GetHostedServiceProperties") + @GET + @Path("/{name}") + @QueryParams(keys = "embed-detail", values = "true") + @XMLResponseParser(HostedServiceWithDetailedPropertiesHandler.class) + @Fallback(NullOnNotFoundOr404.class) + HostedServiceWithDetailedProperties getDetails(@PathParam("name") String name); + + /** + * The Delete Hosted Service operation deletes the specified hosted service from Windows Azure. + * + * @param name + * the unique DNS Prefix value in the Windows Azure Management Portal + * + * @return request id or null, if not found + */ + @Named("DeleteHostedService") + @DELETE + @Path("/{name}") + @Fallback(NullOnNotFoundOr404.class) + @ResponseParser(ParseRequestIdHeader.class) + String delete(@PathParam("name") String name); +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java new file mode 100644 index 0000000..cdf7029 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/ImageApi.java @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import java.util.List; +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import org.jclouds.azurecompute.binders.BindOSImageParamsToXmlPayload; +import org.jclouds.azurecompute.domain.Image; +import org.jclouds.azurecompute.domain.ImageParams; +import org.jclouds.azurecompute.functions.ImageParamsName; +import org.jclouds.azurecompute.functions.ParseRequestIdHeader; +import org.jclouds.azurecompute.xml.ListImagesHandler; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.Headers; +import org.jclouds.rest.annotations.ParamParser; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.XMLResponseParser; + +import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; +import static org.jclouds.Fallbacks.NullOnNotFoundOr404; + +/** + * The Service Management API includes operations for managing the OS images in your subscription. + * + * @see docs + */ +@Path("/services/images") +@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") +@Consumes(MediaType.APPLICATION_XML) +public interface ImageApi { + + /** + * The List Hosted Services operation lists the hosted services available under the current + * subscription. + */ + @Named("ListImages") + @GET + @XMLResponseParser(ListImagesHandler.class) + @Fallback(EmptyListOnNotFoundOr404.class) + List list(); + + /** + * The Add OS Image operation adds an OS image that is currently stored in a storage account in your subscription to + * the image repository. + */ + @Named("AddImage") + @POST + @Produces(MediaType.APPLICATION_XML) + @ResponseParser(ParseRequestIdHeader.class) + String add(@BinderParam(BindOSImageParamsToXmlPayload.class) ImageParams params); + + /** + * The Update OS Image operation updates an OS image that in your image repository. + */ + @Named("UpdateImage") + @PUT + @Path("/{imageName}") + @Produces(MediaType.APPLICATION_XML) + @ResponseParser(ParseRequestIdHeader.class) + String update(@PathParam("imageName") @ParamParser(ImageParamsName.class) + @BinderParam(BindOSImageParamsToXmlPayload.class) ImageParams params); + + /** + * The Delete Hosted Service operation deletes the specified hosted service from Windows Azure. + * + * @param imageName + * the unique DNS Prefix value in the Windows Azure Management Portal + */ + @Named("DeleteImage") + @DELETE + @Path("/{imageName}") + @Fallback(NullOnNotFoundOr404.class) + @ResponseParser(ParseRequestIdHeader.class) + String delete(@PathParam("imageName") String imageName); +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java new file mode 100644 index 0000000..1621139 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import java.util.List; +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.MediaType; +import org.jclouds.azurecompute.domain.Location; +import org.jclouds.azurecompute.xml.ListLocationsHandler; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.Headers; +import org.jclouds.rest.annotations.XMLResponseParser; + +import static org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; + +/** + * The Service Management API includes operations for listing the available data center locations + * for a hosted service in your subscription. + *

+ * + * @see + */ +@Path("/locations") +@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") +@Consumes(MediaType.APPLICATION_XML) +public interface LocationApi { + + /** + * The List Locations operation lists all of the data center locations that are valid for your + * subscription. + */ + @Named("ListLocations") + @GET + @XMLResponseParser(ListLocationsHandler.class) + @Fallback(EmptyListOnNotFoundOr404.class) + List list(); +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java new file mode 100644 index 0000000..5ee97a6 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; +import org.jclouds.azurecompute.domain.Operation; +import org.jclouds.azurecompute.xml.OperationHandler; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.Headers; +import org.jclouds.rest.annotations.XMLResponseParser; + +import static org.jclouds.Fallbacks.NullOnNotFoundOr404; + +/** + * The Service Management API includes one operation for tracking the progress of asynchronous requests. + * + * @see docs + */ +@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") +@Consumes(MediaType.APPLICATION_XML) +public interface OperationApi { + + @Named("GetOperation") + @GET + @Path("/operations/{request-id}") + @XMLResponseParser(OperationHandler.class) + @Fallback(NullOnNotFoundOr404.class) + Operation get(@PathParam("request-id") String requestId); +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java new file mode 100644 index 0000000..5067029 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import org.jclouds.azurecompute.functions.ParseRequestIdHeader; +import org.jclouds.rest.annotations.Headers; +import org.jclouds.rest.annotations.Payload; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.ResponseParser; + +/** + * The Service Management API includes operations for managing the virtual + * machines in your subscription. + * + * @see docs + */ +@Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleinstances") +@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") +@Consumes(MediaType.APPLICATION_XML) +// NOTE: MS Docs refer to the commands as Role, but in the description, it is always Virtual Machine. +public interface VirtualMachineApi { + + @Named("RestartRole") + @POST + // Warning : the url in the documentation is WRONG ! @see + // http://social.msdn.microsoft.com/Forums/pl-PL/WAVirtualMachinesforWindows/thread/7ba2367b-e450-49e0-89e4-46c240e9d213 + @Path("/{name}/Operations") + @Produces(MediaType.APPLICATION_XML) + @ResponseParser(ParseRequestIdHeader.class) + @Payload(value = "RestartRoleOperation") + String restart(@PathParam("name") String name); + + /** + * http://msdn.microsoft.com/en-us/library/jj157201 + */ + @Named("CaptureRole") + @POST + @Path("/{name}/Operations") + @Produces(MediaType.APPLICATION_XML) + @ResponseParser(ParseRequestIdHeader.class) + @Payload(value = "CaptureRoleOperationDelete{imageLabel}{imageName}") + String capture(@PathParam("name") String name, @PayloadParam("imageName") String imageName, + @PayloadParam("imageLabel") String imageLabel); + + /** + * http://msdn.microsoft.com/en-us/library/jj157195 + */ + @Named("ShutdownRole") + @POST + @Path("/{name}/Operations") + @Produces(MediaType.APPLICATION_XML) + @ResponseParser(ParseRequestIdHeader.class) + @Payload(value = "ShutdownRoleOperation") + String shutdown(@PathParam("name") String name); + + /** + * http://msdn.microsoft.com/en-us/library/jj157189 + */ + @Named("StartRole") + @POST + @Path("/{name}/Operations") + @Produces(MediaType.APPLICATION_XML) + @ResponseParser(ParseRequestIdHeader.class) + @Payload(value = "StartRoleOperation") + String start(@PathParam("name") String name); +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java new file mode 100644 index 0000000..077b63c --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ImageParamsName.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.functions; + +import com.google.common.base.Function; +import javax.inject.Singleton; +import org.jclouds.azurecompute.domain.ImageParams; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +@Singleton +public class ImageParamsName implements Function { + @Override + public String apply(Object input) { + checkArgument(checkNotNull(input, "input") instanceof ImageParams, + "this function is only valid for ImageParams!"); + return checkNotNull(ImageParams.class.cast(input), "ImageParams").getName(); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java new file mode 100644 index 0000000..2a0d5aa --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.functions; + +import com.google.common.base.Function; +import javax.inject.Singleton; +import org.jclouds.http.HttpResponse; + +import static org.jclouds.http.HttpUtils.releasePayload; + +/** + * Parses an x-ms-request-id the header + * + * A value that uniquely identifies a request made against the management service. For an + * asynchronous operation, you can call get operation status with the value of the header to + * determine whether the operation is complete, has failed, or is still in progress. + */ +@Singleton +public class ParseRequestIdHeader implements Function { + + public String apply(HttpResponse from) { + releasePayload(from); + String requestId = from.getFirstHeaderOrNull("x-ms-request-id"); + if (requestId != null) { + return requestId; + } + throw new IllegalStateException("did not receive RequestId in: " + from); + } + +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/options/CreateHostedServiceOptions.java b/azurecompute/src/main/java/org/jclouds/azurecompute/options/CreateHostedServiceOptions.java new file mode 100644 index 0000000..b4c49eb --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/options/CreateHostedServiceOptions.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.options; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; +import com.google.common.base.Optional; +import java.util.Map; + +/** + * Optional parameters for creating a hosted service + * + * @see docs + */ +public class CreateHostedServiceOptions implements Cloneable { + + private Optional description = Optional.absent(); + private Optional> extendedProperties = Optional.absent(); + + /** + * @see CreateHostedServiceOptions#getDescription() + */ + public CreateHostedServiceOptions description(String description) { + this.description = Optional.fromNullable(description); + return this; + } + + /** + * @see CreateHostedServiceOptions#getExtendedProperties() + */ + public CreateHostedServiceOptions extendedProperties(Map extendedProperties) { + this.extendedProperties = Optional.fromNullable(extendedProperties); + return this; + } + + /** + * A description for the hosted service. The description can be up to 1024 characters in length. + */ + public Optional getDescription() { + return description; + } + + /** + * Represents the name of an extended hosted service property. Each extended property must have + * both a defined name and value. You can have a maximum of 50 extended property name/value + * pairs. + * + * The maximum length of the Name element is 64 characters, only alphanumeric characters and + * underscores are valid in the Name, and the name must start with a letter. Each extended + * property value has a maximum length of 255 characters. + */ + public Optional> getExtendedProperties() { + return extendedProperties; + } + + public static class Builder { + + /** + * @see CreateHostedServiceOptions#getDescription() + */ + public static CreateHostedServiceOptions description(String description) { + return new CreateHostedServiceOptions().description(description); + } + + /** + * @see CreateHostedServiceOptions#getExtendedProperties() + */ + public static CreateHostedServiceOptions extendedProperties(Map extendedProperties) { + return new CreateHostedServiceOptions().extendedProperties(extendedProperties); + } + } + + @Override + public CreateHostedServiceOptions clone() { + return new CreateHostedServiceOptions().description(description.orNull()).extendedProperties( + extendedProperties.orNull()); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CreateHostedServiceOptions other = CreateHostedServiceOptions.class.cast(obj); + return Objects.equal(this.description, other.description) + && Objects.equal(this.extendedProperties, other.extendedProperties); + } + + @Override + public int hashCode() { + return Objects.hashCode(description, extendedProperties); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper("").omitNullValues().add("description", description.orNull()) + .add("extendedProperties", extendedProperties.orNull()).toString(); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/KeyStoreSupplier.java b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/KeyStoreSupplier.java new file mode 100644 index 0000000..d4955e1 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/KeyStoreSupplier.java @@ -0,0 +1,129 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.suppliers; + +import com.google.common.base.Charsets; +import com.google.common.base.Supplier; +import com.google.common.io.ByteSource; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.PrivateKey; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.KeySpec; +import java.util.Collection; +import javax.inject.Inject; +import javax.inject.Singleton; +import org.jclouds.crypto.Crypto; +import org.jclouds.crypto.Pems; +import org.jclouds.domain.Credentials; +import org.jclouds.location.Provider; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Throwables.propagate; + +/** + * TODO this code needs to be completely refactored. It needs to stop using KeyStore of at all possible and definitely + * the local filesystem. Please look at oauth for examples on how to do this via PEMs. + */ +@Deprecated +@Singleton +public class KeyStoreSupplier implements Supplier { + private final Crypto crypto; + private final Supplier creds; + + @Inject + KeyStoreSupplier(Crypto crypto, @Provider Supplier creds) { + this.crypto = crypto; + this.creds = creds; + } + + @Override + public KeyStore get() { + Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); + String cert = checkNotNull(currentCreds.identity, "credential supplier returned null identity (should be cert)"); + String keyStorePassword = checkNotNull(currentCreds.credential, + "credential supplier returned null credential (should be keyStorePassword)"); + try { + KeyStore keyStore = KeyStore.getInstance("PKCS12"); + + File certFile = new File(checkNotNull(cert)); + if (certFile.isFile()) { // cert is path to pkcs12 file + FileInputStream stream = new FileInputStream(certFile); + try { + keyStore.load(stream, keyStorePassword.toCharArray()); + } finally { + stream.close(); + } + } else { // cert is PEM encoded, containing private key and certs + + // split in private key and certs + int privateKeyBeginIdx = cert.indexOf("-----BEGIN PRIVATE KEY"); + int privateKeyEndIdx = cert.indexOf("-----END PRIVATE KEY"); + String pemPrivateKey = cert.substring(privateKeyBeginIdx, privateKeyEndIdx + 26); + + StringBuilder pemCerts = new StringBuilder(); + int certsBeginIdx = 0; + + do { + certsBeginIdx = cert.indexOf("-----BEGIN CERTIFICATE", certsBeginIdx); + + if (certsBeginIdx >= 0) { + int certsEndIdx = cert.indexOf("-----END CERTIFICATE", certsBeginIdx) + 26; + pemCerts.append(cert.substring(certsBeginIdx, certsEndIdx)); + certsBeginIdx = certsEndIdx; + } + } while (certsBeginIdx != -1); + + // parse private key + KeySpec keySpec = Pems.privateKeySpec(ByteSource.wrap(pemPrivateKey.getBytes(Charsets.UTF_8))); + PrivateKey privateKey = crypto.rsaKeyFactory().generatePrivate(keySpec); + + // populate keystore with private key and certs + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + @SuppressWarnings("unchecked") + Collection certs = (Collection) cf.generateCertificates(new ByteArrayInputStream( + pemCerts.toString().getBytes(Charsets.UTF_8))); + keyStore.load(null); + keyStore.setKeyEntry("dummy", privateKey, keyStorePassword.toCharArray(), + certs.toArray(new java.security.cert.Certificate[0])); + + } + return keyStore; + } catch (NoSuchAlgorithmException e) { + throw propagate(e); + } catch (KeyStoreException e) { + throw propagate(e); + } catch (CertificateException e) { + throw propagate(e); + } catch (FileNotFoundException e) { + throw propagate(e); + } catch (IOException e) { + throw propagate(e); + } catch (InvalidKeySpecException e) { + throw propagate(e); + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/SSLContextWithKeysSupplier.java b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/SSLContextWithKeysSupplier.java new file mode 100644 index 0000000..1936bf8 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/SSLContextWithKeysSupplier.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.suppliers; + +import com.google.common.base.Supplier; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.UnrecoverableKeyException; +import javax.inject.Inject; +import javax.inject.Singleton; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import org.jclouds.domain.Credentials; +import org.jclouds.http.HttpUtils; +import org.jclouds.http.config.SSLModule.TrustAllCerts; +import org.jclouds.location.Provider; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Throwables.propagate; + +/** + * TODO this code needs to be completely refactored. It needs to stop using KeyStore of at all possible and definitely + * the local filesystem. Please look at oauth for examples on how to do this via PEMs. + */ +@Deprecated +@Singleton +public class SSLContextWithKeysSupplier implements Supplier { + private final Supplier keyStore; + private final TrustManager[] trustManager; + private final Supplier creds; + + @Inject + SSLContextWithKeysSupplier(Supplier keyStore, @Provider Supplier creds, HttpUtils utils, + TrustAllCerts trustAllCerts) { + this.keyStore = keyStore; + this.trustManager = utils.trustAllCerts() ? new TrustManager[] { trustAllCerts } : null; + this.creds = creds; + } + + @Override + public SSLContext get() { + Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); + String keyStorePassword = checkNotNull(currentCreds.credential, + "credential supplier returned null credential (should be keyStorePassword)"); + KeyManagerFactory kmf; + try { + kmf = KeyManagerFactory.getInstance("SunX509"); + kmf.init(keyStore.get(), keyStorePassword.toCharArray()); + SSLContext sc = SSLContext.getInstance("TLS"); + sc.init(kmf.getKeyManagers(), trustManager, new SecureRandom()); + return sc; + } catch (NoSuchAlgorithmException e) { + throw propagate(e); + } catch (UnrecoverableKeyException e) { + throw propagate(e); + } catch (KeyStoreException e) { + throw propagate(e); + } catch (KeyManagementException e) { + throw propagate(e); + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AttachmentHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AttachmentHandler.java new file mode 100644 index 0000000..648cf26 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/AttachmentHandler.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import org.jclouds.azurecompute.domain.Disk.Attachment; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; +import org.xml.sax.SAXException; + +/** + * @see api + */ +public class AttachmentHandler extends ParseSax.HandlerForGeneratedRequestWithResult { + + private StringBuilder currentText = new StringBuilder(); + private Attachment.Builder builder = Attachment.builder(); + + @Override + public Attachment getResult() { + try { + return builder.build(); + } finally { + builder = Attachment.builder(); + } + } + + @Override + public void endElement(String uri, String name, String qName) throws SAXException { + if (qName.equals("HostedServiceName")) { + builder.hostedService(SaxUtils.currentOrNull(currentText)); + } else if (qName.equals("DeploymentName")) { + builder.deployment(SaxUtils.currentOrNull(currentText)); + } else if (qName.equals("RoleName")) { + builder.role(SaxUtils.currentOrNull(currentText)); + } + currentText.setLength(0); + } + + @Override + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } + +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DeploymentHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DeploymentHandler.java new file mode 100644 index 0000000..8d92c72 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DeploymentHandler.java @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import com.google.common.collect.Lists; +import java.net.URI; +import java.util.List; +import org.jclouds.azurecompute.domain.Deployment; +import org.jclouds.azurecompute.domain.DeploymentSlot; +import org.jclouds.azurecompute.domain.DeploymentStatus; +import org.jclouds.azurecompute.domain.InstanceStatus; +import org.jclouds.azurecompute.domain.RoleSize; +import org.jclouds.http.functions.ParseSax; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import static com.google.common.base.Charsets.UTF_8; +import static com.google.common.io.BaseEncoding.base64; +import static org.jclouds.util.SaxUtils.currentOrNull; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; + +/** + * @see api + */ +public class DeploymentHandler extends ParseSax.HandlerForGeneratedRequestWithResult { + + private List elements = Lists.newArrayList(); + private StringBuilder currentText = new StringBuilder(); + private Deployment.Builder builder = Deployment.builder(); + + @Override + public Deployment getResult() { + try { + return builder.build(); + } finally { + builder = Deployment.builder(); + } + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + elements.add(qName); + } + + @Override + public void endElement(String uri, String name, String qName) throws SAXException { + if (equalsOrSuffix(qName, "Name") && "Deployment".equals(elements.get(elements.size() - 2))) { + builder.deploymentName(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "DeploymentSlot")) { + final String dpltSlot = currentOrNull(currentText); + if (dpltSlot != null) { + builder.deploymentSlot(DeploymentSlot.fromValue(dpltSlot)); + } + } else if (equalsOrSuffix(qName, "Status")) { + String deploymentStatus = currentOrNull(currentText); + if (deploymentStatus != null) { + builder.deploymentStatus(DeploymentStatus.fromValue(deploymentStatus)); + } + } else if (equalsOrSuffix(qName, "Label")) { + String label = currentOrNull(currentText); + if (label != null) { + builder.deploymentLabel(new String(base64().decode(label), UTF_8)); + } + } else if (equalsOrSuffix(qName, "Url")) { + final String url = currentOrNull(currentText); + if (url != null) { + builder.deploymentURL(URI.create(url)); + } + } else if (equalsOrSuffix(qName, "RoleName")) { + builder.roleName(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "InstanceName")) { + builder.instanceName(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "InstanceStatus")) { + String instanceStatus = currentOrNull(currentText); + if (instanceStatus != null) { + builder.instanceStatus(InstanceStatus.fromValue(instanceStatus)); + } + } else if (equalsOrSuffix(qName, "InstanceStateDetails")) { + builder.instanceStateDetails(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "InstanceErrorCode")) { + builder.instanceErrorCode(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "InstanceSize")) { + String instanceSize = currentOrNull(currentText); + if (instanceSize != null) { + builder.instanceSize(RoleSize.fromValue(instanceSize)); + } + } else if (equalsOrSuffix(qName, "IpAddress")) { + builder.privateIpAddress(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "Vip")) { + builder.publicIpAddress(currentOrNull(currentText)); + } + + currentText.setLength(0); + elements.remove(elements.size() - 1); + } + + @Override + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DetailedHostedServicePropertiesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DetailedHostedServicePropertiesHandler.java new file mode 100644 index 0000000..2986d7d --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DetailedHostedServicePropertiesHandler.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import javax.inject.Inject; +import org.jclouds.azurecompute.domain.DetailedHostedServiceProperties; +import org.jclouds.azurecompute.domain.HostedService.Status; +import org.jclouds.date.DateService; +import org.xml.sax.SAXException; + +import static org.jclouds.util.SaxUtils.currentOrNull; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; + +/** + * @see api + */ +public class DetailedHostedServicePropertiesHandler extends HostedServicePropertiesHandler { + + private final DateService dateService; + + @Inject + private DetailedHostedServicePropertiesHandler(DateService dateService) { + this.dateService = dateService; + } + + private DetailedHostedServiceProperties.Builder builder = DetailedHostedServiceProperties.builder(); + + private String name; + + @Override + public DetailedHostedServiceProperties getResult() { + try { + return builder.fromHostedServiceProperties(super.getResult()).build(); + } finally { + builder = DetailedHostedServiceProperties.builder(); + } + } + + @Override + public void endElement(String uri, String name, String qName) throws SAXException { + if (equalsOrSuffix(qName, "DateCreated")) { + builder.created(dateService.iso8601SecondsDateParse(currentOrNull(currentText))); + } else if (equalsOrSuffix(qName, "DateLastModified")) { + builder.lastModified(dateService.iso8601SecondsDateParse(currentOrNull(currentText))); + } else if (equalsOrSuffix(qName, "Status")) { + String rawStatus = currentOrNull(currentText); + builder.rawStatus(rawStatus); + builder.status(Status.fromValue(rawStatus)); + } else if (equalsOrSuffix(qName, "Name")) { + this.name = currentOrNull(currentText); + } else if (equalsOrSuffix(qName, "Value")) { + builder.addExtendedProperty(this.name, currentOrNull(currentText)); + this.name = null; + } else { + super.endElement(uri, name, qName); + } + currentText.setLength(0); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java new file mode 100644 index 0000000..b592f95 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/DiskHandler.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import java.net.URI; +import javax.inject.Inject; +import org.jclouds.azurecompute.domain.Disk; +import org.jclouds.azurecompute.domain.OSType; +import org.jclouds.http.functions.ParseSax; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import static org.jclouds.util.SaxUtils.currentOrNull; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; + +/** + * @see api + */ +public class DiskHandler extends + ParseSax.HandlerForGeneratedRequestWithResult { + + private final AttachmentHandler attachmentHandler; + + @Inject + private DiskHandler(AttachmentHandler attachmentHandler) { + this.attachmentHandler = attachmentHandler; + } + + private StringBuilder currentText = new StringBuilder(); + private Disk.Builder builder = Disk.builder(); + + private boolean inAttachment; + + @Override + public Disk getResult() { + try { + return builder.build(); + } finally { + builder = Disk.builder(); + } + } + + @Override + public void startElement(String uri, String localName, String qName, + Attributes attributes) throws SAXException { + if (equalsOrSuffix(qName, "AttachedTo")) { + inAttachment = true; + } + } + + @Override + public void endElement(String uri, String name, String qName) + throws SAXException { + if (equalsOrSuffix(qName, "AttachedTo")) { + builder.attachedTo(attachmentHandler.getResult()); + inAttachment = false; + } else if (inAttachment) { + attachmentHandler.endElement(uri, name, qName); + } else if (equalsOrSuffix(qName, "OS")) { + builder.os(OSType.fromValue(currentOrNull(currentText))); + } else if (equalsOrSuffix(qName, "Name")) { + builder.name(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "LogicalDiskSizeInGB")) { + String gb = currentOrNull(currentText); + if (gb != null) + builder.logicalSizeInGB(Integer.parseInt(gb)); + } else if (equalsOrSuffix(qName, "Description")) { + builder.description(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "Location")) { + builder.location(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "AffinityGroup")) { + builder.affinityGroup(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "MediaLink")) { + String link = currentOrNull(currentText); + if (link != null) + builder.mediaLink(URI.create(link)); + } else if (equalsOrSuffix(qName, "SourceImageName")) { + builder.sourceImage(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "Label")) { + builder.label(currentOrNull(currentText)); + } + currentText.setLength(0); + } + + @Override + public void characters(char ch[], int start, int length) { + if (inAttachment) { + attachmentHandler.characters(ch, start, length); + } else { + currentText.append(ch, start, length); + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ErrorHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ErrorHandler.java new file mode 100644 index 0000000..3d7f2f4 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ErrorHandler.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import org.jclouds.azurecompute.domain.Error; +import org.jclouds.azurecompute.domain.Error.Code; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; +import org.xml.sax.SAXException; + +/** + * @see api + */ +public class ErrorHandler extends ParseSax.HandlerForGeneratedRequestWithResult { + + private StringBuilder currentText = new StringBuilder(); + private Error.Builder builder = Error.builder(); + + @Override + public Error getResult() { + try { + return builder.build(); + } finally { + builder = Error.builder(); + } + } + + @Override + public void endElement(String uri, String name, String qName) throws SAXException { + if (qName.equals("Code")) { + String rawCode = SaxUtils.currentOrNull(currentText); + builder.rawCode(rawCode); + builder.code(Code.fromValue(rawCode)); + } else if (qName.equals("Message")) { + builder.message(SaxUtils.currentOrNull(currentText)); + } + currentText.setLength(0); + } + + @Override + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceHandler.java new file mode 100644 index 0000000..2962c42 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceHandler.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import java.net.URI; +import javax.inject.Inject; +import org.jclouds.azurecompute.domain.HostedService; +import org.jclouds.azurecompute.domain.HostedService.Builder; +import org.jclouds.http.functions.ParseSax; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import static org.jclouds.util.SaxUtils.currentOrNull; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; + +/** + * @see api + */ +public class HostedServiceHandler extends ParseSax.HandlerForGeneratedRequestWithResult { + + private final HostedServicePropertiesHandler hostedServicePropertiesHandler; + + @Inject protected HostedServiceHandler(HostedServicePropertiesHandler hostedServicePropertiesHandler) { + this.hostedServicePropertiesHandler = hostedServicePropertiesHandler; + } + + private StringBuilder currentText = new StringBuilder(); + protected HostedService.Builder builder = builder(); + + protected Builder builder() { + return HostedService.builder(); + } + + private boolean inHostedServiceProperties; + + @Override + public HostedService getResult() { + try { + return builder.build(); + } finally { + builder = builder(); + } + } + + @Override + public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { + if (equalsOrSuffix(qName, "HostedServiceProperties")) { + inHostedServiceProperties = true; + } + if (inHostedServiceProperties) { + hostedServicePropertiesHandler.startElement(url, name, qName, attributes); + } + } + + @Override + public void endElement(String uri, String name, String qName) throws SAXException { + + if (equalsOrSuffix(qName, "HostedServiceProperties")) { + builder.properties(hostedServicePropertiesHandler.getResult()); + inHostedServiceProperties = false; + } else if (inHostedServiceProperties) { + hostedServicePropertiesHandler.endElement(uri, name, qName); + } else if (equalsOrSuffix(qName, "Url")) { + builder.url(URI.create(currentOrNull(currentText))); + } else if (equalsOrSuffix(qName, "ServiceName")) { + builder.name(currentOrNull(currentText)); + } + currentText.setLength(0); + } + + @Override + public void characters(char ch[], int start, int length) { + if (inHostedServiceProperties) { + hostedServicePropertiesHandler.characters(ch, start, length); + } else { + currentText.append(ch, start, length); + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServicePropertiesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServicePropertiesHandler.java new file mode 100644 index 0000000..835ce3a --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServicePropertiesHandler.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import org.jclouds.azurecompute.domain.HostedServiceProperties; +import org.jclouds.http.functions.ParseSax; +import org.xml.sax.SAXException; + +import static com.google.common.base.Charsets.UTF_8; +import static com.google.common.io.BaseEncoding.base64; +import static org.jclouds.util.SaxUtils.currentOrNull; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; + +/** + * @see api + */ +public class HostedServicePropertiesHandler extends + ParseSax.HandlerForGeneratedRequestWithResult { + + protected StringBuilder currentText = new StringBuilder(); + private HostedServiceProperties.Builder builder = HostedServiceProperties.builder(); + + @Override + public HostedServiceProperties getResult() { + try { + return builder.build(); + } finally { + builder = HostedServiceProperties.builder(); + } + } + + @Override + public void endElement(String uri, String name, String qName) throws SAXException { + if (equalsOrSuffix(qName, "Description")) { + builder.description(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "Location")) { + builder.location(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "AffinityGroup")) { + builder.affinityGroup(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "Label")) { + builder.label(new String(base64().decode(currentOrNull(currentText)), UTF_8)); + } + currentText.setLength(0); + } + + @Override + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceWithDetailedPropertiesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceWithDetailedPropertiesHandler.java new file mode 100644 index 0000000..69193b1 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/HostedServiceWithDetailedPropertiesHandler.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import javax.inject.Inject; +import org.jclouds.azurecompute.domain.HostedServiceWithDetailedProperties; + +public class HostedServiceWithDetailedPropertiesHandler extends HostedServiceHandler { + + @Inject protected HostedServiceWithDetailedPropertiesHandler( + DetailedHostedServicePropertiesHandler hostedServicePropertiesHandler) { + super(hostedServicePropertiesHandler); + } + + @Override + protected HostedServiceWithDetailedProperties.Builder builder() { + return HostedServiceWithDetailedProperties.builder(); + } + + @Override + public HostedServiceWithDetailedProperties getResult() { + try { + return HostedServiceWithDetailedProperties.class.cast(builder.build()); + } finally { + builder = builder(); + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java new file mode 100644 index 0000000..08adfea --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ImageHandler.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import com.google.common.base.Splitter; +import com.google.common.base.Strings; +import java.net.URI; +import org.jclouds.azurecompute.domain.Image; +import org.jclouds.azurecompute.domain.OSType; +import org.jclouds.http.functions.ParseSax; +import org.xml.sax.SAXException; + +import static org.jclouds.util.SaxUtils.currentOrNull; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; + +/** + * @see api + */ +public class ImageHandler extends ParseSax.HandlerForGeneratedRequestWithResult { + + private StringBuilder currentText = new StringBuilder(); + private Image.Builder builder = Image.builder(); + + @Override + public Image getResult() { + try { + return builder.build(); + } finally { + builder = Image.builder(); + } + } + + @Override + public void endElement(String uri, String name, String qName) throws SAXException { + if (equalsOrSuffix(qName, "OS")) { + builder.os(OSType.fromValue(currentOrNull(currentText))); + } else if (equalsOrSuffix(qName, "Name")) { + builder.name(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "LogicalSizeInGB")) { + String gb = currentOrNull(currentText); + if (gb != null) + builder.logicalSizeInGB(Integer.parseInt(gb)); + } else if (equalsOrSuffix(qName, "Description")) { + builder.description(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "Category")) { + builder.category(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "Location")) { + builder.location(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "AffinityGroup")) { + builder.affinityGroup(currentOrNull(currentText)); + } else if (equalsOrSuffix(qName, "MediaLink")) { + String link = currentOrNull(currentText); + if (link != null) + builder.mediaLink(URI.create(link)); + } else if (equalsOrSuffix(qName, "Eula")) { + String eulaField = currentOrNull(currentText); + if (eulaField != null) { + for (String eula : Splitter.on(';').split(eulaField)) { + if ((eula = Strings.emptyToNull(eula.trim())) != null) { // Dirty data in RightScale eula field. + builder.eula(eula); + } + } + } + } else if (equalsOrSuffix(qName, "Label")) { + builder.label(currentOrNull(currentText)); + } + currentText.setLength(0); + } + + @Override + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListDisksHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListDisksHandler.java new file mode 100644 index 0000000..fb6ea13 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListDisksHandler.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; +import com.google.inject.Inject; +import java.util.List; +import org.jclouds.azurecompute.domain.Disk; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +public class ListDisksHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { + + private final DiskHandler diskHandler; + + private Builder disks = ImmutableList. builder(); + + private boolean inDisk; + + @Inject + public ListDisksHandler(final DiskHandler diskHandler) { + this.diskHandler = diskHandler; + } + + @Override + public List getResult() { + return disks.build(); + } + + @Override + public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { + if (SaxUtils.equalsOrSuffix(qName, "Disk")) { + inDisk = true; + } + if (inDisk) { + diskHandler.startElement(url, name, qName, attributes); + } + } + + @Override + public void endElement(String uri, String name, String qName) throws SAXException { + if (qName.equals("Disk")) { + inDisk = false; + disks.add(diskHandler.getResult()); + } else if (inDisk) { + diskHandler.endElement(uri, name, qName); + } + } + + @Override + public void characters(char ch[], int start, int length) { + if (inDisk) { + diskHandler.characters(ch, start, length); + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListHostedServicesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListHostedServicesHandler.java new file mode 100644 index 0000000..875e787 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListHostedServicesHandler.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; +import com.google.inject.Inject; +import java.util.List; +import org.jclouds.azurecompute.domain.HostedServiceWithDetailedProperties; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +/** + * @see doc + */ +public class ListHostedServicesHandler extends + ParseSax.HandlerForGeneratedRequestWithResult> { + + private final HostedServiceWithDetailedPropertiesHandler hostedServiceHandler; + + private Builder hostedServices = ImmutableList + . builder(); + + private boolean inHostedService; + + @Inject + public ListHostedServicesHandler(HostedServiceWithDetailedPropertiesHandler hostedServiceHandler) { + this.hostedServiceHandler = hostedServiceHandler; + } + + @Override + public List getResult() { + return hostedServices.build(); + } + + @Override + public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { + if (SaxUtils.equalsOrSuffix(qName, "HostedService")) { + inHostedService = true; + } + if (inHostedService) { + hostedServiceHandler.startElement(url, name, qName, attributes); + } + } + + @Override + public void endElement(String uri, String name, String qName) throws SAXException { + if (qName.equals("HostedService")) { + inHostedService = false; + hostedServices.add(hostedServiceHandler.getResult()); + } else if (inHostedService) { + hostedServiceHandler.endElement(uri, name, qName); + } + } + + @Override + public void characters(char ch[], int start, int length) { + if (inHostedService) { + hostedServiceHandler.characters(ch, start, length); + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java new file mode 100644 index 0000000..beae350 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListImagesHandler.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; +import com.google.inject.Inject; +import java.util.List; +import org.jclouds.azurecompute.domain.Image; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +public class ListImagesHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { + + private final ImageHandler locationHandler; + + private Builder locations = ImmutableList. builder(); + + private boolean inOSImage; + + @Inject + public ListImagesHandler(ImageHandler locationHandler) { + this.locationHandler = locationHandler; + } + + @Override + public List getResult() { + return locations.build(); + } + + @Override + public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { + if (SaxUtils.equalsOrSuffix(qName, "OSImage")) { + inOSImage = true; + } + if (inOSImage) { + locationHandler.startElement(url, name, qName, attributes); + } + } + + @Override + public void endElement(String uri, String name, String qName) throws SAXException { + if (qName.equals("OSImage")) { + inOSImage = false; + locations.add(locationHandler.getResult()); + } else if (inOSImage) { + locationHandler.endElement(uri, name, qName); + } + } + + @Override + public void characters(char ch[], int start, int length) { + if (inOSImage) { + locationHandler.characters(ch, start, length); + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListLocationsHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListLocationsHandler.java new file mode 100644 index 0000000..f257a6a --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListLocationsHandler.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; +import com.google.inject.Inject; +import java.util.List; +import org.jclouds.azurecompute.domain.Location; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +public class ListLocationsHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { + + private final LocationHandler locationHandler; + + private Builder locations = ImmutableList. builder(); + + private boolean inLocation; + + @Inject + public ListLocationsHandler(LocationHandler locationHandler) { + this.locationHandler = locationHandler; + } + + @Override + public List getResult() { + return locations.build(); + } + + @Override + public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { + if (SaxUtils.equalsOrSuffix(qName, "Location")) { + inLocation = true; + } + if (inLocation) { + locationHandler.startElement(url, name, qName, attributes); + } + } + + @Override + public void endElement(String uri, String name, String qName) throws SAXException { + if (qName.equals("Location")) { + inLocation = false; + locations.add(locationHandler.getResult()); + } else if (inLocation) { + locationHandler.endElement(uri, name, qName); + } + } + + @Override + public void characters(char ch[], int start, int length) { + if (inLocation) { + locationHandler.characters(ch, start, length); + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/LocationHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/LocationHandler.java new file mode 100644 index 0000000..01d2b9e --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/LocationHandler.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import org.jclouds.azurecompute.domain.Location; +import org.jclouds.http.functions.ParseSax; +import org.jclouds.util.SaxUtils; +import org.xml.sax.SAXException; + +/** + * @see api + */ +public class LocationHandler extends ParseSax.HandlerForGeneratedRequestWithResult { + + private StringBuilder currentText = new StringBuilder(); + private Location.Builder builder = Location.builder(); + + @Override + public Location getResult() { + try { + return builder.build(); + } finally { + builder = Location.builder(); + } + } + + @Override + public void endElement(String uri, String name, String qName) throws SAXException { + if (qName.equals("Name")) { + builder.name(SaxUtils.currentOrNull(currentText)); + } else if (qName.equals("DisplayName")) { + builder.displayName(SaxUtils.currentOrNull(currentText)); + } else if (qName.equals("AvailableService")) { + builder.addAvailableService(SaxUtils.currentOrNull(currentText)); + } + currentText.setLength(0); + } + + @Override + public void characters(char ch[], int start, int length) { + currentText.append(ch, start, length); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OperationHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OperationHandler.java new file mode 100644 index 0000000..e0a6912 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/OperationHandler.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.xml; + +import javax.inject.Inject; +import org.jclouds.azurecompute.domain.Operation; +import org.jclouds.azurecompute.domain.Operation.Builder; +import org.jclouds.azurecompute.domain.Operation.Status; +import org.jclouds.http.functions.ParseSax; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; + +import static org.jclouds.util.SaxUtils.currentOrNull; +import static org.jclouds.util.SaxUtils.equalsOrSuffix; + +/** + * @see api + */ +public class OperationHandler extends ParseSax.HandlerForGeneratedRequestWithResult { + + private final ErrorHandler errorHandler; + + @Inject + private OperationHandler(ErrorHandler errorHandler) { + this.errorHandler = errorHandler; + } + + private StringBuilder currentText = new StringBuilder(); + private Operation.Builder builder = builder(); + + private Builder builder() { + return Operation.builder(); + } + + private boolean inError; + + @Override + public Operation getResult() { + try { + return builder.build(); + } finally { + builder = builder(); + } + } + + @Override + public void startElement(String url, String name, String qName, Attributes attributes) throws SAXException { + if (equalsOrSuffix(qName, "Error")) { + inError = true; + } + if (inError) { + errorHandler.startElement(url, name, qName, attributes); + } + } + + @Override + public void endElement(String uri, String name, String qName) throws SAXException { + if (equalsOrSuffix(qName, "Error")) { + builder.error(errorHandler.getResult()); + inError = false; + } else if (inError) { + errorHandler.endElement(uri, name, qName); + } else if (equalsOrSuffix(qName, "ID")) { + builder.id(currentOrNull(currentText)); + } else if (qName.equals("Status")) { + String rawStatus = currentOrNull(currentText); + builder.rawStatus(rawStatus); + builder.status(Status.fromValue(rawStatus)); + } else if (equalsOrSuffix(qName, "HttpStatusCode")) { + builder.httpStatusCode(Integer.parseInt(currentOrNull(currentText))); + } + currentText.setLength(0); + } + + @Override + public void characters(char ch[], int start, int length) { + if (inError) { + errorHandler.characters(ch, start, length); + } else { + currentText.append(ch, start, length); + } + } +} diff --git a/azurecompute/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/azurecompute/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000..05b8f1f --- /dev/null +++ b/azurecompute/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.azurecompute.AzureComputeProviderMetadata diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/AzureComputeProviderMetadataTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/AzureComputeProviderMetadataTest.java new file mode 100644 index 0000000..a7e7eb7 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/AzureComputeProviderMetadataTest.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute; + +import org.jclouds.providers.internal.BaseProviderMetadataTest; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "AzureManagementProviderMetadataTest") +public class AzureComputeProviderMetadataTest extends BaseProviderMetadataTest { + + public AzureComputeProviderMetadataTest() { + super(new AzureComputeProviderMetadata(), new AzureManagementApiMetadata()); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java new file mode 100644 index 0000000..e0bd956 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DeploymentApiMockTest.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; +import org.jclouds.azurecompute.domain.DeploymentParams; +import org.jclouds.azurecompute.domain.OSType; +import org.jclouds.azurecompute.domain.RoleSize; +import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; +import org.jclouds.azurecompute.parse.GetDeploymentTest; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +@Test(groups = "unit", testName = "DeploymentApiMockTest") +public class DeploymentApiMockTest extends BaseAzureComputeApiMockTest { + + public void create() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice"); + + DeploymentParams params = DeploymentParams.builder().osType(OSType.LINUX).name("mydeployment") + .username("username").password("testpwd").size(RoleSize.MEDIUM) + .sourceImageName("OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd") + .storageAccount("portalvhds0g7xhnq2x7t21").build(); + + assertThat(api.create(params)).isEqualTo("request-1"); + + assertSent(server, "POST", "/services/hostedservices/myservice/deployments", "/deploymentparams.xml"); + } finally { + server.shutdown(); + } + } + + public void getWhenFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(xmlResponse("/deployment.xml")); + + try { + DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice"); + + assertThat(api.get("mydeployment")).isEqualTo(GetDeploymentTest.expected()); + + assertSent(server, "GET", "/services/hostedservices/myservice/deployments/mydeployment"); + } finally { + server.shutdown(); + } + } + + public void getWhenNotFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice"); + + assertThat(api.get("mydeployment")).isNull(); + + assertSent(server, "GET", "/services/hostedservices/myservice/deployments/mydeployment"); + } finally { + server.shutdown(); + } + } + + public void deleteWhenFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice"); + + assertThat(api.delete("mydeployment")).isEqualTo("request-1"); + + assertSent(server, "DELETE", "/services/hostedservices/myservice/deployments/mydeployment"); + } finally { + server.shutdown(); + } + } + + public void deleteWhenNotFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + DeploymentApi api = api(server.getUrl("/")).getDeploymentApiForService("myservice"); + + assertThat(api.delete("mydeployment")).isNull(); + + assertSent(server, "DELETE", "/services/hostedservices/myservice/deployments/mydeployment"); + } finally { + server.shutdown(); + } + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java new file mode 100644 index 0000000..eb16847 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiLiveTest.java @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableSet; +import java.util.List; +import org.jclouds.azurecompute.domain.Disk; +import org.jclouds.azurecompute.domain.Image; +import org.jclouds.azurecompute.domain.Location; +import org.jclouds.azurecompute.domain.OSType; +import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.transform; +import static org.testng.Assert.assertNotEquals; +import static org.testng.Assert.assertTrue; + +@Test(groups = "live", testName = "DiskApiLiveTest") +public class DiskApiLiveTest extends BaseAzureComputeApiLiveTest { + + private ImmutableSet locations; + private ImmutableSet images; + + @BeforeClass(groups = { "integration", "live" }) + public void setup() { + super.setup(); + + locations = ImmutableSet.copyOf(transform(api.getLocationApi().list(), + new Function() { + @Override + public String apply(Location in) { + return in.getName(); + } + })); + images = ImmutableSet.copyOf(transform(api.getImageApi().list(), new Function() { + @Override + public String apply(Image in) { + return in.getName(); + } + })); + } + + @Test + protected void testList() { + List response = api().list(); + + for (Disk disk : response) { + checkDisk(disk); + } + } + + private void checkDisk(Disk disk) { + checkNotNull(disk.getName(), "Name cannot be null for Disk %s", disk.getLabel()); + checkNotNull(disk.getOS(), "OS cannot be null for Disk: %s", disk); + assertNotEquals(disk.getOS(), OSType.UNRECOGNIZED, "Status cannot be UNRECOGNIZED for Disk: " + disk); + + checkNotNull(disk.getAttachedTo(), "While AttachedTo can be null for Disk, its Optional wrapper cannot: %s", disk); + if (disk.getAttachedTo().isPresent()) { + // TODO: verify you can lookup the role + } + + checkNotNull(disk.getLogicalSizeInGB(), + "While LogicalSizeInGB can be null for Disk, its Optional wrapper cannot: %s", disk); + + if (disk.getLogicalSizeInGB().isPresent()) + assertTrue(disk.getLogicalSizeInGB().get() > 0, "LogicalSizeInGB should be positive, if set" + disk.toString()); + + checkNotNull(disk.getMediaLink(), "While MediaLink can be null for Disk, its Optional wrapper cannot: %s", disk); + + if (disk.getMediaLink().isPresent()) + assertTrue(ImmutableSet.of("http", "https").contains(disk.getMediaLink().get().getScheme()), + "MediaLink should be an http(s) url" + disk.toString()); + + checkNotNull(disk.getLabel(), "While Label can be null for Disk, its Optional wrapper cannot: %s", + disk); + + checkNotNull(disk.getDescription(), "While Description can be null for Disk, its Optional wrapper cannot: %s", + disk); + + checkNotNull(disk.getLocation(), "While Location can be null for Disk, its Optional wrapper cannot: %s", disk); + if (disk.getLocation().isPresent()) { + assertTrue(locations.contains(disk.getLocation().get()), + "Location not in " + locations + " :" + disk.toString()); + } + + checkNotNull(disk.getSourceImage(), "While SourceImage can be null for Disk, its Optional wrapper cannot: %s", + disk); + if (disk.getSourceImage().isPresent()) { + assertTrue(images.contains(disk.getSourceImage().get()), + "SourceImage not in " + images + " :" + disk.toString()); + } + + checkNotNull(disk.getAffinityGroup(), + "While AffinityGroup can be null for Disk, its Optional wrapper cannot: %s", disk); + if (disk.getAffinityGroup().isPresent()) { + // TODO: list getAffinityGroups and check if there + } + } + + private DiskApi api() { + return api.getDiskApi(); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiMockTest.java new file mode 100644 index 0000000..c6fab15 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/DiskApiMockTest.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; +import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; +import org.jclouds.azurecompute.parse.ListDisksTest; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +@Test(groups = "unit", testName = "DiskApiMockTest") +public class DiskApiMockTest extends BaseAzureComputeApiMockTest { + + public void listWhenFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(xmlResponse("/disks.xml")); + + try { + DiskApi api = api(server.getUrl("/")).getDiskApi(); + + assertThat(api.list()).containsExactlyElementsOf(ListDisksTest.expected()); + + assertSent(server, "GET", "/services/disks"); + } finally { + server.shutdown(); + } + } + + public void listWhenNotFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + DiskApi api = api(server.getUrl("/")).getDiskApi(); + + assertThat(api.list()).isEmpty(); + + assertSent(server, "GET", "/services/disks"); + } finally { + server.shutdown(); + } + } + + public void deleteWhenFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + DiskApi api = api(server.getUrl("/")).getDiskApi(); + + assertThat(api.delete("my-disk")).isEqualTo("request-1"); + + assertSent(server, "DELETE", "/services/disks/my-disk"); + } finally { + server.shutdown(); + } + } + + public void deleteWhenNotFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + DiskApi api = api(server.getUrl("/")).getDiskApi(); + + assertThat(api.delete("my-disk")).isNull(); + + assertSent(server, "DELETE", "/services/disks/my-disk"); + } finally { + server.shutdown(); + } + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java new file mode 100644 index 0000000..558689f --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiLiveTest.java @@ -0,0 +1,168 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; +import java.util.List; +import java.util.logging.Logger; +import org.jclouds.azurecompute.domain.DetailedHostedServiceProperties; +import org.jclouds.azurecompute.domain.HostedService; +import org.jclouds.azurecompute.domain.HostedService.Status; +import org.jclouds.azurecompute.domain.HostedServiceWithDetailedProperties; +import org.jclouds.azurecompute.domain.Operation; +import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.jclouds.util.Predicates2.retry; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotEquals; +import static org.testng.Assert.assertTrue; + +@Test(groups = "live", testName = "HostedServiceApiLiveTest") +public class HostedServiceApiLiveTest extends BaseAzureComputeApiLiveTest { + + public static final String HOSTED_SERVICE = (System.getProperty("user.name") + "-jclouds-hostedService") + .toLowerCase(); + + private Predicate operationSucceeded; + private Predicate hostedServiceCreated; + private Predicate hostedServiceGone; + + private String location; + + @BeforeClass(groups = { "integration", "live" }) + public void setup() { + super.setup(); + // TODO: filter locations on those who have compute + location = Iterables.get(api.getLocationApi().list(), 0).getName(); + operationSucceeded = retry(new Predicate() { + public boolean apply(String input) { + return api.getOperationApi().get(input).getStatus() == Operation.Status.SUCCEEDED; + } + }, 600, 5, 5, SECONDS); + hostedServiceCreated = retry(new Predicate() { + public boolean apply(HostedServiceWithDetailedProperties input) { + return api().getDetails(input.getName()).getProperties().getStatus() == Status.CREATED; + } + }, 600, 5, 5, SECONDS); + hostedServiceGone = retry(new Predicate() { + public boolean apply(HostedService input) { + return api().get(input.getName()) == null; + } + }, 600, 5, 5, SECONDS); + } + + private HostedServiceWithDetailedProperties hostedService; + + public void testCreateHostedService() { + + String requestId = api().createServiceWithLabelInLocation(HOSTED_SERVICE, HOSTED_SERVICE, location); + assertTrue(operationSucceeded.apply(requestId), requestId); + Logger.getAnonymousLogger().info("operation succeeded: " + requestId); + + hostedService = api().getDetails(HOSTED_SERVICE); + Logger.getAnonymousLogger().info("created hostedService: " + hostedService); + + assertEquals(hostedService.getName(), HOSTED_SERVICE); + + checkHostedService(hostedService); + + assertTrue(hostedServiceCreated.apply(hostedService), hostedService.toString()); + hostedService = api().getDetails(hostedService.getName()); + Logger.getAnonymousLogger().info("hostedService available: " + hostedService); + + } + + @Test(dependsOnMethods = "testCreateHostedService") + public void testDeleteHostedService() { + String requestId = api().delete(hostedService.getName()); + assertTrue(operationSucceeded.apply(requestId), requestId); + Logger.getAnonymousLogger().info("operation succeeded: " + requestId); + + assertTrue(hostedServiceGone.apply(hostedService), hostedService.toString()); + Logger.getAnonymousLogger().info("hostedService deleted: " + hostedService); + } + + @Override + @AfterClass(groups = "live") + protected void tearDown() { + String requestId = api().delete(HOSTED_SERVICE); + if (requestId != null) + operationSucceeded.apply(requestId); + + super.tearDown(); + } + + @Test + protected void testList() { + List response = api().list(); + + for (HostedServiceWithDetailedProperties hostedService : response) { + checkHostedService(hostedService); + } + + if (response.size() > 0) { + HostedService hostedService = response.iterator().next(); + Assert.assertEquals(api().getDetails(hostedService.getName()), hostedService); + } + } + + private void checkHostedService(HostedServiceWithDetailedProperties hostedService) { + checkNotNull(hostedService.getUrl(), "Url cannot be null for a HostedService."); + checkNotNull(hostedService.getName(), "ServiceName cannot be null for HostedService %s", hostedService.getUrl()); + checkNotNull(hostedService.getProperties(), "Properties cannot be null for HostedService %s", + hostedService.getUrl()); + checkProperties(hostedService.getProperties()); + } + + private void checkProperties(DetailedHostedServiceProperties hostedService) { + checkNotNull(hostedService.getDescription(), + "While Description can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s", + hostedService); + checkNotNull(hostedService.getLocation(), + "While Location can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s", + hostedService); + checkNotNull(hostedService.getAffinityGroup(), + "While AffinityGroup can be null for DetailedHostedServiceProperties, its Optional wrapper cannot: %s", + hostedService); + checkState(hostedService.getLocation().isPresent() || hostedService.getAffinityGroup().isPresent(), + "Location or AffinityGroup must be present for DetailedHostedServiceProperties: %s", hostedService); + checkNotNull(hostedService.getLabel(), "Label cannot be null for HostedService %s", hostedService); + + checkNotNull(hostedService.getStatus(), "Status cannot be null for DetailedHostedServiceProperties: %s", + hostedService); + assertNotEquals(hostedService.getStatus(), Status.UNRECOGNIZED, + "Status cannot be UNRECOGNIZED for DetailedHostedServiceProperties: " + hostedService); + checkNotNull(hostedService.getCreated(), "Created cannot be null for DetailedHostedServiceProperties %s", + hostedService); + checkNotNull(hostedService.getLastModified(), + "LastModified cannot be null for DetailedHostedServiceProperties %s", hostedService); + checkNotNull(hostedService.getExtendedProperties(), + "ExtendedProperties cannot be null for DetailedHostedServiceProperties %s", hostedService); + } + + private HostedServiceApi api() { + return api.getHostedServiceApi(); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java new file mode 100644 index 0000000..a2a4aaf --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/HostedServiceApiMockTest.java @@ -0,0 +1,186 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import com.google.common.collect.ImmutableMap; +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; +import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; +import org.jclouds.azurecompute.parse.GetHostedServiceDetailsTest; +import org.jclouds.azurecompute.parse.GetHostedServiceTest; +import org.jclouds.azurecompute.parse.ListHostedServicesTest; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.jclouds.azurecompute.options.CreateHostedServiceOptions.Builder.description; + +@Test(groups = "unit", testName = "HostedServiceApiMockTest") +public class HostedServiceApiMockTest extends BaseAzureComputeApiMockTest { + + public void listWhenFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(xmlResponse("/hostedservices.xml")); + + try { + HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi(); + + assertThat(api.list()).containsExactlyElementsOf(ListHostedServicesTest.expected()); + + assertSent(server, "GET", "/services/hostedservices"); + } finally { + server.shutdown(); + } + } + + public void listWhenNotFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi(); + + assertThat(api.list()).isEmpty(); + + assertSent(server, "GET", "/services/hostedservices"); + } finally { + server.shutdown(); + } + } + + public void getWhenFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(xmlResponse("/hostedservice.xml")); + + try { + HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi(); + + assertThat(api.get("myservice")).isEqualTo(GetHostedServiceTest.expected()); + + assertSent(server, "GET", "/services/hostedservices/myservice"); + } finally { + server.shutdown(); + } + } + + public void getWhenNotFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi(); + + assertThat(api.get("myservice")).isNull(); + + assertSent(server, "GET", "/services/hostedservices/myservice"); + } finally { + server.shutdown(); + } + } + + public void getDetailsWhenFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(xmlResponse("/hostedservice_details.xml")); + + try { + HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi(); + + assertThat(api.getDetails("myservice")).isEqualTo(GetHostedServiceDetailsTest.expected()); + + assertSent(server, "GET", "/services/hostedservices/myservice?embed-detail=true"); + } finally { + server.shutdown(); + } + } + + public void getDetailsWhenNotFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi(); + + assertThat(api.getDetails("myservice")).isNull(); + + assertSent(server, "GET", "/services/hostedservices/myservice?embed-detail=true"); + } finally { + server.shutdown(); + } + } + + public void createServiceWithLabelInLocation() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi(); + + assertThat(api.createServiceWithLabelInLocation("myservice", "service mine", "West US")) + .isEqualTo("request-1"); + + assertSent(server, "POST", "/services/hostedservices", "/create_hostedservice_location.xml"); + } finally { + server.shutdown(); + } + } + + public void createServiceWithLabelInLocationOptions() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi(); + + assertThat(api.createServiceWithLabelInLocation("myservice", "service mine", "West US", + description("my description").extendedProperties(ImmutableMap.of("Role", "Production")))) + .isEqualTo("request-1"); + + assertSent(server, "POST", "/services/hostedservices", "/create_hostedservice_location_options.xml"); + } finally { + server.shutdown(); + } + } + + public void deleteWhenFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi(); + + assertThat(api.delete("myservice")).isEqualTo("request-1"); + + assertSent(server, "DELETE", "/services/hostedservices/myservice"); + } finally { + server.shutdown(); + } + } + + public void deleteWhenNotFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + HostedServiceApi api = api(server.getUrl("/")).getHostedServiceApi(); + + assertThat(api.delete("myservice")).isNull(); + + assertSent(server, "DELETE", "/services/hostedservices/myservice"); + } finally { + server.shutdown(); + } + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java new file mode 100644 index 0000000..3507147 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiLiveTest.java @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableSet; +import java.util.List; +import org.jclouds.azurecompute.domain.Image; +import org.jclouds.azurecompute.domain.Location; +import org.jclouds.azurecompute.domain.OSType; +import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.transform; +import static org.assertj.core.api.Assertions.assertThat; +import static org.testng.Assert.assertNotEquals; +import static org.testng.Assert.assertTrue; + +@Test(groups = "live", testName = "ImageApiLiveTest") +public class ImageApiLiveTest extends BaseAzureComputeApiLiveTest { + + private ImmutableSet locations; + + @BeforeClass(groups = { "integration", "live" }) + public void setup() { + super.setup(); + + locations = ImmutableSet.copyOf(transform(api.getLocationApi().list(), + new Function() { + @Override + public String apply(Location in) { + return in.getName(); + } + })); + } + + @Test + protected void testList() { + List response = api().list(); + + for (Image image : response) { + checkOSImage(image); + } + } + + private void checkOSImage(Image image) { + checkNotNull(image.getLabel(), "Label cannot be null for OSImage %s", image); + checkNotNull(image.getName(), "Name cannot be null for OSImage %s", image.getLabel()); + checkNotNull(image.getOS(), "OS cannot be null for OSImage: %s", image); + assertNotEquals(image.getOS(), OSType.UNRECOGNIZED, "Status cannot be UNRECOGNIZED for OSImage: " + image); + + checkNotNull(image.getCategory(), "While Category can be null for OSImage, its Optional wrapper cannot: %s", + image); + if (image.getCategory().isPresent()) + assertNotEquals("", image.getCategory().get().trim(), "Invalid Category: " + image.toString()); + + checkNotNull(image.getLogicalSizeInGB(), + "While LogicalSizeInGB can be null for OSImage, its Optional wrapper cannot: %s", image); + + if (image.getLogicalSizeInGB().isPresent()) + assertTrue(image.getLogicalSizeInGB().get() > 0, + "LogicalSizeInGB should be positive, if set" + image.toString()); + + checkNotNull(image.getMediaLink(), "While MediaLink can be null for OSImage, its Optional wrapper cannot: %s", + image); + + if (image.getMediaLink().isPresent()) + assertTrue(ImmutableSet.of("http", "https").contains(image.getMediaLink().get().getScheme()), + "MediaLink should be an http(s) url" + image.toString()); + + checkNotNull(image.getDescription(), + "While Description can be null for OSImage, its Optional wrapper cannot: %s", image); + + checkNotNull(image.getLocation(), "While Location can be null for OSImage, its Optional wrapper cannot: %s", + image); + if (image.getLocation().isPresent()) { + assertTrue(locations.contains(image.getLocation().get()), + "Location not in " + locations + " :" + image.toString()); + } + + // Ex. Dirty data in RightScale eula field comes out as an empty string. + assertThat(image.getEula()).isNotNull().doesNotContain(""); + + checkNotNull(image.getAffinityGroup(), + "While AffinityGroup can be null for OSImage, its Optional wrapper cannot: %s", image); + if (image.getAffinityGroup().isPresent()) { + // TODO: list getAffinityGroups and check if there + } + } + + private ImageApi api() { + return api.getImageApi(); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java new file mode 100644 index 0000000..6c7b5c4 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/ImageApiMockTest.java @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; +import java.net.URI; +import org.jclouds.azurecompute.domain.ImageParams; +import org.jclouds.azurecompute.domain.OSType; +import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; +import org.jclouds.azurecompute.parse.ListImagesTest; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +@Test(groups = "unit", testName = "ImageApiMockTest") +public class ImageApiMockTest extends BaseAzureComputeApiMockTest { + + public void listWhenFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(xmlResponse("/images.xml")); + + try { + ImageApi api = api(server.getUrl("/")).getImageApi(); + + assertThat(api.list()).containsExactlyElementsOf(ListImagesTest.expected()); + + assertSent(server, "GET", "/services/images"); + } finally { + server.shutdown(); + } + } + + public void listWhenNotFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + ImageApi api = api(server.getUrl("/")).getImageApi(); + + assertThat(api.list()).isEmpty(); + + assertSent(server, "GET", "/services/images"); + } finally { + server.shutdown(); + } + } + + public void add() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + ImageApi api = api(server.getUrl("/")).getImageApi(); + + ImageParams params = ImageParams.builder().name("myimage").label("foo").os(OSType.LINUX) + .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build(); + + assertThat(api.add(params)).isEqualTo("request-1"); + + assertSent(server, "POST", "/services/images", "/imageparams.xml"); + } finally { + server.shutdown(); + } + } + + public void update() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + ImageApi api = api(server.getUrl("/")).getImageApi(); + + ImageParams params = ImageParams.builder().name("myimage").label("foo").os(OSType.LINUX) + .mediaLink(URI.create("http://example.blob.core.windows.net/disks/mydisk.vhd")).build(); + + assertThat(api.update(params)).isEqualTo("request-1"); + + assertSent(server, "PUT", "/services/images/myimage", "/imageparams.xml"); + } finally { + server.shutdown(); + } + } + + public void deleteWhenFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + ImageApi api = api(server.getUrl("/")).getImageApi(); + + assertThat(api.delete("myimage")).isEqualTo("request-1"); + + assertSent(server, "DELETE", "/services/images/myimage"); + } finally { + server.shutdown(); + } + } + + public void deleteWhenNotFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + ImageApi api = api(server.getUrl("/")).getImageApi(); + + assertThat(api.delete("myimage")).isNull(); + + assertSent(server, "DELETE", "/services/images/myimage"); + } finally { + server.shutdown(); + } + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiLiveTest.java new file mode 100644 index 0000000..455ef11 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiLiveTest.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.Iterables; +import java.util.Arrays; +import java.util.List; +import org.jclouds.azurecompute.domain.Location; +import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest; +import org.testng.annotations.Test; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; + +@Test(groups = "live", testName = "LocationApiLiveTest") +public class LocationApiLiveTest extends BaseAzureComputeApiLiveTest { + + @Test + protected void testList() { + List response = api().list(); + + for (Location location : response) { + checkLocation(location); + } + + } + + private Predicate knownServices = Predicates + .in(Arrays.asList("Compute", "Storage", "PersistentVMRole", "HighMemory")); + + private void checkLocation(Location location) { + checkNotNull(location.getName(), "Name cannot be null for a Location."); + checkNotNull(location.getDisplayName(), "DisplayName cannot be null for Location %s", location.getName()); + checkNotNull(location.getAvailableServices(), "AvailableServices cannot be null for Location %s", + location.getName()); + checkState(Iterables.all(location.getAvailableServices(), knownServices), + "AvailableServices in Location %s didn't match %s: %s", location.getName(), knownServices, + location.getAvailableServices()); + } + + private LocationApi api() { + return api.getLocationApi(); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java new file mode 100644 index 0000000..695b54d --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/LocationApiMockTest.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; +import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; +import org.jclouds.azurecompute.parse.ListLocationsTest; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +@Test(groups = "unit", testName = "LocationApiMockTest") +public class LocationApiMockTest extends BaseAzureComputeApiMockTest { + + public void listWhenLocationsFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(xmlResponse("/locations.xml")); + + try { + LocationApi api = api(server.getUrl("/")).getLocationApi(); + + assertThat(api.list()).containsExactlyElementsOf(ListLocationsTest.expected()); + + assertSent(server, "GET", "/locations"); + } finally { + server.shutdown(); + } + } + + public void listWhenLocationsNotFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + LocationApi api = api(server.getUrl("/")).getLocationApi(); + + assertThat(api.list()).isEmpty(); + + assertSent(server, "GET", "/locations"); + } finally { + server.shutdown(); + } + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/OperationApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OperationApiMockTest.java new file mode 100644 index 0000000..2298bc0 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/OperationApiMockTest.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; +import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; +import org.jclouds.azurecompute.parse.GetOperationTest; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +@Test(groups = "unit", testName = "OperationApiMockTest") +public class OperationApiMockTest extends BaseAzureComputeApiMockTest { + + public void getWhenFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(xmlResponse("/operation.xml")); + + try { + OperationApi api = api(server.getUrl("/")).getOperationApi(); + + assertThat(api.get("request-id")).isEqualTo(GetOperationTest.expected()); + + assertSent(server, "GET", "/operations/request-id"); + } finally { + server.shutdown(); + } + } + + public void getWhenNotFound() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + OperationApi api = api(server.getUrl("/")).getOperationApi(); + + assertThat(api.get("request-id")).isNull(); + + assertSent(server, "GET", "/operations/request-id"); + } finally { + server.shutdown(); + } + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java new file mode 100644 index 0000000..7e3ce5a --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/VirtualMachineApiMockTest.java @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.features; + +import com.squareup.okhttp.mockwebserver.MockWebServer; +import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +@Test(groups = "unit", testName = "ApiMockTest") +public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest { + + public void start() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + VirtualMachineApi api = vmApi(server); + + assertThat(api.start("myvm")).isEqualTo("request-1"); + + assertSent(server, "POST", + "/services/hostedservices/my-service/deployments/mydeployment/roleinstances/myvm/Operations", + "/startrolepayload.xml"); + } finally { + server.shutdown(); + } + } + + public void restart() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + VirtualMachineApi api = vmApi(server); + + assertThat(api.restart("myvm")).isEqualTo("request-1"); + + assertSent(server, "POST", + "/services/hostedservices/my-service/deployments/mydeployment/roleinstances/myvm/Operations", + "/restartrolepayload.xml"); + } finally { + server.shutdown(); + } + } + + public void shutdown() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + VirtualMachineApi api = vmApi(server); + + assertThat(api.shutdown("myvm")).isEqualTo("request-1"); + + assertSent(server, "POST", + "/services/hostedservices/my-service/deployments/mydeployment/roleinstances/myvm/Operations", + "/shutdownrolepayload.xml"); + } finally { + server.shutdown(); + } + } + + public void capture() throws Exception { + MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + VirtualMachineApi api = vmApi(server); + + assertThat(api.capture("myvm", "myImageName", "myImageLabel")).isEqualTo("request-1"); + + assertSent(server, "POST", + "/services/hostedservices/my-service/deployments/mydeployment/roleinstances/myvm/Operations", + "/capturerolepayload.xml"); + } finally { + server.shutdown(); + } + } + + private VirtualMachineApi vmApi(MockWebServer server) { + return api(server.getUrl("/")).getVirtualMachineApiForDeploymentInService("mydeployment", "my-service"); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java new file mode 100644 index 0000000..5e3fea4 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiLiveTest.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.internal; + +import java.util.Properties; +import org.jclouds.apis.BaseApiLiveTest; +import org.jclouds.azurecompute.AzureComputeApi; + +import static org.jclouds.azurecompute.config.AzureComputeProperties.SUBSCRIPTION_ID; + +public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest { + + protected String subscriptionId; + + public BaseAzureComputeApiLiveTest() { + provider = "azurecompute"; + } + + @Override + protected Properties setupProperties() { + Properties props = super.setupProperties(); + subscriptionId = setIfTestSystemPropertyPresent(props, SUBSCRIPTION_ID); + return props; + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java new file mode 100644 index 0000000..0ecba9d --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/internal/BaseAzureComputeApiMockTest.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.internal; + +import com.google.common.base.Throwables; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; +import com.squareup.okhttp.mockwebserver.RecordedRequest; +import java.io.IOException; +import java.net.URL; +import java.util.Set; +import org.jclouds.ContextBuilder; +import org.jclouds.azurecompute.AzureComputeApi; +import org.jclouds.concurrent.config.ExecutorServiceModule; +import org.jclouds.util.Strings2; + +import static com.google.common.base.Charsets.UTF_8; +import static com.google.common.util.concurrent.MoreExecutors.newDirectExecutorService; +import static org.assertj.core.api.Assertions.assertThat; + +public class BaseAzureComputeApiMockTest { + private final Set modules = ImmutableSet + .of(new ExecutorServiceModule(newDirectExecutorService(), newDirectExecutorService())); + + protected String provider; + private final String identity; + private final String credential; + + public BaseAzureComputeApiMockTest() { + provider = "azurecompute"; + // self-signed dummy cert: + // keytool -genkey -alias test -keyalg RSA -keysize 1024 -validity 5475 -dname "CN=localhost" -keystore azure-test.p12 -storepass azurepass -storetype pkcs12 + identity = this.getClass().getResource("/azure-test.p12").getFile(); + credential = "azurepass"; + } + + public AzureComputeApi api(URL url) { + return ContextBuilder.newBuilder(provider).credentials(identity, credential).endpoint(url.toString()) + .modules(modules).buildApi(AzureComputeApi.class); + } + + protected static MockWebServer mockAzureManagementServer() throws IOException { + MockWebServer server = new MockWebServer(); + server.play(); + return server; + } + + protected MockResponse xmlResponse(String resource) { + return new MockResponse().addHeader("Content-Type", "application/xml").setBody(stringFromResource(resource)); + } + + protected MockResponse requestIdResponse(String requestId) { + return new MockResponse().addHeader("x-ms-request-id", requestId); + } + + protected String stringFromResource(String resourceName) { + try { + return Strings2.toStringAndClose(getClass().getResourceAsStream(resourceName)); + } catch (IOException e) { + throw Throwables.propagate(e); + } + } + + protected RecordedRequest assertSent(MockWebServer server, String method, String path) throws InterruptedException { + RecordedRequest request = server.takeRequest(); + assertThat(request.getMethod()).isEqualTo(method); + assertThat(request.getPath()).isEqualTo(path); + assertThat(request.getHeader("x-ms-version")).isEqualTo("2012-03-01"); + assertThat(request.getHeader("Accept")).isEqualTo("application/xml"); + return request; + } + + protected RecordedRequest assertSent(MockWebServer server, String method, String path, String resource) + throws InterruptedException { + RecordedRequest request = assertSent(server, method, path); + assertThat(new String(request.getBody(), UTF_8)).isEqualTo(stringFromResource(resource)); + return request; + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ErrorTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ErrorTest.java new file mode 100644 index 0000000..12d38c6 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ErrorTest.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.parse; + +import java.io.InputStream; +import org.jclouds.azurecompute.domain.Error; +import org.jclouds.azurecompute.domain.Error.Code; +import org.jclouds.azurecompute.xml.ErrorHandler; +import org.jclouds.http.functions.BaseHandlerTest; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +@Test(groups = "unit", testName = "ErrorTest") +public class ErrorTest extends BaseHandlerTest { + + public void test() { + InputStream is = getClass().getResourceAsStream("/error.xml"); + + Error expected = expected(); + + ErrorHandler handler = injector.getInstance(ErrorHandler.class); + Error result = factory.create(handler).parse(is); + + assertEquals(result.toString(), expected.toString()); + + } + + public Error expected() { + return Error.builder() + .rawCode("MissingOrInvalidRequiredQueryParameter") + .code(Code.MISSING_OR_INVALID_REQUIRED_QUERY_PARAMETER) + .message("A required query parameter was not specified for this request or was specified incorrectly.") + .build(); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetDeploymentTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetDeploymentTest.java new file mode 100644 index 0000000..129014e --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetDeploymentTest.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.parse; + +import java.io.InputStream; +import java.net.URI; +import org.jclouds.azurecompute.domain.Deployment; +import org.jclouds.azurecompute.domain.DeploymentSlot; +import org.jclouds.azurecompute.domain.DeploymentStatus; +import org.jclouds.azurecompute.domain.InstanceStatus; +import org.jclouds.azurecompute.domain.RoleSize; +import org.jclouds.azurecompute.xml.DeploymentHandler; +import org.jclouds.http.functions.BaseHandlerTest; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +@Test(groups = "unit", testName = "GetDeploymentTest") +public class GetDeploymentTest extends BaseHandlerTest { + + public void test() { + InputStream is = getClass().getResourceAsStream("/deployment.xml"); + + Deployment expected = expected(); + + DeploymentHandler handler = injector.getInstance(DeploymentHandler.class); + Deployment result = factory.create(handler).parse(is); + + assertEquals(result.toString(), expected.toString()); + } + + public static Deployment expected() { + return Deployment.builder() + .deploymentName("neotysss") + .deploymentSlot(DeploymentSlot.PRODUCTION) + .deploymentStatus(DeploymentStatus.RUNNING) + .deploymentLabel("neotysss") + .deploymentURL(URI.create("http://neotysss.cloudapp.net/")) + .roleName("neotysss") + .instanceName("neotysss") + .instanceStatus(InstanceStatus.READY_ROLE) + .instanceSize(RoleSize.MEDIUM) + .privateIpAddress("10.59.244.162") + .publicIpAddress("168.63.27.148") + .build(); + } + +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceDetailsTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceDetailsTest.java new file mode 100644 index 0000000..8a71f50 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceDetailsTest.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.parse; + +import java.io.InputStream; +import java.net.URI; +import org.jclouds.azurecompute.domain.DetailedHostedServiceProperties; +import org.jclouds.azurecompute.domain.HostedService; +import org.jclouds.azurecompute.domain.HostedService.Status; +import org.jclouds.azurecompute.domain.HostedServiceWithDetailedProperties; +import org.jclouds.azurecompute.xml.HostedServiceWithDetailedPropertiesHandler; +import org.jclouds.date.DateService; +import org.jclouds.date.internal.SimpleDateFormatDateService; +import org.jclouds.http.functions.BaseHandlerTest; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +@Test(groups = "unit", testName = "DetailedHostedServiceProperties") +public class GetHostedServiceDetailsTest extends BaseHandlerTest { + + public void test() { + InputStream is = getClass().getResourceAsStream("/hostedservice_details.xml"); + + HostedService expected = expected(); + + HostedServiceWithDetailedPropertiesHandler handler = injector.getInstance(HostedServiceWithDetailedPropertiesHandler.class); + HostedServiceWithDetailedProperties result = HostedServiceWithDetailedProperties.class.cast(factory.create(handler).parse(is)); + + assertEquals(result.toString(), expected.toString()); + + } + + private static final DateService dateService = new SimpleDateFormatDateService(); + + public static HostedServiceWithDetailedProperties expected() { + return HostedServiceWithDetailedProperties.builder() + .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys")) + .name("neotys") + .properties(DetailedHostedServiceProperties.builder() + .description("Implicitly created hosted service2012-08-06 14:55") + .location("West Europe") + .label("neotys") + .rawStatus("Created") + .status(Status.CREATED) + .created(dateService.iso8601SecondsDateParse("2012-08-06T14:55:17Z")) + .lastModified(dateService.iso8601SecondsDateParse("2012-08-06T15:50:34Z")) + .build()) + .build(); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceTest.java new file mode 100644 index 0000000..b5ccd31 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetHostedServiceTest.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.parse; + +import java.io.InputStream; +import java.net.URI; +import org.jclouds.azurecompute.domain.HostedService; +import org.jclouds.azurecompute.domain.HostedServiceProperties; +import org.jclouds.azurecompute.xml.HostedServiceHandler; +import org.jclouds.http.functions.BaseHandlerTest; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +@Test(groups = "unit", testName = "GetHostedServiceTest") +public class GetHostedServiceTest extends BaseHandlerTest { + + public void test() { + InputStream is = getClass().getResourceAsStream("/hostedservice.xml"); + + HostedService expected = expected(); + + HostedServiceHandler handler = injector.getInstance(HostedServiceHandler.class); + HostedService result = factory.create(handler).parse(is); + + assertEquals(result.toString(), expected.toString()); + + } + + public static HostedService expected() { + return HostedService.builder() + .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys")) + .name("neotys") + .properties(HostedServiceProperties.builder() + .description("Implicitly created hosted service2012-08-06 14:55") + .location("West Europe") + .label("neotys") + .build()) + .build(); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetOperationTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetOperationTest.java new file mode 100644 index 0000000..ecf7083 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/GetOperationTest.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.parse; + +import java.io.InputStream; +import org.jclouds.azurecompute.domain.Error; +import org.jclouds.azurecompute.domain.Error.Code; +import org.jclouds.azurecompute.domain.Operation; +import org.jclouds.azurecompute.domain.Operation.Status; +import org.jclouds.azurecompute.xml.OperationHandler; +import org.jclouds.http.functions.BaseHandlerTest; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +@Test(groups = "unit", testName = "GetOperationTest") +public class GetOperationTest extends BaseHandlerTest { + + public void test() { + InputStream is = getClass().getResourceAsStream("/operation.xml"); + + Operation expected = expected(); + + OperationHandler handler = injector.getInstance(OperationHandler.class); + Operation result = factory.create(handler).parse(is); + + assertEquals(result.toString(), expected.toString()); + } + + public static Operation expected() { + return Operation.builder() + .id("request-id") + .rawStatus("Failed") + .status(Status.FAILED) + .httpStatusCode(400) + .error(Error.builder() + .rawCode("MissingOrInvalidRequiredQueryParameter") + .code(Code.MISSING_OR_INVALID_REQUIRED_QUERY_PARAMETER) + .message("A required query parameter was not specified for this request or was specified incorrectly.") + .build()) + .build(); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListDisksTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListDisksTest.java new file mode 100644 index 0000000..8e0a524 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListDisksTest.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.parse; + +import com.google.common.collect.ImmutableSet; +import java.io.InputStream; +import java.net.URI; +import java.util.List; +import java.util.Set; +import org.jclouds.azurecompute.domain.Disk; +import org.jclouds.azurecompute.domain.Disk.Attachment; +import org.jclouds.azurecompute.domain.OSType; +import org.jclouds.azurecompute.xml.ListDisksHandler; +import org.jclouds.http.functions.BaseHandlerTest; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +@Test(groups = "unit", testName = "ListDisksTest") +public class ListDisksTest extends BaseHandlerTest { + + public void test() { + InputStream is = getClass().getResourceAsStream("/disks.xml"); + + Set expected = expected(); + + ListDisksHandler handler = injector.getInstance(ListDisksHandler.class); + List result = factory.create(handler).parse(is); + + assertEquals(result.toString(), expected.toString()); + + } + + public static Set expected() { + + return ImmutableSet.builder() + .add(Disk.builder() + .os(OSType.LINUX) + .location("West Europe") + .logicalSizeInGB(30) + .mediaLink(URI.create("http://neotysbucket1.blob.core.windows.net/vhds/testimage2-testimage2-2012-08-17.vhd")) + .name("testimage2-testimage2-0-20120817095145") + .sourceImage("OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd") + .build()) + .add(Disk.builder() + .attachedTo(Attachment.builder().deployment("neotysss").hostedService("neotysss").role("neotysss").build()) + .os(OSType.WINDOWS) + .location("West Europe") + .logicalSizeInGB(30) + .mediaLink(URI.create("http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/neotysss/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd")) + .name("neotysss-neotysss-0-20120824091357") + .sourceImage("MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd") + .build()) + .build(); + } + +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListHostedServicesTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListHostedServicesTest.java new file mode 100644 index 0000000..3eaf136 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListHostedServicesTest.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.parse; + +import com.google.common.collect.ImmutableList; +import java.io.InputStream; +import java.net.URI; +import java.util.List; +import org.jclouds.azurecompute.domain.DetailedHostedServiceProperties; +import org.jclouds.azurecompute.domain.HostedService.Status; +import org.jclouds.azurecompute.domain.HostedServiceWithDetailedProperties; +import org.jclouds.azurecompute.xml.ListHostedServicesHandler; +import org.jclouds.date.DateService; +import org.jclouds.date.internal.SimpleDateFormatDateService; +import org.jclouds.http.functions.BaseHandlerTest; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +@Test(groups = "unit", testName = "ListHostedServicesTest") +public class ListHostedServicesTest extends BaseHandlerTest { + + public void test() { + InputStream is = getClass().getResourceAsStream("/hostedservices.xml"); + + List expected = expected(); + + ListHostedServicesHandler handler = injector.getInstance(ListHostedServicesHandler.class); + List result = factory.create(handler).parse(is); + + assertEquals(result.toString(), expected.toString()); + + } + + private static final DateService dateService = new SimpleDateFormatDateService(); + + public static List expected() { + return ImmutableList.builder() + .add(HostedServiceWithDetailedProperties.builder() + .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys")) + .name("neotys") + .properties(DetailedHostedServiceProperties.builder() + .description("Implicitly created hosted service2012-08-06 14:55") + .location("West Europe") + .label("neotys") + .rawStatus("Created") + .status(Status.CREATED) + .created(dateService.iso8601SecondsDateParse("2012-08-06T14:55:17Z")) + .lastModified(dateService.iso8601SecondsDateParse("2012-08-06T15:50:34Z")) + .build()) + .build()) + .add(HostedServiceWithDetailedProperties.builder() + .url(URI.create("https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys3")) + .name("neotys3") + .properties(DetailedHostedServiceProperties.builder() + .location("West Europe") + .label("neotys3") + .rawStatus("Created") + .status(Status.CREATED) + .created(dateService.iso8601SecondsDateParse("2012-08-07T09:00:02Z")) + .lastModified(dateService.iso8601SecondsDateParse("2012-08-07T09:00:02Z")) + .build()) + .build()).build(); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListImagesTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListImagesTest.java new file mode 100644 index 0000000..d9e19b3 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListImagesTest.java @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.parse; + +import com.google.common.collect.ImmutableList; +import java.io.InputStream; +import java.util.List; +import org.jclouds.azurecompute.domain.Image; +import org.jclouds.azurecompute.domain.OSType; +import org.jclouds.azurecompute.xml.ListImagesHandler; +import org.jclouds.http.functions.BaseHandlerTest; +import org.testng.annotations.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +@Test(groups = "unit", testName = "ListOSImagesTest") +public class ListImagesTest extends BaseHandlerTest { + + public void test() { + InputStream is = getClass().getResourceAsStream("/images.xml"); + + ListImagesHandler handler = injector.getInstance(ListImagesHandler.class); + List result = factory.create(handler).parse(is); + + assertThat(result).usingFieldByFieldElementComparator().containsExactlyElementsOf(expected()); + } + + public static List expected() { + return ImmutableList.builder() + .add(Image.builder() + .category("Canonical") + .label("Ubuntu Server 12.04 LTS") + .logicalSizeInGB(30) + .name("CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd") + .os(OSType.LINUX) + .eula("http://www.ubuntu.com/project/about-ubuntu/licensing") + .description("Ubuntu Server 12.04 LTS amd64 20120528 Cloud Image").build()) + .add(Image.builder() + .category("Microsoft") + .label("Windows Server 2008 R2 SP1, June 2012") + .logicalSizeInGB(30) + .name("MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd") + .os(OSType.WINDOWS) + .description("Windows Server 2008 R2 is a multi-purpose server.").build()) + .add(Image.builder() + .category("Microsoft") + .label("Microsoft SQL Server 2012 Evaluation Edition") + .logicalSizeInGB(30) + .name("MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd") + .os(OSType.WINDOWS) + .eula("http://go.microsoft.com/fwlink/?LinkID=251820") // NOTE multiple eula. + .eula("http://go.microsoft.com/fwlink/?LinkID=131004") + .description("SQL Server 2012 Evaluation Edition (64-bit).").build()) + .add(Image.builder() + .category("Microsoft") + .label("Windows Server 2012 Release Candidate, July 2012") + .logicalSizeInGB(30) + .name("MSFT__Win2K12RC-Datacenter-201207.02-en.us-30GB.vhd") + .os(OSType.WINDOWS) + .description("Windows Server 2012 incorporates Microsoft's experience building.").build()) + .add(Image.builder() + .category("Microsoft") + .label("Windows Server 2008 R2 SP1, July 2012") + .logicalSizeInGB(30) + .name("MSFT__Win2K8R2SP1-Datacenter-201207.01-en.us-30GB.vhd") + .os(OSType.WINDOWS) + .description("Windows Server 2008 R2 is a multi-purpose server.") + .build()) + .add(Image.builder() + .category("OpenLogic") + .label("OpenLogic CentOS 6.2") + .logicalSizeInGB(30) + .name("OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd") + .os(OSType.LINUX) + .eula("http://www.openlogic.com/azure/service-agreement/") + .description("This distribution of Linux is based on CentOS.").build()) + .add(Image.builder() + .category("SUSE") + .label("openSUSE 12.1") + .logicalSizeInGB(30) + .name("SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd") + .os(OSType.LINUX) + .eula("http://opensuse.org/") + .description("openSUSE is a free and Linux-based operating system!") + .build()) + .add(Image.builder() + .category("SUSE") + .label("SUSE Linux Enterprise Server") + .logicalSizeInGB(30) + .name("SUSE__SUSE-Linux-Enterprise-Server-11SP2-20120601-en-us-30GB.vhd") + .os(OSType.LINUX) + .eula("http://www.novell.com/licensing/eula/") + .description("SUSE Linux Enterprise Server is a highly reliable value.").build()) + .add(Image.builder() + .category("RightScale with Linux") + .label("RightImage-CentOS-6.4-x64-v13.4") + .logicalSizeInGB(10) + .name("0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.4-x64-v13.4") + .os(OSType.LINUX) // No EULA, as RightScale stuffed ';' into the field. + .build()).build(); + } + +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListLocationsTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListLocationsTest.java new file mode 100644 index 0000000..5ec96b1 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/parse/ListLocationsTest.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.parse; + +import com.google.common.collect.ImmutableList; +import java.io.InputStream; +import java.util.List; +import org.jclouds.azurecompute.domain.Location; +import org.jclouds.azurecompute.xml.ListLocationsHandler; +import org.jclouds.http.functions.BaseHandlerTest; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +@Test(groups = "unit", testName = "LocationsTest") +public class ListLocationsTest extends BaseHandlerTest { + + public void test() { + InputStream is = getClass().getResourceAsStream("/locations.xml"); + + List expected = expected(); + + ListLocationsHandler handler = injector.getInstance(ListLocationsHandler.class); + List result = factory.create(handler).parse(is); + + assertEquals(result.toString(), expected.toString()); + + } + + public static List expected() { + List availableServices = ImmutableList.of("Compute", "Storage", "PersistentVMRole"); + return ImmutableList.builder() + .add(Location.builder() + .name("West US") + .displayName("West US") + .availableServices(availableServices) + .build()) + .add(Location.builder() + .name("East US") + .displayName("East US") + .availableServices(availableServices) + .build()) + .add(Location.builder() + .name("East Asia") + .displayName("East Asia") + .availableServices(availableServices) + .build()) + .add(Location.builder() + .name("Southeast Asia") + .displayName("Southeast Asia") + .availableServices(availableServices) + .build()) + .add(Location.builder() + .name("North Europe") + .displayName("North Europe") + .availableServices(availableServices) + .build()) + .add(Location.builder() + .name("West Europe") + .displayName("West Europe") + .availableServices(availableServices) + .build()).build(); + } + +} diff --git a/azurecompute/src/test/resources/azure-test.p12 b/azurecompute/src/test/resources/azure-test.p12 new file mode 100644 index 0000000000000000000000000000000000000000..5250dd6ec2554e87216a48aab04594968e14a325 GIT binary patch literal 1536 zcmY+DdpOg39LM+j?V@4svs|W@`;d(#%c6_>N?U{|DTalLp;4AI)g(uXQ7*aU(v#Fd zZj~hK$gP@DBFVK_qJ-GN(es>BPk(%$&-1+ApU?NN_lv-V{{sS00vBG5K;q9ko}Whn zQa~OTUIOF7Z>-{60vD?JTLeYHxKQLOhOa&VA@kprtTX`Talr}#7ra9-KuG_OS3g&W zsW@<(uTScw7v(mcc}cQr>ltPrcLqTi1jYs9l*M^1()-uj+G z9(^cOUs@3Uv4|qMYG5N}*&j1A7d&)&9b6uKj0lG0mJCEiA1RSJuxuT*GSZjMlx;W4 zkjc}7PuqM(bVi@hbr+8}&`Z7|#0=H^iIG|Rck=h_Jj3MlsG0e1Ixc32E6-gic`XpNOp;;UJl^E0>p zQC$go>4ed`)G@ixo1&1qLovWUq3Dg^+YC?Lt%5(X=eZQ=np;@LzC|z7heCEt-}6}x zV3hO0bEvfec&&hepZy~Ei(nw%(2`6eVp*93TDki6c_tVNHSoCdogme|8y^{3{?!W) z;vSidVDVq}ZEZV!vB~7KW+`d?vHE$*IfXE$6SZ)@r-tlDFVAUV!VrZhG^Wiyj@i8^ zu6q4;;QJPIfTz^-s2%6%0Z!Co9N}Q%0F+W-XW;WpF$&@)gL~huU8* zg+Zdrc0P%H5gpgbVoqYm943us)Gc=TBrnAJnW)ZJ8T(6S1v<;7WzZy!gnUY|s~$>p zxcK#c1w-wrwSxbUzm@A7rm5Dgk0kfdxND}jlND;>c4Onx&c~y5wh&H>^{hB>_pE_do z{uI!nx+ojfBSvXm9_VZiUPb<(x4Ykt*))n%)aZA7>B=@Qb+BcSf!|WBS{o=Lcg~I1 zeH8DFx6L+GQVctwBpA5j6ijS}Sq6Xmn{TGOTbt#k*R(WMs+O)A^LQerdhLiy{?Wwz z?X(i240|&ouuXVbw1yIT~1J*Wdkb?;YvQ5Weu35}wLKdfM+ zqB>*s5LfR#+O1FQHcc7}XA`j}uDGzW`t{#?hw!iv-|)9i>wk`u478jhK!QvLaKQ2ows9MOlYAK!g~TDpR+;PvH=93;`(-{5EH*XQ*w&(N)I;|w zNR=Y+qDzXWQoqw^z*5*1IWnk=ONyUE;UC_^0p{@29@{fP9rMhXN{`Ho9!j#DS`@%k4F9+khuO)i TZKnCCnfbVf&9oPI{HWT$N{yS1 literal 0 HcmV?d00001 diff --git a/azurecompute/src/test/resources/capturerolepayload.xml b/azurecompute/src/test/resources/capturerolepayload.xml new file mode 100644 index 0000000..9414c52 --- /dev/null +++ b/azurecompute/src/test/resources/capturerolepayload.xml @@ -0,0 +1 @@ +CaptureRoleOperationDeletemyImageLabelmyImageName \ No newline at end of file diff --git a/azurecompute/src/test/resources/create_hostedservice_location.xml b/azurecompute/src/test/resources/create_hostedservice_location.xml new file mode 100644 index 0000000..076f562 --- /dev/null +++ b/azurecompute/src/test/resources/create_hostedservice_location.xml @@ -0,0 +1 @@ +myserviceWest US \ No newline at end of file diff --git a/azurecompute/src/test/resources/create_hostedservice_location_options.xml b/azurecompute/src/test/resources/create_hostedservice_location_options.xml new file mode 100644 index 0000000..9f7f8f0 --- /dev/null +++ b/azurecompute/src/test/resources/create_hostedservice_location_options.xml @@ -0,0 +1 @@ +myservicemy descriptionWest USRoleProduction \ No newline at end of file diff --git a/azurecompute/src/test/resources/deployment.xml b/azurecompute/src/test/resources/deployment.xml new file mode 100644 index 0000000..94cebc9 --- /dev/null +++ b/azurecompute/src/test/resources/deployment.xml @@ -0,0 +1,70 @@ + + neotysss + Production + 05aa8ec5d8ee4215894431c7db401b31 + Running + + http://neotysss.cloudapp.net/ + PFNlcnZpY2VDb25maWd1cmF0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL1NlcnZpY2VIb3N0aW5nLzIwMDgvMTAvU2VydmljZUNvbmZpZ3VyYXRpb24iPg0KICA8Um9sZSBuYW1lPSJuZW90eXNzcyI+DQogICAgPEluc3RhbmNlcyBjb3VudD0iMSIgLz4NCiAgPC9Sb2xlPg0KPC9TZXJ2aWNlQ29uZmlndXJhdGlvbj4= + + + neotysss + neotysss + ReadyRole + 0 + 0 + Medium + + 10.59.244.162 + + + SSH + 168.63.27.148 + 22 + 22 + tcp + + + Started + neotys + + + 1 + + + neotysss + + PersistentVMRole + + + NetworkConfiguration + + + 22 + SSH + 22 + tcp + 168.63.27.148 + + + + + + + + ReadWrite + neotysss-neotysss-0-20120824091357 + http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/neotysss/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd + MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd + Windows + + Medium + + + + false + false + 2012-08-24T09:13:53Z + 2012-08-27T08:55:13Z + + \ No newline at end of file diff --git a/azurecompute/src/test/resources/deploymentparams.xml b/azurecompute/src/test/resources/deploymentparams.xml new file mode 100644 index 0000000..fadaff1 --- /dev/null +++ b/azurecompute/src/test/resources/deploymentparams.xml @@ -0,0 +1 @@ +mydeploymentProductionmydeploymentPersistentVMRoleLinuxProvisioningConfigurationmydeploymentusernametestpwdfalseNetworkConfigurationReadWritehttp://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/mydeployment/OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhdOpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhdLinuxMedium \ No newline at end of file diff --git a/azurecompute/src/test/resources/disks.xml b/azurecompute/src/test/resources/disks.xml new file mode 100644 index 0000000..afae399 --- /dev/null +++ b/azurecompute/src/test/resources/disks.xml @@ -0,0 +1,23 @@ + + + Linux + West Europe + 30 + http://neotysbucket1.blob.core.windows.net/vhds/testimage2-testimage2-2012-08-17.vhd + testimage2-testimage2-0-20120817095145 + OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd + + + + neotysss + neotysss + neotysss + + Windows + West Europe + 30 + http://portalvhds0g7xhnq2x7t21.blob.core.windows.net/disks/neotysss/MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd + neotysss-neotysss-0-20120824091357 + MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd + + diff --git a/azurecompute/src/test/resources/error.xml b/azurecompute/src/test/resources/error.xml new file mode 100644 index 0000000..a9f9b2f --- /dev/null +++ b/azurecompute/src/test/resources/error.xml @@ -0,0 +1,5 @@ + + + MissingOrInvalidRequiredQueryParameter + A required query parameter was not specified for this request or was specified incorrectly. + \ No newline at end of file diff --git a/azurecompute/src/test/resources/hostedservice.xml b/azurecompute/src/test/resources/hostedservice.xml new file mode 100644 index 0000000..625aeb3 --- /dev/null +++ b/azurecompute/src/test/resources/hostedservice.xml @@ -0,0 +1,10 @@ + + https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys + neotys + + Implicitly created hosted service2012-08-06 14:55 + + West Europe + + + \ No newline at end of file diff --git a/azurecompute/src/test/resources/hostedservice_details.xml b/azurecompute/src/test/resources/hostedservice_details.xml new file mode 100644 index 0000000..d730cc7 --- /dev/null +++ b/azurecompute/src/test/resources/hostedservice_details.xml @@ -0,0 +1,13 @@ + + https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys + neotys + + Implicitly created hosted service2012-08-06 14:55 + West Europe + + Created + 2012-08-06T14:55:17Z + 2012-08-06T15:50:34Z + + + \ No newline at end of file diff --git a/azurecompute/src/test/resources/hostedservices.xml b/azurecompute/src/test/resources/hostedservices.xml new file mode 100644 index 0000000..66b7589 --- /dev/null +++ b/azurecompute/src/test/resources/hostedservices.xml @@ -0,0 +1,29 @@ + + + https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys + neotys + + Implicitly created hosted service2012-08-06 14:55 + West Europe + + Created + 2012-08-06T14:55:17Z + 2012-08-06T15:50:34Z + + + + + https://management.core.windows.net/eb0347c3-68d4-4550-9b39-5e7e0f92f7db/services/hostedservices/neotys3 + neotys3 + + + West Europe + + Created + 2012-08-07T09:00:02Z + 2012-08-07T09:00:02Z + + + + \ No newline at end of file diff --git a/azurecompute/src/test/resources/imageparams.xml b/azurecompute/src/test/resources/imageparams.xml new file mode 100644 index 0000000..d3279ba --- /dev/null +++ b/azurecompute/src/test/resources/imageparams.xml @@ -0,0 +1 @@ +http://example.blob.core.windows.net/disks/mydisk.vhdmyimageLinux \ No newline at end of file diff --git a/azurecompute/src/test/resources/images.xml b/azurecompute/src/test/resources/images.xml new file mode 100644 index 0000000..e7b37d6 --- /dev/null +++ b/azurecompute/src/test/resources/images.xml @@ -0,0 +1,84 @@ + + + Canonical + + 30 + CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd + Linux + http://www.ubuntu.com/project/about-ubuntu/licensing + Ubuntu Server 12.04 LTS amd64 20120528 Cloud Image + + + Microsoft + + 30 + MSFT__Win2K8R2SP1-120612-1520-121206-01-en-us-30GB.vhd + Windows + + Windows Server 2008 R2 is a multi-purpose server. + + + Microsoft + + 30 + MSFT__Sql-Server-11EVAL-11.0.2215.0-05152012-en-us-30GB.vhd + Windows + http://go.microsoft.com/fwlink/?LinkID=251820;http://go.microsoft.com/fwlink/?LinkID=131004 + SQL Server 2012 Evaluation Edition (64-bit). + + + Microsoft + + 30 + MSFT__Win2K12RC-Datacenter-201207.02-en.us-30GB.vhd + Windows + + Windows Server 2012 incorporates Microsoft's experience building. + + + Microsoft + + 30 + MSFT__Win2K8R2SP1-Datacenter-201207.01-en.us-30GB.vhd + Windows + + Windows Server 2008 R2 is a multi-purpose server. + + + OpenLogic + + 30 + OpenLogic__OpenLogic-CentOS-62-20120531-en-us-30GB.vhd + Linux + http://www.openlogic.com/azure/service-agreement/ + This distribution of Linux is based on CentOS. + + + SUSE + + 30 + SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd + Linux + http://opensuse.org/ + openSUSE is a free and Linux-based operating system! + + + SUSE + + 30 + SUSE__SUSE-Linux-Enterprise-Server-11SP2-20120601-en-us-30GB.vhd + Linux + http://www.novell.com/licensing/eula/ + SUSE Linux Enterprise Server is a highly reliable value. + + + RightScale with Linux + + 10 + 0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.4-x64-v13.4 + Linux + ; + + + \ No newline at end of file diff --git a/azurecompute/src/test/resources/locations.xml b/azurecompute/src/test/resources/locations.xml new file mode 100644 index 0000000..5937871 --- /dev/null +++ b/azurecompute/src/test/resources/locations.xml @@ -0,0 +1,57 @@ + + + + West US + West US + + Compute + Storage + PersistentVMRole + + + + East US + East US + + Compute + Storage + PersistentVMRole + + + + East Asia + East Asia + + Compute + Storage + PersistentVMRole + + + + Southeast Asia + Southeast Asia + + Compute + Storage + PersistentVMRole + + + + North Europe + North Europe + + Compute + Storage + PersistentVMRole + + + + West Europe + West Europe + + Compute + Storage + PersistentVMRole + + + \ No newline at end of file diff --git a/azurecompute/src/test/resources/operation.xml b/azurecompute/src/test/resources/operation.xml new file mode 100644 index 0000000..498d1f0 --- /dev/null +++ b/azurecompute/src/test/resources/operation.xml @@ -0,0 +1,10 @@ + + + request-id + Failed + 400 + + MissingOrInvalidRequiredQueryParameter + A required query parameter was not specified for this request or was specified incorrectly. + + diff --git a/azurecompute/src/test/resources/restartrolepayload.xml b/azurecompute/src/test/resources/restartrolepayload.xml new file mode 100644 index 0000000..4eca508 --- /dev/null +++ b/azurecompute/src/test/resources/restartrolepayload.xml @@ -0,0 +1 @@ +RestartRoleOperation \ No newline at end of file diff --git a/azurecompute/src/test/resources/shutdownrolepayload.xml b/azurecompute/src/test/resources/shutdownrolepayload.xml new file mode 100644 index 0000000..27beee8 --- /dev/null +++ b/azurecompute/src/test/resources/shutdownrolepayload.xml @@ -0,0 +1 @@ +ShutdownRoleOperation \ No newline at end of file diff --git a/azurecompute/src/test/resources/startrolepayload.xml b/azurecompute/src/test/resources/startrolepayload.xml new file mode 100644 index 0000000..4e82022 --- /dev/null +++ b/azurecompute/src/test/resources/startrolepayload.xml @@ -0,0 +1 @@ +StartRoleOperation \ No newline at end of file diff --git a/pom.xml b/pom.xml index c88ed47..9140562 100644 --- a/pom.xml +++ b/pom.xml @@ -65,6 +65,7 @@ + azurecompute docker virtualbox vcloud-director