http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/strategy/CleanupResources.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/strategy/CleanupResources.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/strategy/CleanupResources.java deleted file mode 100644 index 3ca1a5d..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/strategy/CleanupResources.java +++ /dev/null @@ -1,237 +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.azurecompute.arm.compute.strategy; - -import static com.google.common.base.Predicates.not; -import static com.google.common.base.Predicates.notNull; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.transform; -import static com.google.common.collect.Maps.filterValues; -import static org.jclouds.azurecompute.arm.compute.AzureComputeServiceAdapter.AUTOGENERATED_IP_KEY; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED; -import static org.jclouds.azurecompute.arm.domain.IdReference.extractName; -import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup; - -import java.net.URI; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.azurecompute.arm.AzureComputeApi; -import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName; -import org.jclouds.azurecompute.arm.domain.AvailabilitySet; -import org.jclouds.azurecompute.arm.domain.DataDisk; -import org.jclouds.azurecompute.arm.domain.IdReference; -import org.jclouds.azurecompute.arm.domain.IpConfiguration; -import org.jclouds.azurecompute.arm.domain.ManagedDiskParameters; -import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCard; -import org.jclouds.azurecompute.arm.domain.NetworkProfile.NetworkInterface; -import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup; -import org.jclouds.azurecompute.arm.domain.OSDisk; -import org.jclouds.azurecompute.arm.domain.PublicIPAddress; -import org.jclouds.azurecompute.arm.domain.VirtualMachine; -import org.jclouds.azurecompute.arm.features.NetworkSecurityGroupApi; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.logging.Logger; - -import com.google.common.base.Function; -import com.google.common.base.Joiner; -import com.google.common.base.Predicate; - -@Singleton -public class CleanupResources { - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - private final AzureComputeApi api; - private final Predicate<URI> resourceDeleted; - private final GroupNamingConvention.Factory namingConvention; - - @Inject - CleanupResources(AzureComputeApi azureComputeApi, @Named(TIMEOUT_RESOURCE_DELETED) Predicate<URI> resourceDeleted, - GroupNamingConvention.Factory namingConvention) { - this.api = azureComputeApi; - this.resourceDeleted = resourceDeleted; - this.namingConvention = namingConvention; - } - - public boolean cleanupNode(final String id) { - ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(id); - String resourceGroupName = resourceGroupAndName.resourceGroup(); - - VirtualMachine virtualMachine = api.getVirtualMachineApi(resourceGroupName).get(resourceGroupAndName.name()); - if (virtualMachine == null) { - return true; - } - - logger.debug(">> destroying %s ...", id); - boolean vmDeleted = deleteVirtualMachine(resourceGroupName, virtualMachine); - - // We don't delete the network here, as it is global to the resource - // group. It will be deleted when the resource group is deleted - - cleanupVirtualMachineNICs(virtualMachine); - cleanupManagedDisks(virtualMachine); - cleanupAvailabilitySetIfOrphaned(virtualMachine); - - return vmDeleted; - } - - public boolean cleanupVirtualMachineNICs(VirtualMachine virtualMachine) { - boolean deleted = true; - for (NetworkInterface nicRef : virtualMachine.properties().networkProfile().networkInterfaces()) { - String nicResourceGroup = extractResourceGroup(nicRef.id()); - String nicName = extractName(nicRef.id()); - NetworkInterfaceCard nic = api.getNetworkInterfaceCardApi(nicResourceGroup).get(nicName); - - Iterable<IdReference> publicIps = getPublicIps(nic); - - logger.debug(">> destroying nic %s...", nicName); - URI nicDeletionURI = api.getNetworkInterfaceCardApi(nicResourceGroup).delete(nicName); - deleted &= nicDeletionURI == null || resourceDeleted.apply(nicDeletionURI); - - for (IdReference publicIp : publicIps) { - String publicIpResourceGroup = publicIp.resourceGroup(); - String publicIpName = publicIp.name(); - - PublicIPAddress ip = api.getPublicIPAddressApi(publicIpResourceGroup).get(publicIpName); - if (ip.tags() != null && Boolean.parseBoolean(ip.tags().get(AUTOGENERATED_IP_KEY))) { - logger.debug(">> deleting public ip %s...", publicIpName); - deleted &= api.getPublicIPAddressApi(publicIpResourceGroup).delete(publicIpName); - } - } - } - return deleted; - } - - public boolean cleanupManagedDisks(VirtualMachine virtualMachine) { - Map<String, URI> deleteJobs = new HashMap<String, URI>(); - - OSDisk osDisk = virtualMachine.properties().storageProfile().osDisk(); - deleteManagedDisk(osDisk.managedDiskParameters(), deleteJobs); - - for (DataDisk dataDisk : virtualMachine.properties().storageProfile().dataDisks()) { - deleteManagedDisk(dataDisk.managedDiskParameters(), deleteJobs); - } - - Set<String> nonDeletedDisks = filterValues(deleteJobs, not(resourceDeleted)).keySet(); - if (!nonDeletedDisks.isEmpty()) { - logger.warn(">> could not delete disks: %s", Joiner.on(',').join(nonDeletedDisks)); - } - - return nonDeletedDisks.isEmpty(); - } - - private void deleteManagedDisk(@Nullable ManagedDiskParameters managedDisk, Map<String, URI> deleteJobs) { - if (managedDisk != null) { - IdReference diskRef = IdReference.create(managedDisk.id()); - logger.debug(">> deleting managed disk %s...", diskRef.name()); - URI uri = api.getDiskApi(diskRef.resourceGroup()).delete(diskRef.name()); - if (uri != null) { - deleteJobs.put(diskRef.name(), uri); - } - } - } - - public boolean cleanupSecurityGroupIfOrphaned(String resourceGroup, String group) { - String name = namingConvention.create().sharedNameForGroup(group); - NetworkSecurityGroupApi sgapi = api.getNetworkSecurityGroupApi(resourceGroup); - - boolean deleted = false; - - try { - NetworkSecurityGroup securityGroup = sgapi.get(name); - if (securityGroup != null) { - List<NetworkInterfaceCard> nics = securityGroup.properties().networkInterfaces(); - if (nics == null || nics.isEmpty()) { - logger.debug(">> deleting orphaned security group %s from %s...", name, resourceGroup); - try { - deleted = resourceDeleted.apply(sgapi.delete(name)); - } catch (Exception ex) { - logger.warn(ex, ">> error deleting orphaned security group %s from %s...", name, resourceGroup); - } - } - } - } catch (Exception ex) { - logger.warn(ex, "Error deleting security groups for %s and group %s", resourceGroup, group); - } - - return deleted; - } - - public boolean cleanupAvailabilitySetIfOrphaned(VirtualMachine virtualMachine) { - boolean deleted = true; - IdReference availabilitySetRef = virtualMachine.properties().availabilitySet(); - - if (availabilitySetRef != null) { - String name = availabilitySetRef.name(); - String resourceGroup = availabilitySetRef.resourceGroup(); - AvailabilitySet availabilitySet = api.getAvailabilitySetApi(resourceGroup).get(name); - - if (isOrphanedJcloudsAvailabilitySet(availabilitySet)) { - logger.debug(">> deleting orphaned availability set %s from %s...", name, resourceGroup); - URI uri = api.getAvailabilitySetApi(resourceGroup).delete(name); - deleted = uri == null || resourceDeleted.apply(uri); - } - } - - return deleted; - } - - public boolean deleteResourceGroupIfEmpty(String group) { - boolean deleted = false; - if (api.getResourceGroupApi().resources(group).isEmpty()) { - logger.debug(">> the resource group %s is empty. Deleting...", group); - deleted = resourceDeleted.apply(api.getResourceGroupApi().delete(group)); - } - return deleted; - } - - private Iterable<IdReference> getPublicIps(NetworkInterfaceCard nic) { - return filter(transform(nic.properties().ipConfigurations(), new Function<IpConfiguration, IdReference>() { - @Override - public IdReference apply(IpConfiguration input) { - return input.properties().publicIPAddress(); - } - }), notNull()); - } - - private static boolean isOrphanedJcloudsAvailabilitySet(AvailabilitySet availabilitySet) { - // We check for the presence of the 'jclouds' tag to make sure we only - // delete availability sets that were automatically created by jclouds - return availabilitySet != null - && availabilitySet.tags() != null - && availabilitySet.tags().containsKey("jclouds") - && (availabilitySet.properties().virtualMachines() == null || availabilitySet.properties() - .virtualMachines().isEmpty()); - } - - private boolean deleteVirtualMachine(String group, VirtualMachine virtualMachine) { - return resourceDeleted.apply(api.getVirtualMachineApi(group).delete(virtualMachine.name())); - } - -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/strategy/CreateResourcesThenCreateNodes.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/strategy/CreateResourcesThenCreateNodes.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/strategy/CreateResourcesThenCreateNodes.java deleted file mode 100644 index 511d531..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/strategy/CreateResourcesThenCreateNodes.java +++ /dev/null @@ -1,258 +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.azurecompute.arm.compute.strategy; - -import java.util.Arrays; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.azurecompute.arm.AzureComputeApi; -import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName; -import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndNameAndIngressRules; -import org.jclouds.azurecompute.arm.compute.functions.TemplateToAvailabilitySet; -import org.jclouds.azurecompute.arm.compute.options.AzureTemplateOptions; -import org.jclouds.azurecompute.arm.compute.options.IpOptions; -import org.jclouds.azurecompute.arm.domain.AvailabilitySet; -import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup; -import org.jclouds.azurecompute.arm.domain.PublicIPAddress; -import org.jclouds.azurecompute.arm.domain.ResourceGroup; -import org.jclouds.azurecompute.arm.domain.Subnet; -import org.jclouds.azurecompute.arm.domain.Subnet.SubnetProperties; -import org.jclouds.azurecompute.arm.domain.VirtualNetwork.AddressSpace; -import org.jclouds.azurecompute.arm.domain.VirtualNetwork.VirtualNetworkProperties; -import org.jclouds.compute.config.CustomizationResponse; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName; -import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap; -import org.jclouds.compute.strategy.ListNodesStrategy; -import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet; -import org.jclouds.domain.Location; -import org.jclouds.logging.Logger; -import org.jclouds.util.PasswordGenerator; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Multimap; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkState; -import static com.google.common.collect.Iterables.getOnlyElement; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.DEFAULT_SUBNET_ADDRESS_PREFIX; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.DEFAULT_VNET_ADDRESS_SPACE_PREFIX; -import static org.jclouds.azurecompute.arm.domain.IdReference.extractName; -import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup; -import static org.jclouds.azurecompute.arm.domain.Subnet.extractVirtualNetwork; - -@Singleton -public class CreateResourcesThenCreateNodes extends CreateNodesWithGroupEncodedIntoNameThenAddToSet { - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - private final AzureComputeApi api; - private final LoadingCache<ResourceGroupAndNameAndIngressRules, String> securityGroupMap; - private final String defaultVnetAddressPrefix; - private final String defaultSubnetAddressPrefix; - private final TemplateToAvailabilitySet templateToAvailabilitySet; - private final PasswordGenerator.Config passwordGenerator; - - @Inject - protected CreateResourcesThenCreateNodes( - CreateNodeWithGroupEncodedIntoName addNodeWithGroupStrategy, - ListNodesStrategy listNodesStrategy, - GroupNamingConvention.Factory namingConvention, - @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, - CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory, - AzureComputeApi api, @Named(DEFAULT_VNET_ADDRESS_SPACE_PREFIX) String defaultVnetAddressPrefix, - @Named(DEFAULT_SUBNET_ADDRESS_PREFIX) String defaultSubnetAddressPrefix, - LoadingCache<ResourceGroupAndNameAndIngressRules, String> securityGroupMap, - TemplateToAvailabilitySet templateToAvailabilitySet, - PasswordGenerator.Config passwordGenerator) { - super(addNodeWithGroupStrategy, listNodesStrategy, namingConvention, userExecutor, - customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory); - this.api = api; - this.securityGroupMap = securityGroupMap; - this.defaultVnetAddressPrefix = defaultVnetAddressPrefix; - this.defaultSubnetAddressPrefix = defaultSubnetAddressPrefix; - this.templateToAvailabilitySet = templateToAvailabilitySet; - this.passwordGenerator = passwordGenerator; - } - - @Override - public Map<?, ListenableFuture<Void>> execute(String group, int count, Template template, - Set<NodeMetadata> goodNodes, Map<NodeMetadata, Exception> badNodes, - Multimap<NodeMetadata, CustomizationResponse> customizationResponses) { - - AzureTemplateOptions options = template.getOptions().as(AzureTemplateOptions.class); - - // TODO Generate a private key instead. Also no need to use AUTHENTICATE_SUDO in this case. - generatePasswordIfNoneProvided(template); - - // If there is a script to be run on the node and public key - // authentication has been configured, warn users if the private key - // is not present - if (hasRunScriptWithKeyAuthAndNoPrivateKey(template)) { - logger.warn(">> a runScript was configured but no SSH key has been provided. " - + "Authentication will delegate to the ssh-agent"); - } - - String location = template.getLocation().getId(); - - createResourceGroupIfNeeded(group, location, options); - - normalizeNetworkOptions(options); - createDefaultNetworkIfNeeded(group, location, options); - - configureSecurityGroupForOptions(group, template.getLocation(), options); - configureAvailabilitySetForTemplate(template); - - return super.execute(group, count, template, goodNodes, badNodes, customizationResponses); - } - - // Azure requires that we pass it the VM password. Need to generate one if not overridden by the user. - private void generatePasswordIfNoneProvided(Template template) { - TemplateOptions options = template.getOptions(); - if (options.getLoginPassword() == null) { - Optional<String> passwordOptional = template.getImage().getDefaultCredentials().getOptionalPassword(); - options.overrideLoginPassword(passwordOptional.or(passwordGenerator.generate())); - } - } - - protected synchronized void createDefaultNetworkIfNeeded(String group, String location, AzureTemplateOptions options) { - if (options.getIpOptions().isEmpty()) { - String name = namingConvention.create().sharedNameForGroup(group); - - Subnet subnet = Subnet.builder().name(name) - .properties(SubnetProperties.builder().addressPrefix(defaultSubnetAddressPrefix).build()).build(); - - VirtualNetworkProperties properties = VirtualNetworkProperties.builder() - .addressSpace(AddressSpace.create(Arrays.asList(defaultVnetAddressPrefix))) - .subnets(Arrays.asList(subnet)).build(); - - logger.debug(">> network options have not been configured. Creating network %s(%s) and subnet %s(%s)", name, - defaultVnetAddressPrefix, name, defaultSubnetAddressPrefix); - - api.getVirtualNetworkApi(options.getResourceGroup()).createOrUpdate(name, location, null, properties); - Subnet createdSubnet = api.getSubnetApi(options.getResourceGroup(), name).get(name); - - options.ipOptions(IpOptions.builder().subnet(createdSubnet.id()).allocateNewPublicIp(true).build()); - } - } - - private static boolean hasRunScriptWithKeyAuthAndNoPrivateKey(Template template) { - return template.getOptions().getRunScript() != null && template.getOptions().getPublicKey() != null - && !template.getOptions().hasLoginPrivateKeyOption(); - } - - private void configureSecurityGroupForOptions(String group, Location location, AzureTemplateOptions options) { - - checkArgument(options.getGroups().size() <= 1, - "Only one security group can be configured for each network interface"); - - if (!options.getGroups().isEmpty()) { - ResourceGroupAndName securityGroupId = ResourceGroupAndName.fromSlashEncoded(getOnlyElement(options.getGroups())); - NetworkSecurityGroup securityGroup = api.getNetworkSecurityGroupApi(securityGroupId.resourceGroup()).get( - securityGroupId.name()); - checkArgument(securityGroup != null, "Security group %s was not found", securityGroupId.slashEncode()); - options.securityGroups(securityGroup.id()); - } else if (options.getInboundPorts().length > 0) { - String name = namingConvention.create().sharedNameForGroup(group); - ResourceGroupAndNameAndIngressRules regionAndIdAndIngressRules = ResourceGroupAndNameAndIngressRules.create( - options.getResourceGroup(), location.getId(), name, options.getInboundPorts()); - // this will create if not yet exists. - String securityGroupId = securityGroupMap.getUnchecked(regionAndIdAndIngressRules); - options.securityGroups(securityGroupId); - } - } - - private void configureAvailabilitySetForTemplate(Template template) { - AvailabilitySet availabilitySet = templateToAvailabilitySet.apply(template); - if (availabilitySet != null) { - logger.debug(">> configuring nodes in availability set [%s]", availabilitySet.name()); - template.getOptions().as(AzureTemplateOptions.class).availabilitySet(availabilitySet); - } - } - - private void createResourceGroupIfNeeded(String group, String location, AzureTemplateOptions options) { - if (options.getResourceGroup() == null) { - options.resourceGroup(group); - } - logger.debug(">> using resource group [%s]", options.getResourceGroup()); - ResourceGroup rg = api.getResourceGroupApi().get(options.getResourceGroup()); - if (rg == null) { - logger.debug(">> resource group [%s] does not exist. Creating!", options.getResourceGroup()); - api.getResourceGroupApi().create(options.getResourceGroup(), location, - ImmutableMap.of("description", "jclouds default resource group")); - } - } - - @VisibleForTesting - void normalizeNetworkOptions(AzureTemplateOptions options) { - if (!options.getNetworks().isEmpty() && !options.getIpOptions().isEmpty()) { - throw new IllegalArgumentException("The options.networks and options.ipOptions are exclusive"); - } - - if (!options.getNetworks().isEmpty()) { - // The portable interface allows to configure network IDs (subnet IDs), - // but we don't know the type of the IP configurations to be applied - // when attaching nodes to those networks. We'll assume private IPs - // with Dynamic allocation and new public ip address allocated. - ImmutableList.Builder<IpOptions> ipOptions = ImmutableList.builder(); - for (String subnetId : options.getNetworks()) { - ipOptions.add(IpOptions.builder().subnet(subnetId).allocateNewPublicIp(true).build()); - } - options.ipOptions(ipOptions.build()); - } - - if (!options.getIpOptions().isEmpty()) { - // Eagerly validate that all configured subnets exist. - for (IpOptions ipConfig : options.getIpOptions()) { - if (ipConfig.allocateNewPublicIp() && ipConfig.publicIpId() != null) { - throw new IllegalArgumentException("The allocateNewPublicIps and publicIpId are exclusive"); - } - - String resourceGroup = extractResourceGroup(ipConfig.subnet()); - String networkName = extractVirtualNetwork(ipConfig.subnet()); - String subnetName = extractName(ipConfig.subnet()); - Subnet subnet = api.getSubnetApi(resourceGroup, networkName).get(subnetName); - checkState(subnet != null, "Configured subnet %s does not exist", ipConfig.subnet()); - - if (ipConfig.publicIpId() != null) { - PublicIPAddress publicIp = api.getPublicIPAddressApi(extractResourceGroup(ipConfig.publicIpId())).get( - extractName(ipConfig.publicIpId())); - checkState(publicIp != null, "Configured public ip %s does not exist", ipConfig.publicIpId()); - } - } - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeHttpApiModule.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeHttpApiModule.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeHttpApiModule.java deleted file mode 100644 index 7ba23db..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeHttpApiModule.java +++ /dev/null @@ -1,108 +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.azurecompute.arm.config; - -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; - -import java.net.URI; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.inject.Singleton; - -import org.jclouds.azurecompute.arm.AzureComputeApi; -import org.jclouds.azurecompute.arm.config.GraphRBAC.GraphRBACForTenant; -import org.jclouds.azurecompute.arm.domain.ServicePrincipal; -import org.jclouds.azurecompute.arm.handlers.AzureComputeErrorHandler; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.annotation.ClientError; -import org.jclouds.http.annotation.Redirection; -import org.jclouds.http.annotation.ServerError; -import org.jclouds.location.suppliers.ImplicitLocationSupplier; -import org.jclouds.location.suppliers.implicit.FirstRegion; -import org.jclouds.oauth.v2.config.OAuthConfigFactory; -import org.jclouds.oauth.v2.config.OAuthScopes; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ConfiguresHttpApi; -import org.jclouds.rest.config.HttpApiModule; -import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; - -import com.google.common.base.Supplier; -import com.google.inject.Provides; -import com.google.inject.Scopes; -import com.google.inject.TypeLiteral; -import com.google.inject.name.Named; - -@ConfiguresHttpApi -public class AzureComputeHttpApiModule extends HttpApiModule<AzureComputeApi> { - - private static final Pattern OAUTH_TENANT_PATTERN = Pattern - .compile("https://login.microsoft(?:online)?.com/([^/]+)/oauth2/token"); - - @Override - protected void bindErrorHandlers() { - bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(AzureComputeErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(AzureComputeErrorHandler.class); - bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(AzureComputeErrorHandler.class); - } - - @Override - protected void installLocations() { - super.installLocations(); - bind(ImplicitLocationSupplier.class).to(FirstRegion.class).in(Scopes.SINGLETON); - } - - @Override - protected void configure() { - super.configure(); - bind(OAuthScopes.class).toInstance(OAuthScopes.NoScopes.create()); - bind(OAuthConfigFactory.class).to(AzureOAuthConfigFactory.class).in(Scopes.SINGLETON); - bindServiceEndpoints(); - } - - protected void bindServiceEndpoints() { - bind(new TypeLiteral<Supplier<URI>>() { - }).annotatedWith(GraphRBAC.class).to(GraphRBACForTenant.class).in(Scopes.SINGLETON); - } - - @Provides - @Singleton - @Tenant - protected final String provideTenant(@Named("oauth.endpoint") final String oauthEndpoint) { - Matcher m = OAUTH_TENANT_PATTERN.matcher(oauthEndpoint); - if (!m.matches()) { - throw new IllegalArgumentException("Could not parse tenantId from: " + oauthEndpoint); - } - return m.group(1); - } - - @Provides - @Singleton - protected final Supplier<ServicePrincipal> provideServicePrincipal(final AzureComputeApi api, - AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds) { - // This supplier must be defensive against any auth exception. - return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException, - new Supplier<ServicePrincipal>() { - @Override - public ServicePrincipal get() { - return api.getGraphRBACApi().getCurrentServicePrincipal(); - } - }, seconds, TimeUnit.SECONDS); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeParserModule.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeParserModule.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeParserModule.java deleted file mode 100644 index 396f5be..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeParserModule.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.azurecompute.arm.config; - -import org.jclouds.json.config.GsonModule; - -import com.google.inject.AbstractModule; - -public class AzureComputeParserModule extends AbstractModule { - - @Override - protected void configure() { - bind(GsonModule.DateAdapter.class).to(GsonModule.Iso8601DateAdapter.class); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeProperties.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeProperties.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeProperties.java deleted file mode 100644 index abe057d..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeProperties.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.azurecompute.arm.config; - -/** - * Configuration properties and constants used in Azure Resource Manager - * connections. - */ -public class AzureComputeProperties { - - public static final String OPERATION_TIMEOUT = "jclouds.azurecompute.arm.operation.timeout"; - - public static final String IMAGE_PUBLISHERS = "jclouds.azurecompute.arm.publishers"; - - public static final String TIMEOUT_RESOURCE_DELETED = "jclouds.azurecompute.arm.timeout.resourcedeleted"; - - public static final String DEFAULT_VNET_ADDRESS_SPACE_PREFIX = "jclouds.azurecompute.arm.vnet.addressprefix"; - - public static final String DEFAULT_SUBNET_ADDRESS_PREFIX = "jclouds.azurecompute.arm.subnet.addressprefix"; - - public static final String API_VERSION_PREFIX = "jclouds.azurecompute.arm.apiversion."; - - // Predicate constants - public static final String VAULT_DELETE_STATUS = "jclouds.azurecompute.arm.vault.delete_status"; - public static final String VAULT_KEY_DELETED_STATUS = "jclouds.azurecompute.arm.vault.key.delete_status"; - public static final String VAULT_KEY_RECOVERABLE_STATUS = "jclouds.azurecompute.arm.vault.key.recoverable_status"; - public static final String VAULT_SECRET_DELETE_STATUS = "jclouds.azurecompute.arm.vault.secret.delete_status"; - public static final String VAULT_SECRET_RECOVERABLE_STATUS = "jclouds.azurecompute.arm.vault.secret.recoverable_status"; - public static final String VAULT_CERTIFICATE_DELETE_STATUS = "jclouds.azurecompute.arm.vault.certificate.delete_status"; - public static final String VAULT_CERTIFICATE_RECOVERABLE_STATUS = "jclouds.azurecompute.arm.vault.certificate.recoverable_status"; - public static final String VAULT_CERTIFICATE_OPERATION_STATUS = "jclouds.azurecompute.arm.vault.certificate.operation_status"; -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeRateLimitModule.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeRateLimitModule.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeRateLimitModule.java deleted file mode 100644 index 3038b86..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeRateLimitModule.java +++ /dev/null @@ -1,30 +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.azurecompute.arm.config; - -import org.jclouds.azurecompute.arm.handlers.AzureRateLimitRetryHandler; -import org.jclouds.http.HttpRetryHandler; -import org.jclouds.http.annotation.ClientError; - -import com.google.inject.AbstractModule; - -public class AzureComputeRateLimitModule extends AbstractModule { - @Override - protected void configure() { - bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(AzureRateLimitRetryHandler.class); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureOAuthConfigFactory.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureOAuthConfigFactory.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureOAuthConfigFactory.java deleted file mode 100644 index 9128b59..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureOAuthConfigFactory.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.azurecompute.arm.config; - -import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE; -import static org.jclouds.oauth.v2.config.OAuthProperties.RESOURCE; - -import org.jclouds.http.HttpRequest; -import org.jclouds.oauth.v2.config.OAuthConfigFactory; -import org.jclouds.oauth.v2.config.OAuthScopes; -import org.jclouds.rest.internal.GeneratedHttpRequest; - -import com.google.inject.Inject; -import com.google.inject.name.Named; - -public class AzureOAuthConfigFactory implements OAuthConfigFactory { - private final OAuthScopes scopes; - - @Named(AUDIENCE) - @Inject(optional = true) - private String audience; - - @Named(RESOURCE) - @Inject(optional = true) - private String resource; - - @Inject - AzureOAuthConfigFactory(OAuthScopes scopes) { - this.scopes = scopes; - } - - @Override - public OAuthConfig forRequest(HttpRequest input) { - OAuthResource customResource = null; - if (input instanceof GeneratedHttpRequest) { - GeneratedHttpRequest request = (GeneratedHttpRequest) input; - customResource = request.getInvocation().getInvokable().getAnnotation(OAuthResource.class); - if (customResource == null) { - customResource = request.getInvocation().getInvokable().getDeclaringClass() - .getAnnotation(OAuthResource.class); - } - } - String oauthResource = customResource != null ? customResource.value() : resource; - return OAuthConfig.create(scopes.forRequest(input), audience, oauthResource); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/GraphRBAC.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/GraphRBAC.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/GraphRBAC.java deleted file mode 100644 index a7f8b4f..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/GraphRBAC.java +++ /dev/null @@ -1,54 +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.azurecompute.arm.config; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.net.URI; - -import javax.inject.Inject; -import javax.inject.Qualifier; - -import com.google.common.base.Supplier; - -/** - * Provides the Graph RBAC API endpoint for the current tenant. - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) -@Qualifier -public @interface GraphRBAC { - - String ENDPOINT = "https://graph.windows.net/"; - - static class GraphRBACForTenant implements Supplier<URI> { - private final String tenantId; - - @Inject - GraphRBACForTenant(@Tenant String tenantId) { - this.tenantId = tenantId; - } - - @Override - public URI get() { - return URI.create(GraphRBAC.ENDPOINT + tenantId); - } - - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/OAuthResource.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/OAuthResource.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/OAuthResource.java deleted file mode 100644 index 6e5a2df..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/OAuthResource.java +++ /dev/null @@ -1,35 +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.azurecompute.arm.config; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * Configures a custom OAuth resource for certain APIs and methods. - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = { ElementType.TYPE, ElementType.METHOD }) -@Qualifier -public @interface OAuthResource { - - String value(); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/Tenant.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/Tenant.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/Tenant.java deleted file mode 100644 index 5524361..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/Tenant.java +++ /dev/null @@ -1,34 +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.azurecompute.arm.config; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** - * Qualifies an object that describes the current tenant. - */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) -@Qualifier -public @interface Tenant { - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Availability.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Availability.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Availability.java deleted file mode 100644 index eb8c341..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Availability.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.azurecompute.arm.domain; - -import com.google.auto.value.AutoValue; -import org.jclouds.json.SerializedNames; - -@AutoValue -public abstract class Availability { - - public abstract String nameAvailable(); - - @SerializedNames({"nameAvailable"}) - public static Availability create(final String nameAvailable) { - return new AutoValue_Availability(nameAvailable); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AvailabilitySet.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AvailabilitySet.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AvailabilitySet.java deleted file mode 100644 index 4c4720e..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AvailabilitySet.java +++ /dev/null @@ -1,223 +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.azurecompute.arm.domain; - -import java.util.List; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -/** - * AvailabilitySet for subscription - */ -@AutoValue -public abstract class AvailabilitySet { - - @AutoValue - public abstract static class AvailabilitySetProperties { - - /** - * A platform Update Domain Count - */ - public abstract int platformUpdateDomainCount(); - - /** - * A platform Fault Domain Count - */ - public abstract int platformFaultDomainCount(); - - /** - * A list of virtual machines in the availability set - */ - @Nullable - public abstract List<IdReference> virtualMachines(); - - /** - * A list of statuses in the availability set - */ - @Nullable - public abstract List<Status> statuses(); - - @SerializedNames({ "platformUpdateDomainCount", "platformFaultDomainCount", "virtualMachines", "statuses" }) - public static AvailabilitySetProperties create(final int platformUpdateDomainCount, - final int platformFaultDomainCount, List<IdReference> virtualMachines, List<Status> statuses) { - return builder().platformUpdateDomainCount(platformUpdateDomainCount) - .platformFaultDomainCount(platformFaultDomainCount).virtualMachines(virtualMachines).statuses(statuses) - .build(); - } - - public abstract Builder toBuilder(); - - public static Builder builder() { - return new AutoValue_AvailabilitySet_AvailabilitySetProperties.Builder(); - } - - @AutoValue.Builder - public abstract static class Builder { - public abstract Builder platformUpdateDomainCount(int platformUpdateDomainCount); - public abstract Builder platformFaultDomainCount(int platformFaultDomainCount); - public abstract Builder virtualMachines(List<IdReference> virtualMachines); - public abstract Builder statuses(List<Status> statuses); - - abstract List<IdReference> virtualMachines(); - abstract List<Status> statuses(); - abstract AvailabilitySetProperties autoBuild(); - - public AvailabilitySetProperties build() { - virtualMachines(virtualMachines() != null ? ImmutableList.copyOf(virtualMachines()) : null); - statuses(statuses() != null ? ImmutableList.copyOf(statuses()) : null); - return autoBuild(); - } - } - } - - public static enum AvailabilitySetType { - MANAGED("Aligned"), - CLASSIC("Classic"); - - private final String value; - - AvailabilitySetType(String value) { - this.value = value; - } - - public static AvailabilitySetType fromString(String value) { - AvailabilitySetType[] items = AvailabilitySetType.values(); - for (AvailabilitySetType item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - throw new IllegalArgumentException("Unexpected type: " + value); - } - - @Override - public String toString() { - return this.value; - } - } - - @AutoValue - public abstract static class SKU { - - public abstract AvailabilitySetType type(); - - @SerializedNames({ "name" }) - public static SKU create(final String type) { - return create(AvailabilitySetType.fromString(type)); - } - - public static SKU create(AvailabilitySetType type) { - return new AutoValue_AvailabilitySet_SKU(type); - } - } - - /** - * The id of the availability set - */ - @Nullable - public abstract String id(); - - /** - * The name of the availability set. - */ - @Nullable - public abstract String name(); - - /** - * The type of the availability set. - */ - @Nullable - public abstract String type(); - - /** - * The location of the availability set - */ - @Nullable - public abstract String location(); - - /** - * Specifies the type of the availability set - */ - @Nullable - public abstract SKU sku(); - - /** - * Specifies the tags of the availability set - */ - @Nullable - public abstract Map<String, String> tags(); - - /** - * Specifies the properties of the availability set - */ - @Nullable - public abstract AvailabilitySetProperties properties(); - - @SerializedNames({ "id", "name", "type", "location", "sku", "tags", "properties" }) - public static AvailabilitySet create(final String id, final String name, final String type, final String location, - SKU sku, final Map<String, String> tags, AvailabilitySetProperties properties) { - return builder().id(id).name(name).type(type).location(location).sku(sku).tags(tags).properties(properties) - .build(); - } - - public abstract Builder toBuilder(); - - private static Builder builder() { - return new AutoValue_AvailabilitySet.Builder(); - } - - public static Builder managed() { - return builder().managed(); - } - - public static Builder classic() { - return builder().classic(); - } - - @AutoValue.Builder - public abstract static class Builder { - public abstract Builder id(String id); - public abstract Builder name(String name); - public abstract Builder type(String type); - public abstract Builder location(String location); - public abstract Builder tags(Map<String, String> tags); - public abstract Builder properties(AvailabilitySetProperties properties); - - abstract Builder sku(SKU sku); - public Builder managed() { - return sku(SKU.create(AvailabilitySetType.MANAGED)); - } - public Builder classic() { - return sku(SKU.create(AvailabilitySetType.CLASSIC)); - } - - abstract Map<String, String> tags(); - abstract AvailabilitySet autoBuild(); - - public AvailabilitySet build() { - tags(tags() != null ? ImmutableMap.copyOf(tags()) : null); - return autoBuild(); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/BackendAddressPool.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/BackendAddressPool.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/BackendAddressPool.java deleted file mode 100644 index 37ea4aa..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/BackendAddressPool.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.azurecompute.arm.domain; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class BackendAddressPool { - public abstract String name(); - - @Nullable - public abstract String id(); - - @Nullable - public abstract BackendAddressPoolProperties properties(); - - @Nullable - public abstract String etag(); - - @SerializedNames({ "name", "id", "properties", "etag" }) - public static BackendAddressPool create(final String name, final String id, - final BackendAddressPoolProperties properties, final String etag) { - return new AutoValue_BackendAddressPool(name, id, properties, etag); - } -} - http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/BackendAddressPoolProperties.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/BackendAddressPoolProperties.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/BackendAddressPoolProperties.java deleted file mode 100644 index 4daed6f..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/BackendAddressPoolProperties.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.azurecompute.arm.domain; - -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; - -@AutoValue -public abstract class BackendAddressPoolProperties implements Provisionable { - - @Nullable - public abstract String provisioningState(); - - @Nullable - public abstract List<IdReference> backendIPConfigurations(); - - @Nullable - public abstract List<IdReference> loadBalancingRules(); - - - @SerializedNames({ "provisioningState", "backendIPConfigurations", "loadBalancingRules"}) - public static BackendAddressPoolProperties create(final String provisioningState, - final List<IdReference> backendIPConfigurations, final List<IdReference> loadBalancingRules) { - return builder().provisioningState(provisioningState).backendIPConfigurations(backendIPConfigurations).loadBalancingRules(loadBalancingRules).build(); - } - - public abstract Builder toBuilder(); - - public static Builder builder() { - return new AutoValue_BackendAddressPoolProperties.Builder(); - } - - @AutoValue.Builder - public abstract static class Builder { - - public abstract Builder provisioningState(String provisioningState); - - public abstract Builder backendIPConfigurations(List<IdReference> backendIPConfigurations); - - public abstract Builder loadBalancingRules(List<IdReference> loadBalancingRules); - - abstract List<IdReference> backendIPConfigurations(); - abstract List<IdReference> loadBalancingRules(); - - abstract BackendAddressPoolProperties autoBuild(); - - public BackendAddressPoolProperties build() { - backendIPConfigurations(backendIPConfigurations() != null ? ImmutableList.copyOf(backendIPConfigurations()) - : null); - loadBalancingRules(loadBalancingRules() != null ? ImmutableList.copyOf(loadBalancingRules()) : null); - return autoBuild(); - } - } -} - http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Certificate.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Certificate.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Certificate.java deleted file mode 100644 index 65de40c..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Certificate.java +++ /dev/null @@ -1,638 +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.azurecompute.arm.domain; - -import java.util.Map; -import java.util.List; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - - -@AutoValue -public abstract class Certificate { - @AutoValue - public abstract static class CertificateAttributes { - @Nullable - public abstract Integer created(); - - public abstract boolean enabled(); - - @Nullable - public abstract Integer expiry(); - - @Nullable - public abstract Integer notBefore(); - - @Nullable - public abstract String recoveryLevel(); - - @Nullable - public abstract Integer updated(); - - @SerializedNames({"created", "enabled", "exp", "nbf", "recoveryLevel", "updated"}) - public static CertificateAttributes create(final Integer created, - final boolean enabled, - final Integer expiry, - final Integer notBefore, - final String recoveryLevel, - final Integer updated) { - return new AutoValue_Certificate_CertificateAttributes(created, enabled, expiry, notBefore, recoveryLevel, updated); - } - } - - @AutoValue - public abstract static class IssuerParameters { - @Nullable - public abstract String certType(); - - @Nullable - public abstract String name(); - - @SerializedNames({"cty", "name"}) - public static IssuerParameters create(final String certType, - final String name) { - return new AutoValue_Certificate_IssuerParameters(certType, name); - } - } - - @AutoValue - public abstract static class KeyProperties { - @Nullable - public abstract Boolean exportable(); - - @Nullable - public abstract Integer keySize(); - - @Nullable - public abstract String keyType(); - - @Nullable - public abstract Boolean reuseKey(); - - @SerializedNames({"exportable", "key_size", "kty", "reuse_key"}) - public static KeyProperties create(final boolean exportable, - final Integer keySize, - final String keyType, - final boolean reuseKey) { - return new AutoValue_Certificate_KeyProperties(exportable, keySize, keyType, reuseKey); - } - } - - @AutoValue - public abstract static class LifetimeActionTrigger { - @Nullable - public abstract Integer daysBeforeExpiry(); - - @Nullable - public abstract Integer lifetimePercentage(); - - @SerializedNames({"days_before_expiry", "lifetime_percentage"}) - public static LifetimeActionTrigger create(final Integer daysBeforeExpiry, - final Integer lifetimePercentage) { - return new AutoValue_Certificate_LifetimeActionTrigger(daysBeforeExpiry, lifetimePercentage); - } - } - - @AutoValue - public abstract static class LifetimeActionAction { - public abstract String actionType(); - - @SerializedNames({"action_type"}) - public static LifetimeActionAction create(final String actionType) { - return new AutoValue_Certificate_LifetimeActionAction(actionType); - } - } - - @AutoValue - public abstract static class LifetimeAction { - public abstract LifetimeActionAction action(); - - public abstract LifetimeActionTrigger trigger(); - - @SerializedNames({"action", "trigger"}) - public static LifetimeAction create(final LifetimeActionAction action, - final LifetimeActionTrigger trigger) { - return new AutoValue_Certificate_LifetimeAction(action, trigger); - } - } - - @AutoValue - public abstract static class SecretProperties { - public abstract String contentType(); - - @SerializedNames({"contentType"}) - public static SecretProperties create(final String contentType) { - return new AutoValue_Certificate_SecretProperties(contentType); - } - } - - @AutoValue - public abstract static class SubjectAlternativeNames { - public abstract List<String> dnsNames(); - - public abstract List<String> emails(); - - public abstract List<String> upns(); - - @SerializedNames({"dns_names", "emails", "upns"}) - public static SubjectAlternativeNames create(final List<String> dnsNames, - final List<String> emails, - final List<String> upns) { - return new AutoValue_Certificate_SubjectAlternativeNames( - dnsNames != null ? ImmutableList.copyOf(dnsNames) : ImmutableList.<String> of(), - emails != null ? ImmutableList.copyOf(emails) : ImmutableList.<String> of(), - upns != null ? ImmutableList.copyOf(upns) : ImmutableList.<String> of() - ); - } - } - - @AutoValue - public abstract static class X509CertificateProperties { - public abstract List<String> enhancedKeyUsage(); - - public abstract List<String> keyUsage(); - - @Nullable - public abstract SubjectAlternativeNames subjectAltNames(); - - @Nullable - public abstract String subject(); - - @Nullable - public abstract Integer validityMonths(); - - @SerializedNames({"ekus", "key_usage", "sans", "subject", "validity_months"}) - public static X509CertificateProperties create(final List<String> enhancedKeyUsage, - final List<String> keyUsage, - final SubjectAlternativeNames subjectAltNames, - final String subject, - final Integer validityMonths) { - return new AutoValue_Certificate_X509CertificateProperties( - enhancedKeyUsage != null ? ImmutableList.copyOf(enhancedKeyUsage) : ImmutableList.<String> of(), - keyUsage != null ? ImmutableList.copyOf(keyUsage) : ImmutableList.<String> of(), - subjectAltNames, - subject, - validityMonths - ); - } - } - - @AutoValue - public abstract static class CertificatePolicy { - @Nullable - public abstract CertificateAttributes attributes(); - - @Nullable - public abstract String id(); - - @Nullable - public abstract IssuerParameters issuer(); - - @Nullable - public abstract KeyProperties keyProps(); - - public abstract List<LifetimeAction> lifetimeActions(); - - @Nullable - public abstract SecretProperties secretProps(); - - @Nullable - public abstract X509CertificateProperties x509props(); - - @SerializedNames({"attributes", "id", "issuer", "key_props", "lifetime_actions", "secret_props", "x509_props"}) - public static CertificatePolicy create(final CertificateAttributes attributes, - final String id, - final IssuerParameters issuer, - final KeyProperties keyProps, - final List<LifetimeAction> lifetimeActions, - final SecretProperties secretProperties, - final X509CertificateProperties x509Props) { - return new AutoValue_Certificate_CertificatePolicy( - attributes, - id, - issuer, - keyProps, - lifetimeActions != null ? ImmutableList.copyOf(lifetimeActions) : ImmutableList.<LifetimeAction>of(), - secretProperties, - x509Props - ); - } - } - - @AutoValue - public abstract static class CertificateError { - @Nullable - public abstract String code(); - - @Nullable - public abstract String message(); - - @SerializedNames({"code", "message"}) - public static CertificateError create(final String code, - final String message) { - return new AutoValue_Certificate_CertificateError(code, message); - } - } - - @AutoValue - public abstract static class CertificateOperation { - @Nullable - public abstract Boolean cancellationRequested(); - - @Nullable - public abstract String csr(); - - @Nullable - public abstract CertificateError error(); - - @Nullable - public abstract String id(); - - @Nullable - public abstract IssuerParameters issuer(); - - @Nullable - public abstract String requestId(); - - @Nullable - public abstract String status(); - - @Nullable - public abstract String statusDetails(); - - @Nullable - public abstract String target(); - - @SerializedNames({"cancellation_requested", "csr", "error", "id", "issuer", "request_id", "status", "status_details", "target"}) - public static CertificateOperation create(final boolean cancellationRequested, - final String csr, - final CertificateError error, - final String id, - final IssuerParameters issuer, - final String requestId, - final String status, - final String statusDetails, - final String target) { - return new AutoValue_Certificate_CertificateOperation( - cancellationRequested, - csr, - error, - id, - issuer, - requestId, - status, - statusDetails, - target); - } - } - - @AutoValue - public abstract static class CertificateBundle { - @Nullable - public abstract CertificateAttributes attributes(); - - @Nullable - public abstract String certificate(); - - @Nullable - public abstract String contentType(); - - @Nullable - public abstract String id(); - - @Nullable - public abstract String keyId(); - - @Nullable - public abstract CertificatePolicy policy(); - - @Nullable - public abstract String secretId(); - - @Nullable - public abstract Map<String, String> tags(); - - @Nullable - public abstract String thumbprint(); - - @SerializedNames({"attributes", "cer", "contentType", "id", "kid", "policy", "sid", "tags", "x5t"}) - public static CertificateBundle create(final CertificateAttributes attributes, - final String certificate, - final String contentType, - final String id, - final String keyId, - final CertificatePolicy policy, - final String secretId, - final Map<String, String> tags, - final String thumbprint) { - return new AutoValue_Certificate_CertificateBundle(attributes, - certificate, - contentType, - id, - keyId, - policy, - secretId, - tags != null ? ImmutableMap.copyOf(tags) : null, - thumbprint - ); - } - } - - @AutoValue - public abstract static class CertificateIssuer { - public abstract String id(); - - public abstract String provider(); - - @SerializedNames({"id", "provider"}) - public static CertificateIssuer create(final String id, - final String provider) { - return new AutoValue_Certificate_CertificateIssuer(id, provider); - } - } - - @AutoValue - public abstract static class IssuerAttributes { - @Nullable - public abstract Integer created(); - - @Nullable - public abstract Boolean enabled(); - - @Nullable - public abstract Integer updated(); - - @SerializedNames({"created", "enabled", "updated"}) - public static IssuerAttributes create(final Integer created, - final Boolean enabled, - final Integer updated) { - return new AutoValue_Certificate_IssuerAttributes(created, enabled, updated); - } - } - - @AutoValue - public abstract static class IssuerCredentials { - @Nullable - public abstract String accountId(); - - @Nullable - public abstract String password(); - - @SerializedNames({"account_id", "pwd"}) - public static IssuerCredentials create(final String accountId, - final String password) { - return new AutoValue_Certificate_IssuerCredentials(accountId, password); - } - } - - @AutoValue - public abstract static class OrganizationDetails { - public abstract List<AdministrationDetails> adminDetails(); - - @Nullable - public abstract String id(); - - @SerializedNames({"admin_details", "id"}) - public static OrganizationDetails create(final List<AdministrationDetails> adminDetails, - final String id) { - return new AutoValue_Certificate_OrganizationDetails( - adminDetails != null ? ImmutableList.copyOf(adminDetails) : ImmutableList.<AdministrationDetails> of(), - id - ); - } - } - - @AutoValue - public abstract static class AdministrationDetails { - @Nullable - public abstract String email(); - - @Nullable - public abstract String firstName(); - - @Nullable - public abstract String lastName(); - - @Nullable - public abstract String phoneNumber(); - - @SerializedNames({"email", "first_name", "last_name", "phone"}) - public static AdministrationDetails create(final String email, - final String firstName, - final String lastName, - final String phoneNumber) { - return new AutoValue_Certificate_AdministrationDetails(email, firstName, lastName, phoneNumber); - } - } - - @AutoValue - public abstract static class IssuerBundle { - @Nullable - public abstract IssuerAttributes attributes(); - - @Nullable - public abstract IssuerCredentials credentials(); - - @Nullable - public abstract String id(); - - @Nullable - public abstract OrganizationDetails organizationDetails(); - - @Nullable - public abstract String provider(); - - @SerializedNames({"attributes", "credentials", "id", "org_details", "provider"}) - public static IssuerBundle create(final IssuerAttributes attributes, - final IssuerCredentials credentials, - final String id, - final OrganizationDetails orgDetails, - final String provider) { - return new AutoValue_Certificate_IssuerBundle(attributes, credentials, id, orgDetails, provider); - } - } - - @AutoValue - public abstract static class Contact { - @Nullable - public abstract String email(); - - @Nullable - public abstract String name(); - - @Nullable - public abstract String phone(); - - @SerializedNames({"email", "name", "phone"}) - public static Contact create(final String email, - final String name, - final String phone) { - return new AutoValue_Certificate_Contact(email, name, phone); - } - } - - @AutoValue - public abstract static class Contacts { - public abstract List<Contact> contacts(); - - @Nullable - public abstract String id(); - - @SerializedNames({"contacts", "id"}) - public static Contacts create(final List<Contact> contacts, - final String id) { - return new AutoValue_Certificate_Contacts( - contacts != null ? ImmutableList.copyOf(contacts) : ImmutableList.<Contact> of(), - id - ); - } - } - - @AutoValue - public abstract static class DeletedCertificateBundle { - @Nullable - public abstract CertificateAttributes attributes(); - - @Nullable - public abstract String bytes(); - - @Nullable - public abstract Integer deletedDate(); - - @Nullable - public abstract String id(); - - @Nullable - public abstract String keyId(); - - @Nullable - public abstract String recoveryId(); - - @Nullable - public abstract Integer scheduledPurgeDate(); - - @Nullable - public abstract String secredId(); - - @Nullable - public abstract Map<String, String> tags(); - - @Nullable - public abstract String thumbprint(); - - @SerializedNames({"attributes", "cer", "deletedDate", "id", "kid", "recoveryId", "scheduledPurgeDate", "sid", "tags", "x5t"}) - public static DeletedCertificateBundle create(final CertificateAttributes attributes, - final String bytes, - final Integer deletedDate, - final String id, - final String keyId, - final String recoveryId, - final Integer scheduledPurgeDate, - final String secretId, - final Map<String, String> tags, - final String thumbprint) { - return new AutoValue_Certificate_DeletedCertificateBundle( - attributes, - bytes, - deletedDate, - id, - keyId, - recoveryId, - scheduledPurgeDate, - secretId, - tags != null ? ImmutableMap.copyOf(tags) : null, - thumbprint - ); - } - } - - @AutoValue - public abstract static class DeletedCertificate { - @Nullable - public abstract CertificateAttributes attributes(); - - @Nullable - public abstract Integer deletedDate(); - - @Nullable - public abstract String id(); - - @Nullable - public abstract String recoveryId(); - - @Nullable - public abstract Integer scheduledPurgeDate(); - - @Nullable - public abstract Map<String, String> tags(); - - @Nullable - public abstract String thumbprint(); - - @SerializedNames({"attributes", "deletedDate", "id", "recoveryId", "scheduledPurgeDate", "tags", "x5t"}) - public static DeletedCertificate create(final CertificateAttributes attributes, - final Integer deletedDate, - final String id, - final String recoveryId, - final Integer scheduledPurgeDate, - final Map<String, String> tags, - final String thumbprint) { - return new AutoValue_Certificate_DeletedCertificate( - attributes, - deletedDate, - id, - recoveryId, - scheduledPurgeDate, - tags != null ? ImmutableMap.copyOf(tags) : null, - thumbprint - ); - } - } - - @Nullable - public abstract CertificateAttributes attributes(); - - @Nullable - public abstract String id(); - - @Nullable - public abstract Map<String, String> tags(); - - @Nullable - public abstract String thumbprint(); - - @SerializedNames({"attributes", "id", "tags", "x5t"}) - public static Certificate create(final CertificateAttributes attributes, - final String id, - final Map<String, String> tags, - final String thumbprint) { - return new AutoValue_Certificate( - attributes, - id, - tags != null ? ImmutableMap.copyOf(tags) : null, - thumbprint - ); - } - - Certificate() { - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ComputeNode.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ComputeNode.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ComputeNode.java deleted file mode 100644 index 516bbf6..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ComputeNode.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.azurecompute.arm.domain; - -import org.jclouds.azurecompute.arm.util.GetEnumValue; - -public class ComputeNode { - public enum Status { - GOOD, - BAD, - UNRECOGNIZED; - - public static Status fromValue(final String text) { - return (Status) GetEnumValue.fromValueOrDefault(text, Status.UNRECOGNIZED); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/ac03bac4/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/CreationData.java ---------------------------------------------------------------------- diff --git a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/CreationData.java b/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/CreationData.java deleted file mode 100644 index ff31ef2..0000000 --- a/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/CreationData.java +++ /dev/null @@ -1,54 +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.azurecompute.arm.domain; - -import org.jclouds.azurecompute.arm.util.GetEnumValue; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.base.CaseFormat; - -@AutoValue -public abstract class CreationData { - - - public enum CreateOptions { - EMPTY, - FROM_IMAGE, - COPY, - IMPORT, - UNRECOGNIZED; - - public static CreateOptions fromValue(final String text) { - return (CreateOptions) GetEnumValue.fromValueOrDefault(text, UNRECOGNIZED); - } - - @Override - public String toString() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name()); - } - } - - @Nullable - public abstract CreateOptions createOption(); - - @SerializedNames({ "createOption" }) - public static CreationData create(CreateOptions createOption) { - return new AutoValue_CreationData(createOption); - } -}
