http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/DeploymentStatus.java ---------------------------------------------------------------------- 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; - } - } -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/DetailedHostedServiceProperties.java ---------------------------------------------------------------------- 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<T extends Builder<T>> extends HostedServiceProperties.Builder<T> { - - protected String rawStatus; - protected Status status; - protected Date created; - protected Date lastModified; - protected ImmutableMap.Builder<String, String> extendedProperties = ImmutableMap.<String, String> 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<String, String> 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<ConcreteBuilder> { - @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<String, String> extendedProperties; - - protected DetailedHostedServiceProperties(Optional<String> description, Optional<String> location, - Optional<String> affinityGroup, String label, String rawStatus, Status status, Date created, - Date lastModified, Map<String, String> 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<String, String> getExtendedProperties() { - return extendedProperties; - } - - /** - * {@inheritDoc} - */ - @Override - public ToStringHelper string() { - return super.string().add("status", rawStatus).add("created", created).add("lastModified", lastModified) - .add("extendedProperties", extendedProperties); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/Disk.java ---------------------------------------------------------------------- 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 <a href="http://msdn.microsoft.com/en-us/library/jj157176" >api</a> - */ -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<T extends Builder<T>> { - protected abstract T self(); - - protected Optional<Attachment> attachedTo = Optional.absent(); - protected OSType os; - protected String name; - protected Optional<Integer> logicalSizeInGB = Optional.absent(); - protected Optional<String> description = Optional.absent(); - protected Optional<String> location = Optional.absent(); - protected Optional<String> affinityGroup = Optional.absent(); - protected Optional<URI> mediaLink = Optional.absent(); - protected Optional<String> sourceImage = Optional.absent(); - protected Optional<String> 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<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final Optional<Attachment> attachedTo; - protected final OSType os; - protected final String name; - protected final Optional<Integer> logicalSizeInGB; - protected final Optional<String> description; - protected final Optional<String> location; - protected final Optional<String> affinityGroup; - protected final Optional<URI> mediaLink; - protected final Optional<String> sourceImage; - protected final Optional<String> label; - protected final boolean hasOperatingSystem; - protected final boolean isCorrupted; - - protected Disk(Optional<Attachment> attachedTo, OSType os, String name, Optional<Integer> logicalSizeInGB, - Optional<String> description, Optional<String> location, Optional<String> affinityGroup, - Optional<URI> mediaLink, Optional<String> sourceImage, Optional<String> 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<Attachment> 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<Integer> getLogicalSizeInGB() { - return logicalSizeInGB; - } - - /** - * The description for the image. - */ - public Optional<String> 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<String> 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<String> 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 - * <subscription-id> value in the operation call. - * - * Example: - * - * http://example.blob.core.windows.net/disks/mydisk.vhd - */ - public Optional<URI> 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<String> getSourceImage() { - return sourceImage; - } - - /** - * The description of the image. - */ - public Optional<String> 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); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/Error.java ---------------------------------------------------------------------- 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 <a href="http://msdn.microsoft.com/en-us/library/ee460801" >api</a> - */ -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(); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedService.java ---------------------------------------------------------------------- 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 <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a> - */ -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<T extends Builder<T>> { - 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<ConcreteBuilder> { - @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); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceProperties.java ---------------------------------------------------------------------- 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 <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a> - */ -public class HostedServiceProperties { - public static Builder<?> builder() { - return new ConcreteBuilder(); - } - - public Builder<?> toBuilder() { - return new ConcreteBuilder().fromHostedServiceProperties(this); - } - - public abstract static class Builder<T extends Builder<T>> { - protected abstract T self(); - - protected Optional<String> description = Optional.absent(); - protected Optional<String> location = Optional.absent(); - protected Optional<String> 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<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final Optional<String> description; - protected final Optional<String> location; - protected final Optional<String> affinityGroup; - protected final String label; - - protected HostedServiceProperties(Optional<String> description, Optional<String> location, - Optional<String> 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<String> 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<String> 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<String> 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); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/HostedServiceWithDetailedProperties.java ---------------------------------------------------------------------- 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<T extends Builder<T>> extends HostedService.Builder<T> { - - @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<ConcreteBuilder> { - @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); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/InputEndpoint.java ---------------------------------------------------------------------- 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 - + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/InstanceStatus.java ---------------------------------------------------------------------- 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; - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/Location.java ---------------------------------------------------------------------- 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 <a href="http://msdn.microsoft.com/en-us/library/gg441293" >api</a> - */ -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<String> availableServices = ImmutableSet.<String> 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<String> availableServices) { - this.availableServices = ImmutableSet.<String> 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<String> availableServices; - - protected Location(String name, String displayName, Iterable<String> 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<String> 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(); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/OSImage.java ---------------------------------------------------------------------- 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 <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a> - */ -public class OSImage { - public static Builder<?> builder() { - return new ConcreteBuilder(); - } - - public Builder<?> toBuilder() { - return new ConcreteBuilder().fromHostedService(this); - } - - public abstract static class Builder<T extends Builder<T>> { - protected abstract T self(); - - protected OSType os; - protected String name; - protected Optional<Integer> logicalSizeInGB = Optional.absent(); - protected Optional<String> description = Optional.absent(); - protected Optional<String> category = Optional.absent(); - protected Optional<String> location = Optional.absent(); - protected Optional<String> affinityGroup = Optional.absent(); - protected Optional<URI> mediaLink = Optional.absent(); - protected Optional<URI> 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<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - protected final OSType os; - protected final String name; - protected final Optional<Integer> logicalSizeInGB; - protected final Optional<String> description; - protected final Optional<String> category; - protected final Optional<String> location; - protected final Optional<String> affinityGroup; - protected final Optional<URI> mediaLink; - protected final Optional<URI> eula; - protected final String label; - - protected OSImage(OSType os, String name, Optional<Integer> logicalSizeInGB, Optional<String> description, - Optional<String> category, Optional<String> location, Optional<String> affinityGroup, - Optional<URI> mediaLink, Optional<URI> 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<Integer> getLogicalSizeInGB() { - return logicalSizeInGB; - } - - /** - * The description for the image. - */ - public Optional<String> 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<String> 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<String> 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<String> 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 - * <subscription-id> value in the operation call. - * - * Example: - * - * http://example.blob.core.windows.net/disks/myimage.vhd - */ - public Optional<URI> getMediaLink() { - return mediaLink; - } - - /** - * The eula for the image, if available. - */ - public Optional<URI> 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); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/OSImageParams.java ---------------------------------------------------------------------- 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 <a href="http://msdn.microsoft.com/en-us/library/jj157191" >api</a> - */ -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 - * <subscription-id> 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); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/OSType.java ---------------------------------------------------------------------- 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; - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/Operation.java ---------------------------------------------------------------------- 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 <a href="http://msdn.microsoft.com/en-us/library/ee460783" >api</a> - */ -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<Integer> httpStatusCode = Optional.absent(); - private Optional<Error> 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<Integer> httpStatusCode; - private final Optional<Error> error; - - protected Operation(String id, String rawStatus, Status status, Optional<Integer> httpStatusCode, Optional<Error> 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<Integer> getHttpStatusCode() { - return httpStatusCode; - } - - /** - * The management service error returned if the asynchronous request failed. - */ - public Optional<Error> 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(); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/6ab58bd2/azure-management/src/main/java/org/jclouds/azure/management/domain/RoleSize.java ---------------------------------------------------------------------- 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; - } - } -}
