http://git-wip-us.apache.org/repos/asf/stratos/blob/26070cb4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Account.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Account.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Account.java deleted file mode 100644 index 8dad3a9..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Account.java +++ /dev/null @@ -1,789 +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.cloudstack.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; -import java.util.Map; -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.CaseFormat; -import com.google.common.base.Function; -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; -import com.google.common.collect.ForwardingSet; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; - -/** - * Class Account - */ -public class Account extends ForwardingSet<User> { - - /** - */ - public static enum State { - ENABLED, DISABLED, LOCKED, UNRECOGNIZED; - - @Override - public String toString() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); - } - - public static State fromValue(String state) { - try { - return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state"))); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - - } - - /** - */ - public static enum Type { - /** - * API access for all the resources associated with their account. There - * may be many users in a domain, many domains in a deployment, and many - * users in a deployment. This is typically the end user - */ - USER(0), - /** - * full API access. This is typically a service administrator or code that - * executes with complete trust in the service operator's environment. - */ - ADMIN(1), - /** - * full API access within a domain. This is the most privileged user that - * a given customer has. This may be a reseller for the service provider. - */ - DOMAIN_ADMIN(2), UNRECOGNIZED(Integer.MAX_VALUE); - - private int code; - - private static final Map<Integer, Type> INDEX = Maps.uniqueIndex(ImmutableSet.copyOf(Type.values()), - new Function<Type, Integer>() { - - @Override - public Integer apply(Type input) { - return input.code; - } - - }); - - Type(int code) { - this.code = code; - } - - @Override - public String toString() { - return "" + code; - } - - public static Type fromValue(String type) { - Integer code = Integer.valueOf(checkNotNull(type, "type")); - return INDEX.containsKey(code) ? INDEX.get(code) : UNRECOGNIZED; - } - - } - - public static Builder<?> builder() { - return new ConcreteBuilder(); - } - - public Builder<?> toBuilder() { - return new ConcreteBuilder().fromAccount(this); - } - - public abstract static class Builder<T extends Builder<T>> { - protected abstract T self(); - - protected String id; - protected Account.Type type; - protected String networkDomain; - protected String domain; - protected String domainId; - protected Long IPsAvailable; - protected Long IPLimit; - protected long IPs; - protected boolean cleanupRequired; - protected String name; - protected long receivedBytes; - protected long sentBytes; - protected Long snapshotsAvailable; - protected Long snapshotLimit; - protected long snapshots; - protected Account.State state; - protected Long templatesAvailable; - protected Long templateLimit; - protected long templates; - protected Long VMsAvailable; - protected Long VMLimit; - protected long VMsRunning; - protected long VMsStopped; - protected long VMs; - protected Long volumesAvailable; - protected Long volumeLimit; - protected long volumes; - protected Set<User> users = ImmutableSet.of(); - - /** - * @see Account#getId() - */ - public T id(String id) { - this.id = id; - return self(); - } - - /** - * @see Account#getType() - */ - public T type(Account.Type type) { - this.type = type; - return self(); - } - - /** - * @see Account#getNetworkDomain() - */ - public T networkDomain(String networkDomain) { - this.networkDomain = networkDomain; - return self(); - } - - /** - * @see Account#getDomain() - */ - public T domain(String domain) { - this.domain = domain; - return self(); - } - - /** - * @see Account#getDomainId() - */ - public T domainId(String domainId) { - this.domainId = domainId; - return self(); - } - - /** - * @see Account#getIPsAvailable() - */ - public T IPsAvailable(Long IPsAvailable) { - this.IPsAvailable = IPsAvailable; - return self(); - } - - /** - * @see Account#getIPLimit() - */ - public T IPLimit(Long IPLimit) { - this.IPLimit = IPLimit; - return self(); - } - - /** - * @see Account#getIPs() - */ - public T IPs(long IPs) { - this.IPs = IPs; - return self(); - } - - /** - * @see Account#isCleanupRequired() - */ - public T cleanupRequired(boolean cleanupRequired) { - this.cleanupRequired = cleanupRequired; - return self(); - } - - /** - * @see Account#getName() - */ - public T name(String name) { - this.name = name; - return self(); - } - - /** - * @see Account#getReceivedBytes() - */ - public T receivedBytes(long receivedBytes) { - this.receivedBytes = receivedBytes; - return self(); - } - - /** - * @see Account#getSentBytes() - */ - public T sentBytes(long sentBytes) { - this.sentBytes = sentBytes; - return self(); - } - - /** - * @see Account#getSnapshotsAvailable() - */ - public T snapshotsAvailable(Long snapshotsAvailable) { - this.snapshotsAvailable = snapshotsAvailable; - return self(); - } - - /** - * @see Account#getSnapshotLimit() - */ - public T snapshotLimit(Long snapshotLimit) { - this.snapshotLimit = snapshotLimit; - return self(); - } - - /** - * @see Account#getSnapshots() - */ - public T snapshots(long snapshots) { - this.snapshots = snapshots; - return self(); - } - - /** - * @see Account#getState() - */ - public T state(Account.State state) { - this.state = state; - return self(); - } - - /** - * @see Account#getTemplatesAvailable() - */ - public T templatesAvailable(Long templatesAvailable) { - this.templatesAvailable = templatesAvailable; - return self(); - } - - /** - * @see Account#getTemplateLimit() - */ - public T templateLimit(Long templateLimit) { - this.templateLimit = templateLimit; - return self(); - } - - /** - * @see Account#getTemplates() - */ - public T templates(long templates) { - this.templates = templates; - return self(); - } - - /** - * @see Account#getVMsAvailable() - */ - public T VMsAvailable(Long VMsAvailable) { - this.VMsAvailable = VMsAvailable; - return self(); - } - - /** - * @see Account#getVMLimit() - */ - public T VMLimit(Long VMLimit) { - this.VMLimit = VMLimit; - return self(); - } - - /** - * @see Account#getVMsRunning() - */ - public T VMsRunning(long VMsRunning) { - this.VMsRunning = VMsRunning; - return self(); - } - - /** - * @see Account#getVMsStopped() - */ - public T VMsStopped(long VMsStopped) { - this.VMsStopped = VMsStopped; - return self(); - } - - /** - * @see Account#getVMs() - */ - public T VMs(long VMs) { - this.VMs = VMs; - return self(); - } - - /** - * @see Account#getVolumesAvailable() - */ - public T volumesAvailable(Long volumesAvailable) { - this.volumesAvailable = volumesAvailable; - return self(); - } - - /** - * @see Account#getVolumeLimit() - */ - public T volumeLimit(Long volumeLimit) { - this.volumeLimit = volumeLimit; - return self(); - } - - /** - * @see Account#getVolumes() - */ - public T volumes(long volumes) { - this.volumes = volumes; - return self(); - } - - /** - * @see Account#getUsers() - */ - public T users(Set<User> users) { - this.users = ImmutableSet.copyOf(checkNotNull(users, "users")); - return self(); - } - - public T users(User... in) { - return users(ImmutableSet.copyOf(in)); - } - - public Account build() { - return new Account(id, type, networkDomain, domain, domainId, IPsAvailable, IPLimit, IPs, cleanupRequired, name, receivedBytes, sentBytes, snapshotsAvailable, snapshotLimit, snapshots, state, templatesAvailable, templateLimit, templates, VMsAvailable, VMLimit, VMsRunning, VMsStopped, VMs, volumesAvailable, volumeLimit, volumes, users); - } - - public T fromAccount(Account in) { - return this - .id(in.getId()) - .type(in.getType()) - .networkDomain(in.getNetworkDomain()) - .domain(in.getDomain()) - .domainId(in.getDomainId()) - .IPsAvailable(in.getIPsAvailable()) - .IPLimit(in.getIPLimit()) - .IPs(in.getIPs()) - .cleanupRequired(in.isCleanupRequired()) - .name(in.getName()) - .receivedBytes(in.getReceivedBytes()) - .sentBytes(in.getSentBytes()) - .snapshotsAvailable(in.getSnapshotsAvailable()) - .snapshotLimit(in.getSnapshotLimit()) - .snapshots(in.getSnapshots()) - .state(in.getState()) - .templatesAvailable(in.getTemplatesAvailable()) - .templateLimit(in.getTemplateLimit()) - .templates(in.getTemplates()) - .VMsAvailable(in.getVMsAvailable()) - .VMLimit(in.getVMLimit()) - .VMsRunning(in.getVMsRunning()) - .VMsStopped(in.getVMsStopped()) - .VMs(in.getVMs()) - .volumesAvailable(in.getVolumesAvailable()) - .volumeLimit(in.getVolumeLimit()) - .volumes(in.getVolumes()) - .users(in.getUsers()); - } - } - - private static class ConcreteBuilder extends Builder<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - private final String id; - private final Account.Type type; - private final String networkDomain; - private final String domain; - private final String domainId; - private final Long IPsAvailable; - private final Long IPLimit; - private final long IPs; - private final boolean cleanupRequired; - private final String name; - private final long receivedBytes; - private final long sentBytes; - private final Long snapshotsAvailable; - private final Long snapshotLimit; - private final long snapshots; - private final Account.State state; - private final Long templatesAvailable; - private final Long templateLimit; - private final long templates; - private final Long VMsAvailable; - private final Long VMLimit; - private final long VMsRunning; - private final long VMsStopped; - private final long VMs; - private final Long volumesAvailable; - private final Long volumeLimit; - private final long volumes; - private final Set<User> users; - - @ConstructorProperties({ - "id", "accounttype", "networkdomain", "domain", "domainid", "ipavailable", "iplimit", "iptotal", "iscleanuprequired", - "name", "receivedbytes", "sentbytes", "snapshotavailable", "snapshotlimit", "snapshottotal", "state", "templateavailable", - "templatelimit", "templatetotal", "vmavailable", "vmlimit", "vmrunning", "vmstopped", "vmtotal", "volumeavailable", "volumelimit", - "volumetotal", "user" - }) - private Account(String id, @Nullable Type type, @Nullable String networkDomain, @Nullable String domain, - @Nullable String domainId, @Nullable String IPsAvailable, @Nullable String IPLimit, long IPs, - boolean cleanupRequired, @Nullable String name, long receivedBytes, long sentBytes, - @Nullable String snapshotsAvailable, @Nullable String snapshotLimit, long snapshots, - @Nullable State state, @Nullable String templatesAvailable, @Nullable String templateLimit, - long templates, @Nullable String VMsAvailable, @Nullable String VMLimit, long VMsRunning, - long VMsStopped, long VMs, @Nullable String volumesAvailable, @Nullable String volumeLimit, - long volumes, @Nullable Set<User> users) { - this(id, type, networkDomain, domain, domainId, toLongNullIfUnlimited(IPsAvailable), toLongNullIfUnlimited(IPLimit), IPs, - cleanupRequired, name, receivedBytes, sentBytes, toLongNullIfUnlimited(snapshotsAvailable), toLongNullIfUnlimited(snapshotLimit), - snapshots, state, toLongNullIfUnlimited(templatesAvailable), toLongNullIfUnlimited(templateLimit), templates, - toLongNullIfUnlimited(VMsAvailable), toLongNullIfUnlimited(VMLimit), VMsRunning, VMsStopped, VMs, - toLongNullIfUnlimited(volumesAvailable), toLongNullIfUnlimited(volumeLimit), volumes, users); - } - - private static Long toLongNullIfUnlimited(String in) { - return in == null || "Unlimited".equals(in) ? null : Long.valueOf(in); - } - - protected Account(String id, @Nullable Account.Type type, @Nullable String networkDomain, @Nullable String domain, - @Nullable String domainId, @Nullable Long IPsAvailable, @Nullable Long IPLimit, long IPs, - boolean cleanupRequired, @Nullable String name, long receivedBytes, long sentBytes, @Nullable Long snapshotsAvailable, - @Nullable Long snapshotLimit, long snapshots, @Nullable Account.State state, @Nullable Long templatesAvailable, - @Nullable Long templateLimit, long templates, @Nullable Long VMsAvailable, @Nullable Long VMLimit, long VMsRunning, - long VMsStopped, long VMs, @Nullable Long volumesAvailable, @Nullable Long volumeLimit, long volumes, - @Nullable Set<User> users) { - this.id = checkNotNull(id, "id"); - this.type = type; - this.networkDomain = networkDomain; - this.domain = domain; - this.domainId = domainId; - this.IPsAvailable = IPsAvailable; - this.IPLimit = IPLimit; - this.IPs = IPs; - this.cleanupRequired = cleanupRequired; - this.name = name; - this.receivedBytes = receivedBytes; - this.sentBytes = sentBytes; - this.snapshotsAvailable = snapshotsAvailable; - this.snapshotLimit = snapshotLimit; - this.snapshots = snapshots; - this.state = state; - this.templatesAvailable = templatesAvailable; - this.templateLimit = templateLimit; - this.templates = templates; - this.VMsAvailable = VMsAvailable; - this.VMLimit = VMLimit; - this.VMsRunning = VMsRunning; - this.VMsStopped = VMsStopped; - this.VMs = VMs; - this.volumesAvailable = volumesAvailable; - this.volumeLimit = volumeLimit; - this.volumes = volumes; - this.users = users == null ? ImmutableSet.<User>of() : ImmutableSet.copyOf(users); - } - - /** - * @return the id of the account - */ - public String getId() { - return this.id; - } - - /** - * @return account type (admin, domain-admin, user) - */ - @Nullable - public Account.Type getType() { - return this.type; - } - - /** - * @return the network domain - */ - @Nullable - public String getNetworkDomain() { - return this.networkDomain; - } - - /** - * @return name of the Domain the account belongs to - */ - @Nullable - public String getDomain() { - return this.domain; - } - - /** - * @return id of the Domain the account belongs to - */ - @Nullable - public String getDomainId() { - return this.domainId; - } - - /** - * @return the total number of public ip addresses available for this account - * to acquire, or null if unlimited - */ - @Nullable - public Long getIPsAvailable() { - return this.IPsAvailable; - } - - /** - * @return the total number of public ip addresses this account can acquire, - * or null if unlimited - */ - @Nullable - public Long getIPLimit() { - return this.IPLimit; - } - - /** - * @return the total number of public ip addresses allocated for this account - */ - public long getIPs() { - return this.IPs; - } - - /** - * @return true if the account requires cleanup - */ - public boolean isCleanupRequired() { - return this.cleanupRequired; - } - - /** - * @return the name of the account - */ - @Nullable - public String getName() { - return this.name; - } - - /** - * @return the total number of network traffic bytes received - */ - public long getReceivedBytes() { - return this.receivedBytes; - } - - /** - * @return the total number of network traffic bytes sent - */ - public long getSentBytes() { - return this.sentBytes; - } - - /** - * @return the total number of snapshots available for this account, or null - * if unlimited - */ - @Nullable - public Long getSnapshotsAvailable() { - return this.snapshotsAvailable; - } - - /** - * @return the total number of snapshots which can be stored by this account, - * or null if unlimited - */ - @Nullable - public Long getSnapshotLimit() { - return this.snapshotLimit; - } - - /** - * @return the total number of snapshots stored by this account - */ - public long getSnapshots() { - return this.snapshots; - } - - /** - * @return the state of the account - */ - @Nullable - public State getState() { - return this.state; - } - - /** - * @return the total number of templates available to be created by this - * account, or null if unlimited - */ - @Nullable - public Long getTemplatesAvailable() { - return this.templatesAvailable; - } - - /** - * @return the total number of templates which can be created by this - * account, or null if unlimited - */ - @Nullable - public Long getTemplateLimit() { - return this.templateLimit; - } - - /** - * @return the total number of templates which have been created by this - * account - */ - public long getTemplates() { - return this.templates; - } - - /** - * @return the total number of virtual machines available for this account to - * acquire, or null if unlimited - */ - @Nullable - public Long getVMsAvailable() { - return this.VMsAvailable; - } - - /** - * @return the total number of virtual machines that can be deployed by this - * account, or null if unlimited - */ - @Nullable - public Long getVMLimit() { - return this.VMLimit; - } - - /** - * @return the total number of virtual machines running for this account - */ - public long getVMsRunning() { - return this.VMsRunning; - } - - /** - * @return the total number of virtual machines stopped for this account - */ - public long getVMsStopped() { - return this.VMsStopped; - } - - /** - * @return the total number of virtual machines deployed by this account - */ - public long getVMs() { - return this.VMs; - } - - /** - * @return the total volume available for this account, or null if unlimited - */ - @Nullable - public Long getVolumesAvailable() { - return this.volumesAvailable; - } - - /** - * @return the total volume which can be used by this account, or null if - * unlimited - */ - @Nullable - public Long getVolumeLimit() { - return this.volumeLimit; - } - - /** - * @return the total volume being used by this account - */ - public long getVolumes() { - return this.volumes; - } - - /** - * @return the list of users associated with account - */ - public Set<User> getUsers() { - return this.users; - } - - @Override - protected Set<User> delegate() { - return this.users; - } - - @Override - public int hashCode() { - return Objects.hashCode(id, type, networkDomain, domain, domainId, IPsAvailable, IPLimit, IPs, cleanupRequired, name, receivedBytes, sentBytes, snapshotsAvailable, snapshotLimit, snapshots, state, templatesAvailable, templateLimit, templates, VMsAvailable, VMLimit, VMsRunning, VMsStopped, VMs, volumesAvailable, volumeLimit, volumes, users); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Account that = Account.class.cast(obj); - return Objects.equal(this.id, that.id) - && Objects.equal(this.type, that.type) - && Objects.equal(this.networkDomain, that.networkDomain) - && Objects.equal(this.domain, that.domain) - && Objects.equal(this.domainId, that.domainId) - && Objects.equal(this.IPsAvailable, that.IPsAvailable) - && Objects.equal(this.IPLimit, that.IPLimit) - && Objects.equal(this.IPs, that.IPs) - && Objects.equal(this.cleanupRequired, that.cleanupRequired) - && Objects.equal(this.name, that.name) - && Objects.equal(this.receivedBytes, that.receivedBytes) - && Objects.equal(this.sentBytes, that.sentBytes) - && Objects.equal(this.snapshotsAvailable, that.snapshotsAvailable) - && Objects.equal(this.snapshotLimit, that.snapshotLimit) - && Objects.equal(this.snapshots, that.snapshots) - && Objects.equal(this.state, that.state) - && Objects.equal(this.templatesAvailable, that.templatesAvailable) - && Objects.equal(this.templateLimit, that.templateLimit) - && Objects.equal(this.templates, that.templates) - && Objects.equal(this.VMsAvailable, that.VMsAvailable) - && Objects.equal(this.VMLimit, that.VMLimit) - && Objects.equal(this.VMsRunning, that.VMsRunning) - && Objects.equal(this.VMsStopped, that.VMsStopped) - && Objects.equal(this.VMs, that.VMs) - && Objects.equal(this.volumesAvailable, that.volumesAvailable) - && Objects.equal(this.volumeLimit, that.volumeLimit) - && Objects.equal(this.volumes, that.volumes) - && Objects.equal(this.users, that.users); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this) - .add("id", id).add("type", type).add("networkDomain", networkDomain).add("domain", domain).add("domainId", domainId).add("IPsAvailable", IPsAvailable).add("IPLimit", IPLimit).add("IPs", IPs).add("cleanupRequired", cleanupRequired).add("name", name).add("receivedBytes", receivedBytes).add("sentBytes", sentBytes).add("snapshotsAvailable", snapshotsAvailable).add("snapshotLimit", snapshotLimit).add("snapshots", snapshots).add("state", state).add("templatesAvailable", templatesAvailable).add("templateLimit", templateLimit).add("templates", templates).add("VMsAvailable", VMsAvailable).add("VMLimit", VMLimit).add("VMsRunning", VMsRunning).add("VMsStopped", VMsStopped).add("VMs", VMs).add("volumesAvailable", volumesAvailable).add("volumeLimit", volumeLimit).add("volumes", volumes).add("users", users); - } - - @Override - public String toString() { - return string().toString(); - } - -}
http://git-wip-us.apache.org/repos/asf/stratos/blob/26070cb4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Alert.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Alert.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Alert.java deleted file mode 100644 index e46ec15..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Alert.java +++ /dev/null @@ -1,163 +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.cloudstack.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; -import java.util.Date; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; - -/** - * Represents an alert issued by Cloudstack - */ -public class Alert { - - public static Builder<?> builder() { - return new ConcreteBuilder(); - } - - public Builder<?> toBuilder() { - return new ConcreteBuilder().fromAlert(this); - } - - public abstract static class Builder<T extends Builder<T>> { - protected abstract T self(); - - protected String id; - protected String description; - protected Date sent; - protected String type; - - /** - * @see Alert#getId() - */ - public T id(String id) { - this.id = id; - return self(); - } - - /** - * @see Alert#getDescription() - */ - public T description(String description) { - this.description = description; - return self(); - } - - /** - * @see Alert#getSent() - */ - public T sent(Date sent) { - this.sent = sent; - return self(); - } - - /** - * @see Alert#getType() - */ - public T type(String type) { - this.type = type; - return self(); - } - - public Alert build() { - return new Alert(id, description, sent, type); - } - - public T fromAlert(Alert in) { - return this - .id(in.getId()) - .description(in.getDescription()) - .sent(in.getSent()) - .type(in.getType()); - } - } - - private static class ConcreteBuilder extends Builder<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - private final String id; - private final String description; - private final Date sent; - private final String type; - - @ConstructorProperties({ - "id", "description", "sent", "type" - }) - protected Alert(String id, @Nullable String description, @Nullable Date sent, @Nullable String type) { - this.id = checkNotNull(id, "id"); - this.description = description; - this.sent = sent; - this.type = type; - } - - public String getId() { - return this.id; - } - - @Nullable - public String getDescription() { - return this.description; - } - - @Nullable - public Date getSent() { - return this.sent; - } - - @Nullable - public String getType() { - return this.type; - } - - @Override - public int hashCode() { - return Objects.hashCode(id, description, sent, type); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Alert that = Alert.class.cast(obj); - return Objects.equal(this.id, that.id) - && Objects.equal(this.description, that.description) - && Objects.equal(this.sent, that.sent) - && Objects.equal(this.type, that.type); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this) - .add("id", id).add("description", description).add("sent", sent).add("type", type); - } - - @Override - public String toString() { - return string().toString(); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/26070cb4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AllocationState.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AllocationState.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AllocationState.java deleted file mode 100644 index cb93dae..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AllocationState.java +++ /dev/null @@ -1,42 +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.cloudstack.domain; - -import static com.google.common.base.CaseFormat.UPPER_CAMEL; -import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE; - -/** - * Represents the allocationstate field used in several CloudStack domain objects. - */ -public enum AllocationState { - DISABLED, - ENABLED, - UNKNOWN; - - public static AllocationState fromValue(String value) { - try { - return valueOf(value.toUpperCase()); - } catch (IllegalArgumentException e) { - return UNKNOWN; - } - } - - @Override - public String toString() { - return UPPER_UNDERSCORE.to(UPPER_CAMEL, name()); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/26070cb4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/ApiKeyPair.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/ApiKeyPair.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/ApiKeyPair.java deleted file mode 100644 index 4acfa0c..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/ApiKeyPair.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.cloudstack.domain; - -import java.beans.ConstructorProperties; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; - -/** - * Representation of the API keypair response - */ -public class ApiKeyPair { - - public static Builder<?> builder() { - return new ConcreteBuilder(); - } - - public Builder<?> toBuilder() { - return new ConcreteBuilder().fromApiKeyPair(this); - } - - public abstract static class Builder<T extends Builder<T>> { - protected abstract T self(); - - protected String apiKey; - protected String secretKey; - - /** - * @see ApiKeyPair#getApiKey() - */ - public T apiKey(String apiKey) { - this.apiKey = apiKey; - return self(); - } - - /** - * @see ApiKeyPair#getSecretKey() - */ - public T secretKey(String secretKey) { - this.secretKey = secretKey; - return self(); - } - - public ApiKeyPair build() { - return new ApiKeyPair(apiKey, secretKey); - } - - public T fromApiKeyPair(ApiKeyPair in) { - return this - .apiKey(in.getApiKey()) - .secretKey(in.getSecretKey()); - } - } - - private static class ConcreteBuilder extends Builder<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - private final String apiKey; - private final String secretKey; - - @ConstructorProperties({ - "apikey", "secretkey" - }) - protected ApiKeyPair(@Nullable String apiKey, @Nullable String secretKey) { - this.apiKey = apiKey; - this.secretKey = secretKey; - } - - @Nullable - public String getApiKey() { - return this.apiKey; - } - - @Nullable - public String getSecretKey() { - return this.secretKey; - } - - @Override - public int hashCode() { - return Objects.hashCode(apiKey, secretKey); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ApiKeyPair that = ApiKeyPair.class.cast(obj); - return Objects.equal(this.apiKey, that.apiKey) - && Objects.equal(this.secretKey, that.secretKey); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this) - .add("apiKey", apiKey).add("secretKey", secretKey); - } - - @Override - public String toString() { - return string().toString(); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/26070cb4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AsyncCreateResponse.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AsyncCreateResponse.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AsyncCreateResponse.java deleted file mode 100644 index 8db03f7..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AsyncCreateResponse.java +++ /dev/null @@ -1,132 +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.cloudstack.domain; - -import java.beans.ConstructorProperties; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; - -/** - * Class AsyncCreateResponse - */ -public class AsyncCreateResponse { - public static final AsyncCreateResponse UNINITIALIZED = new AsyncCreateResponse(null, null); - - public static Builder<?> builder() { - return new ConcreteBuilder(); - } - - public Builder<?> toBuilder() { - return new ConcreteBuilder().fromAsyncCreateResponse(this); - } - - public abstract static class Builder<T extends Builder<T>> { - protected abstract T self(); - - protected String id; - protected String jobId; - - /** - * @see AsyncCreateResponse#getId() - */ - public T id(String id) { - this.id = id; - return self(); - } - - /** - * @see AsyncCreateResponse#getJobId() - */ - public T jobId(String jobId) { - this.jobId = jobId; - return self(); - } - - public AsyncCreateResponse build() { - return new AsyncCreateResponse(id, jobId); - } - - public T fromAsyncCreateResponse(AsyncCreateResponse in) { - return this - .id(in.getId()) - .jobId(in.getJobId()); - } - } - - private static class ConcreteBuilder extends Builder<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - private final String id; - private final String jobId; - - @ConstructorProperties({ - "id", "jobid" - }) - protected AsyncCreateResponse(@Nullable String id, @Nullable String jobId) { - this.id = id; - this.jobId = jobId; - } - - /** - * @return id of the resource being created - */ - @Nullable - public String getId() { - return this.id; - } - - /** - * @return id of the job in progress - */ - @Nullable - public String getJobId() { - return this.jobId; - } - - @Override - public int hashCode() { - return Objects.hashCode(id, jobId); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AsyncCreateResponse that = AsyncCreateResponse.class.cast(obj); - return Objects.equal(this.id, that.id) - && Objects.equal(this.jobId, that.jobId); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this) - .add("id", id).add("jobId", jobId); - } - - @Override - public String toString() { - return string().toString(); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/26070cb4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AsyncJob.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AsyncJob.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AsyncJob.java deleted file mode 100644 index 229d7ef..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AsyncJob.java +++ /dev/null @@ -1,456 +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.cloudstack.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; -import java.util.Date; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; - -/** - * Class AsyncJob - */ -public class AsyncJob<S> { - - /** - * Valid job result codes - */ - public static enum ResultCode { - SUCCESS(0), - FAIL(530), - UNKNOWN(-1); - - private final int code; - - private ResultCode(int code) { - this.code = code; - } - - public int code() { - return this.code; - } - - public static ResultCode fromValue(String value) { - try { - int resultCode = Integer.parseInt(value); - switch (resultCode) { - case 0: - return SUCCESS; - case 530: - return FAIL; - default: - return UNKNOWN; - } - } catch (NumberFormatException e) { - return UNKNOWN; - } - } - } - - /** - * Valid async job statuses - */ - public static enum Status { - IN_PROGRESS(0), - SUCCEEDED(1), - FAILED(2), - UNKNOWN(-1); - - private final int code; - - private Status(int code) { - this.code = code; - } - - public int code() { - return this.code; - } - - public static Status fromValue(String value) { - try { - int statusCode = Integer.parseInt(value); - switch (statusCode) { - case 0: - return IN_PROGRESS; - case 1: - return SUCCEEDED; - case 2: - return FAILED; - default: - return UNKNOWN; - } - } catch (NumberFormatException e) { - return UNKNOWN; - } - } - } - - public static <T> Builder<?, T> builder() { - return new ConcreteBuilder<T>(); - } - - public Builder toBuilder() { - return new ConcreteBuilder<S>().fromAsyncJob(this); - } - - public abstract static class Builder<T extends Builder<T, S>, S> { - protected abstract T self(); - - protected String accountId; - protected String cmd; - protected Date created; - protected String id; - protected String instanceId; - protected String instanceType; - protected int progress; - protected S result; - protected AsyncJob.ResultCode resultCode; - protected String resultType; - protected AsyncJob.Status status; - protected String userId; - protected AsyncJobError error; - - /** - * @see AsyncJob#getAccountId() - */ - public T accountId(String accountId) { - this.accountId = accountId; - return self(); - } - - /** - * @see AsyncJob#getCmd() - */ - public T cmd(String cmd) { - this.cmd = cmd; - return self(); - } - - /** - * @see AsyncJob#getCreated() - */ - public T created(Date created) { - this.created = created; - return self(); - } - - /** - * @see AsyncJob#getId() - */ - public T id(String id) { - this.id = id; - return self(); - } - - /** - * @see AsyncJob#getInstanceId() - */ - public T instanceId(String instanceId) { - this.instanceId = instanceId; - return self(); - } - - /** - * @see AsyncJob#getInstanceType() - */ - public T instanceType(String instanceType) { - this.instanceType = instanceType; - return self(); - } - - /** - * @see AsyncJob#getProgress() - */ - public T progress(int progress) { - this.progress = progress; - return self(); - } - - /** - * @see AsyncJob#getResult() - */ - public T result(S result) { - this.result = result; - return self(); - } - - /** - * @see AsyncJob#getResultCode() - */ - public T resultCode(AsyncJob.ResultCode resultCode) { - this.resultCode = resultCode; - return self(); - } - - /** - * @see AsyncJob#getResultType() - */ - public T resultType(String resultType) { - this.resultType = resultType; - return self(); - } - - /** - * @see AsyncJob#getStatus() - */ - public T status(AsyncJob.Status status) { - this.status = status; - return self(); - } - - /** - * @see AsyncJob#getUserId() - */ - public T userId(String userId) { - this.userId = userId; - return self(); - } - - /** - * @see AsyncJob#getError() - */ - public T error(AsyncJobError error) { - this.error = error; - return self(); - } - - public AsyncJob build() { - return new AsyncJob<S>(accountId, cmd, created, id, instanceId, instanceType, progress, result, resultCode, - resultType, status, userId, error); - } - - public T fromAsyncJob(AsyncJob<S> in) { - return this - .accountId(in.getAccountId()) - .cmd(in.getCmd()) - .created(in.getCreated()) - .id(in.getId()) - .instanceId(in.getInstanceId()) - .instanceType(in.getInstanceType()) - .progress(in.getProgress()) - .result(in.getResult()) - .resultCode(in.getResultCode()) - .resultType(in.getResultType()) - .status(in.getStatus()) - .userId(in.getUserId()) - .error(in.getError()); - } - - public static Builder<?, Object> fromAsyncJobUntyped(AsyncJob<?> in) { - return new ConcreteBuilder().fromAsyncJob(in); - } - } - - private static class ConcreteBuilder<T> extends Builder<ConcreteBuilder<T>, T> { - @Override - protected ConcreteBuilder<T> self() { - return this; - } - } - - private final String accountId; - private final String cmd; - private final Date created; - private final String id; - private final String instanceId; - private final String instanceType; - private final int progress; - private final S result; - private final AsyncJob.ResultCode resultCode; - private final String resultType; - private final AsyncJob.Status status; - private final String userId; - private final AsyncJobError error; - - @ConstructorProperties({ - "accountid", "cmd", "created", "jobid", "jobinstanceid", "jobinstancetype", "jobprocstatus", "jobresult", - "jobresultcode", "jobresulttype", "jobstatus", "userid", "error" - }) - protected AsyncJob(@Nullable String accountId, @Nullable String cmd, @Nullable Date created, String id, - @Nullable String instanceId, @Nullable String instanceType, int progress, @Nullable S result, - @Nullable AsyncJob.ResultCode resultCode, @Nullable String resultType, @Nullable AsyncJob.Status status, - @Nullable String userId, @Nullable AsyncJobError error) { - this.accountId = accountId; - this.cmd = cmd; - this.created = created; - this.id = checkNotNull(id, "id"); - this.instanceId = instanceId; - this.instanceType = instanceType; - this.progress = progress; - this.result = result; - this.resultCode = resultCode; - this.resultType = resultType; - this.status = status; - this.userId = userId; - this.error = error; - } - - /** - * @return the account that executed the async command - */ - @Nullable - public String getAccountId() { - return this.accountId; - } - - /** - * @return the async command executed - */ - @Nullable - public String getCmd() { - return this.cmd; - } - - /** - * @return the created date of the job - */ - @Nullable - public Date getCreated() { - return this.created; - } - - /** - * @return async job ID - */ - public String getId() { - return this.id; - } - - /** - * @return the unique ID of the instance/entity object related to the job - */ - @Nullable - public String getInstanceId() { - return this.instanceId; - } - - /** - * @return the instance/entity object related to the job - */ - @Nullable - public String getInstanceType() { - return this.instanceType; - } - - /** - * @return the progress information of the PENDING job - */ - public int getProgress() { - return this.progress; - } - - /** - * @return the result reason - */ - @Nullable - public S getResult() { - return this.result; - } - - /** - * @return the result code for the job - */ - @Nullable - public AsyncJob.ResultCode getResultCode() { - return this.resultCode; - } - - /** - * @return the result type - */ - @Nullable - public String getResultType() { - return this.resultType; - } - - /** - * @return the current job status-should be 0 for PENDING - */ - @Nullable - public AsyncJob.Status getStatus() { - return this.status; - } - - /** - * @return the user that executed the async command - */ - @Nullable - public String getUserId() { - return this.userId; - } - - /** - * @return the error related to this command, or null if no error or error - * not yet encountered. - */ - @Nullable - public AsyncJobError getError() { - return this.error; - } - - public boolean hasFailed() { - return getError() != null || getResultCode() == ResultCode.FAIL || getStatus() == Status.FAILED; - } - - public boolean hasSucceed() { - return getError() == null && getResultCode() == ResultCode.SUCCESS && getStatus() == Status.SUCCEEDED; - } - - @Override - public int hashCode() { - return Objects.hashCode(accountId, cmd, created, id, instanceId, instanceType, progress, result, resultCode, resultType, status, userId, error); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AsyncJob<?> that = AsyncJob.class.cast(obj); - return Objects.equal(this.accountId, that.accountId) - && Objects.equal(this.cmd, that.cmd) - && Objects.equal(this.created, that.created) - && Objects.equal(this.id, that.id) - && Objects.equal(this.instanceId, that.instanceId) - && Objects.equal(this.instanceType, that.instanceType) - && Objects.equal(this.progress, that.progress) - && Objects.equal(this.result, that.result) - && Objects.equal(this.resultCode, that.resultCode) - && Objects.equal(this.resultType, that.resultType) - && Objects.equal(this.status, that.status) - && Objects.equal(this.userId, that.userId) - && Objects.equal(this.error, that.error); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this) - .add("accountId", accountId).add("cmd", cmd).add("created", created).add("id", id).add("instanceId", instanceId) - .add("instanceType", instanceType).add("progress", progress).add("result", result).add("resultCode", resultCode) - .add("resultType", resultType).add("status", status).add("userId", userId).add("error", error); - } - - @Override - public String toString() { - return string().toString(); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/26070cb4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AsyncJobError.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AsyncJobError.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AsyncJobError.java deleted file mode 100644 index 15c4399..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/AsyncJobError.java +++ /dev/null @@ -1,162 +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.cloudstack.domain; - -import java.beans.ConstructorProperties; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; - -public class AsyncJobError { - - /** - * Error codes for job errors - */ - public static enum ErrorCode { - INTERNAL_ERROR(530), - ACCOUNT_ERROR(531), - ACCOUNT_RESOURCE_LIMIT_ERROR(532), - INSUFFICIENT_CAPACITY_ERROR(533), - RESOURCE_UNAVAILABLE_ERROR(534), - RESOURCE_ALLOCATION_ERROR(535), - RESOURCE_IN_USE_ERROR(536), - NETWORK_RULE_CONFLICT_ERROR(537), - UNKNOWN(-1); - - private final int code; - - private ErrorCode(int code) { - this.code = code; - } - - public int code() { - return this.code; - } - - public static ErrorCode fromValue(String value) { - try { - int errorCode = Integer.parseInt(value); - for (ErrorCode candidate : values()) { - if (candidate.code() == errorCode) { - return candidate; - } - } - return UNKNOWN; - - } catch (NumberFormatException e) { - return UNKNOWN; - } - } - } - - public static Builder<?> builder() { - return new ConcreteBuilder(); - } - - public Builder<?> toBuilder() { - return new ConcreteBuilder().fromAsyncJobError(this); - } - - public abstract static class Builder<T extends Builder<T>> { - protected abstract T self(); - - protected AsyncJobError.ErrorCode errorCode; - protected String errorText; - - /** - * @see AsyncJobError#getErrorCode() - */ - public T errorCode(ErrorCode errorCode) { - this.errorCode = errorCode; - return self(); - } - - /** - * @see AsyncJobError#getErrorText() - */ - public T errorText(String errorText) { - this.errorText = errorText; - return self(); - } - - public AsyncJobError build() { - return new AsyncJobError(errorCode, errorText); - } - - public T fromAsyncJobError(AsyncJobError in) { - return this - .errorCode(in.getErrorCode()) - .errorText(in.getErrorText()); - } - } - - private static class ConcreteBuilder extends Builder<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - private final ErrorCode errorCode; - private final String errorText; - - @ConstructorProperties({ - "errorcode", "errortext" - }) - protected AsyncJobError(@Nullable ErrorCode errorCode, @Nullable String errorText) { - this.errorCode = errorCode; - this.errorText = errorText; - } - - @Nullable - public ErrorCode getErrorCode() { - return this.errorCode; - } - - @Nullable - public String getErrorText() { - return this.errorText; - } - - @Override - public int hashCode() { - return Objects.hashCode(errorCode, errorText); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AsyncJobError that = AsyncJobError.class.cast(obj); - return Objects.equal(this.errorCode, that.errorCode) - && Objects.equal(this.errorText, that.errorText); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this) - .add("errorCode", errorCode).add("errorText", errorText); - } - - @Override - public String toString() { - return string().toString(); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/26070cb4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Capabilities.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Capabilities.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Capabilities.java deleted file mode 100644 index e6e7e79..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Capabilities.java +++ /dev/null @@ -1,188 +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.cloudstack.domain; - -import java.beans.ConstructorProperties; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; - -/** - * Class Capabilities - */ -public class Capabilities { - - public static Builder<?> builder() { - return new ConcreteBuilder(); - } - - public Builder<?> toBuilder() { - return new ConcreteBuilder().fromCapabilities(this); - } - - public abstract static class Builder<T extends Builder<T>> { - protected abstract T self(); - - protected String cloudStackVersion; - protected boolean securityGroupsEnabled; - protected boolean canShareTemplates; - protected boolean firewallRuleUiEnabled; - protected boolean supportELB; - - /** - * @see Capabilities#getCloudStackVersion() - */ - public T cloudStackVersion(String cloudStackVersion) { - this.cloudStackVersion = cloudStackVersion; - return self(); - } - - /** - * @see Capabilities#isSecurityGroupsEnabled() - */ - public T securityGroupsEnabled(boolean securityGroupsEnabled) { - this.securityGroupsEnabled = securityGroupsEnabled; - return self(); - } - - /** - * @see Capabilities#canShareTemplates() - */ - public T canShareTemplates(boolean canShareTemplates) { - this.canShareTemplates = canShareTemplates; - return self(); - } - - /** - * @see Capabilities#isFirewallRuleUiEnabled() - */ - public T firewallRuleUiEnabled(boolean firewallRuleUiEnabled) { - this.firewallRuleUiEnabled = firewallRuleUiEnabled; - return self(); - } - - /** - * @see Capabilities#isSupportELB() - */ - public T supportELB(boolean supportELB) { - this.supportELB = supportELB; - return self(); - } - - public Capabilities build() { - return new Capabilities(cloudStackVersion, securityGroupsEnabled, canShareTemplates, firewallRuleUiEnabled, supportELB); - } - - public T fromCapabilities(Capabilities in) { - return this - .cloudStackVersion(in.getCloudStackVersion()) - .securityGroupsEnabled(in.isSecurityGroupsEnabled()) - .canShareTemplates(in.canShareTemplates()) - .firewallRuleUiEnabled(in.isFirewallRuleUiEnabled()) - .supportELB(in.isSupportELB()); - } - } - - private static class ConcreteBuilder extends Builder<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - private final String cloudStackVersion; - private final boolean securityGroupsEnabled; - private final boolean canShareTemplates; - private final boolean firewallRuleUiEnabled; - private final boolean supportELB; - - @ConstructorProperties({ - "cloudstackversion", "securitygroupsenabled", "userpublictemplateenabled", "firewallRuleUiEnabled", "supportELB" - }) - protected Capabilities(@Nullable String cloudStackVersion, boolean securityGroupsEnabled, boolean canShareTemplates, - boolean firewallRuleUiEnabled, boolean supportELB) { - this.cloudStackVersion = cloudStackVersion; - this.securityGroupsEnabled = securityGroupsEnabled; - this.canShareTemplates = canShareTemplates; - this.firewallRuleUiEnabled = firewallRuleUiEnabled; - this.supportELB = supportELB; - } - - /** - * @return version of the cloud stack - */ - @Nullable - public String getCloudStackVersion() { - return this.cloudStackVersion; - } - - /** - * @return true if security groups support is enabled, false otherwise - */ - public boolean isSecurityGroupsEnabled() { - return this.securityGroupsEnabled; - } - - public boolean canShareTemplates() { - return this.canShareTemplates; - } - - /** - * @return true if the firewall rule UI is enabled - */ - public boolean isFirewallRuleUiEnabled() { - return this.firewallRuleUiEnabled; - } - - /** - * @return true if region supports elastic load balancer on basic zones - */ - public boolean isSupportELB() { - return this.supportELB; - } - - @Override - public int hashCode() { - return Objects.hashCode(cloudStackVersion, securityGroupsEnabled, canShareTemplates, firewallRuleUiEnabled, supportELB); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Capabilities that = Capabilities.class.cast(obj); - return Objects.equal(this.cloudStackVersion, that.cloudStackVersion) - && Objects.equal(this.securityGroupsEnabled, that.securityGroupsEnabled) - && Objects.equal(this.canShareTemplates, that.canShareTemplates) - && Objects.equal(this.firewallRuleUiEnabled, that.firewallRuleUiEnabled) - && Objects.equal(this.supportELB, that.supportELB); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this) - .add("cloudStackVersion", cloudStackVersion).add("securityGroupsEnabled", securityGroupsEnabled).add("canShareTemplates", canShareTemplates).add("firewallRuleUiEnabled", firewallRuleUiEnabled).add("supportELB", supportELB); - } - - @Override - public String toString() { - return string().toString(); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/26070cb4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Capacity.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Capacity.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Capacity.java deleted file mode 100644 index 1e87723..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Capacity.java +++ /dev/null @@ -1,287 +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.cloudstack.domain; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.Function; -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; - -/** - * Information about a dimension of the capacity - */ -public class Capacity implements Comparable<Capacity> { - - /** - */ - public static enum Type { - MEMORY_ALLOCATED_BYTES(0), - CPU_ALLOCATED_MHZ(1), - PRIMARY_STORAGE_USED_BYTES(2), - PRIMARY_STORAGE_ALLOCATED_BYTES(3), - PUBLIC_IP_ADDRESSES(4), - PRIVATE_IP_ADDRESSES(5), - SECONDARY_STORAGE_USED_BYTES(6), - VLANS(7), - DIRECT_ATTACHED_PUBLIC_IP_ADDRESSES(8), - LOCAL_STORAGE_USED_BYTES(9), - UNRECOGNIZED(Integer.MAX_VALUE); - - private int code; - - private static final Map<Integer, Type> INDEX = Maps.uniqueIndex(ImmutableSet.copyOf(Type.values()), - new Function<Type, Integer>() { - - @Override - public Integer apply(Type input) { - return input.code; - } - - }); - - Type(int code) { - this.code = code; - } - - @Override - public String toString() { - return name(); - } - - public static Type fromValue(String type) { - Integer code = Integer.valueOf(checkNotNull(type, "type")); - return INDEX.containsKey(code) ? INDEX.get(code) : UNRECOGNIZED; - } - } - - public static Builder<?> builder() { - return new ConcreteBuilder(); - } - - public Builder<?> toBuilder() { - return new ConcreteBuilder().fromCapacity(this); - } - - public abstract static class Builder<T extends Builder<T>> { - protected abstract T self(); - - protected long capacityTotal; - protected long capacityUsed; - protected double percentUsed; - protected String podId; - protected String podName; - protected Capacity.Type type; - protected String zoneId; - protected String zoneName; - - /** - * @see Capacity#getCapacityTotal() - */ - public T capacityTotal(long capacityTotal) { - this.capacityTotal = capacityTotal; - return self(); - } - - /** - * @see Capacity#getCapacityUsed() - */ - public T capacityUsed(long capacityUsed) { - this.capacityUsed = capacityUsed; - return self(); - } - - /** - * @see Capacity#getPercentUsed() - */ - public T percentUsed(double percentUsed) { - this.percentUsed = percentUsed; - return self(); - } - - /** - * @see Capacity#getPodId() - */ - public T podId(String podId) { - this.podId = podId; - return self(); - } - - /** - * @see Capacity#getPodName() - */ - public T podName(String podName) { - this.podName = podName; - return self(); - } - - /** - * @see Capacity#getType() - */ - public T type(Capacity.Type type) { - this.type = type; - return self(); - } - - /** - * @see Capacity#getZoneId() - */ - public T zoneId(String zoneId) { - this.zoneId = zoneId; - return self(); - } - - /** - * @see Capacity#getZoneName() - */ - public T zoneName(String zoneName) { - this.zoneName = zoneName; - return self(); - } - - public Capacity build() { - return new Capacity(capacityTotal, capacityUsed, percentUsed, podId, podName, type, zoneId, zoneName); - } - - public T fromCapacity(Capacity in) { - return this - .capacityTotal(in.getCapacityTotal()) - .capacityUsed(in.getCapacityUsed()) - .percentUsed(in.getPercentUsed()) - .podId(in.getPodId()) - .podName(in.getPodName()) - .type(in.getType()) - .zoneId(in.getZoneId()) - .zoneName(in.getZoneName()); - } - } - - private static class ConcreteBuilder extends Builder<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - private final long capacityTotal; - private final long capacityUsed; - private final double percentUsed; - private final String podId; - private final String podName; - private final Capacity.Type type; - private final String zoneId; - private final String zoneName; - - @ConstructorProperties({ - "capacitytotal", "capacityused", "percentused", "podid", "podname", "type", "zoneid", "zonename" - }) - protected Capacity(long capacityTotal, long capacityUsed, double percentUsed, @Nullable String podId, - @Nullable String podName, @Nullable Capacity.Type type, @Nullable String zoneId, @Nullable String zoneName) { - this.capacityTotal = capacityTotal; - this.capacityUsed = capacityUsed; - this.percentUsed = percentUsed; - this.podId = podId; - this.podName = podName; - this.type = type; - this.zoneId = zoneId; - this.zoneName = zoneName; - } - - public long getCapacityTotal() { - return this.capacityTotal; - } - - public long getCapacityUsed() { - return this.capacityUsed; - } - - public double getPercentUsed() { - return this.percentUsed; - } - - @Nullable - public String getPodId() { - return this.podId; - } - - @Nullable - public String getPodName() { - return this.podName; - } - - @Nullable - public Capacity.Type getType() { - return this.type; - } - - @Nullable - public String getZoneId() { - return this.zoneId; - } - - @Nullable - public String getZoneName() { - return this.zoneName; - } - - @Override - public int hashCode() { - return Objects.hashCode(capacityTotal, capacityUsed, percentUsed, podId, podName, type, zoneId, zoneName); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Capacity that = Capacity.class.cast(obj); - return Objects.equal(this.capacityTotal, that.capacityTotal) - && Objects.equal(this.capacityUsed, that.capacityUsed) - && Objects.equal(this.percentUsed, that.percentUsed) - && Objects.equal(this.podId, that.podId) - && Objects.equal(this.podName, that.podName) - && Objects.equal(this.type, that.type) - && Objects.equal(this.zoneId, that.zoneId) - && Objects.equal(this.zoneName, that.zoneName); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this) - .add("capacityTotal", capacityTotal).add("capacityUsed", capacityUsed).add("percentUsed", percentUsed) - .add("podId", podId).add("podName", podName).add("type", type).add("zoneId", zoneId).add("zoneName", zoneName); - } - - @Override - public String toString() { - return string().toString(); - } - - @Override - public int compareTo(Capacity other) { - int comparison = this.zoneId.compareTo(other.zoneId); - if (comparison == 0) comparison = this.podId.compareTo(other.podId); - if (comparison == 0) Integer.valueOf(this.type.code).compareTo(other.type.code); - return comparison; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/26070cb4/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Cluster.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Cluster.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Cluster.java deleted file mode 100644 index a3b75fa..0000000 --- a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/domain/Cluster.java +++ /dev/null @@ -1,302 +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.cloudstack.domain; - -import static com.google.common.base.CaseFormat.UPPER_CAMEL; -import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.base.MoreObjects; -import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Objects; - -/** - * Represents a CloudStack Cluster. - */ -public class Cluster implements Comparable<Cluster> { - - /** - */ - public static enum ManagedState { - MANAGED, - PREPARE_UNMANAGED, - UNMANAGED, - PREPARE_UNMANAGED_ERROR, - UNRECOGNIZED; - - public static ManagedState fromValue(String value) { - try { - return valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, value)); - } catch (IllegalArgumentException e) { - return UNRECOGNIZED; - } - } - - @Override - public String toString() { - return UPPER_UNDERSCORE.to(UPPER_CAMEL, name()); - } - } - - public static Builder<?> builder() { - return new ConcreteBuilder(); - } - - public Builder<?> toBuilder() { - return new ConcreteBuilder().fromCluster(this); - } - - public abstract static class Builder<T extends Builder<T>> { - protected abstract T self(); - - protected String id; - protected AllocationState allocationState; - protected Host.ClusterType clusterType; - protected String hypervisor; - protected Cluster.ManagedState managedState; - protected String name; - protected String podId; - protected String podName; - protected String zoneId; - protected String zoneName; - - /** - * @see Cluster#getId() - */ - public T id(String id) { - this.id = id; - return self(); - } - - /** - * @see Cluster#getAllocationState() - */ - public T allocationState(AllocationState allocationState) { - this.allocationState = allocationState; - return self(); - } - - /** - * @see Cluster#getClusterType() - */ - public T clusterType(Host.ClusterType clusterType) { - this.clusterType = clusterType; - return self(); - } - - /** - * @see Cluster#getHypervisor() - */ - public T hypervisor(String hypervisor) { - this.hypervisor = hypervisor; - return self(); - } - - /** - * @see Cluster#getManagedState() - */ - public T managedState(Cluster.ManagedState managedState) { - this.managedState = managedState; - return self(); - } - - /** - * @see Cluster#getName() - */ - public T name(String name) { - this.name = name; - return self(); - } - - /** - * @see Cluster#getPodId() - */ - public T podId(String podId) { - this.podId = podId; - return self(); - } - - /** - * @see Cluster#getPodName() - */ - public T podName(String podName) { - this.podName = podName; - return self(); - } - - /** - * @see Cluster#getZoneId() - */ - public T zoneId(String zoneId) { - this.zoneId = zoneId; - return self(); - } - - /** - * @see Cluster#getZoneName() - */ - public T zoneName(String zoneName) { - this.zoneName = zoneName; - return self(); - } - - public Cluster build() { - return new Cluster(id, allocationState, clusterType, hypervisor, managedState, name, podId, podName, zoneId, zoneName); - } - - public T fromCluster(Cluster in) { - return this - .id(in.getId()) - .allocationState(in.getAllocationState()) - .clusterType(in.getClusterType()) - .hypervisor(in.getHypervisor()) - .managedState(in.getManagedState()) - .name(in.getName()) - .podId(in.getPodId()) - .podName(in.getPodName()) - .zoneId(in.getZoneId()) - .zoneName(in.getZoneName()); - } - } - - private static class ConcreteBuilder extends Builder<ConcreteBuilder> { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - private final String id; - private final AllocationState allocationState; - private final Host.ClusterType clusterType; - private final String hypervisor; - private final Cluster.ManagedState managedState; - private final String name; - private final String podId; - private final String podName; - private final String zoneId; - private final String zoneName; - - @ConstructorProperties({ - "id", "allocationstate", "clustertype", "hypervisortype", "managedstate", "name", "podid", "podname", "zoneid", "zonename" - }) - protected Cluster(String id, @Nullable AllocationState allocationState, @Nullable Host.ClusterType clusterType, - @Nullable String hypervisor, @Nullable Cluster.ManagedState managedState, @Nullable String name, - @Nullable String podId, @Nullable String podName, @Nullable String zoneId, @Nullable String zoneName) { - this.id = checkNotNull(id, "id"); - this.allocationState = allocationState; - this.clusterType = clusterType; - this.hypervisor = hypervisor; - this.managedState = managedState; - this.name = name; - this.podId = podId; - this.podName = podName; - this.zoneId = zoneId; - this.zoneName = zoneName; - } - - public String getId() { - return this.id; - } - - @Nullable - public AllocationState getAllocationState() { - return this.allocationState; - } - - @Nullable - public Host.ClusterType getClusterType() { - return this.clusterType; - } - - @Nullable - public String getHypervisor() { - return this.hypervisor; - } - - @Nullable - public Cluster.ManagedState getManagedState() { - return this.managedState; - } - - @Nullable - public String getName() { - return this.name; - } - - @Nullable - public String getPodId() { - return this.podId; - } - - @Nullable - public String getPodName() { - return this.podName; - } - - @Nullable - public String getZoneId() { - return this.zoneId; - } - - @Nullable - public String getZoneName() { - return this.zoneName; - } - - @Override - public int hashCode() { - return Objects.hashCode(id, allocationState, clusterType, hypervisor, managedState, name, podId, podName, zoneId, zoneName); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Cluster that = Cluster.class.cast(obj); - return Objects.equal(this.id, that.id) - && Objects.equal(this.allocationState, that.allocationState) - && Objects.equal(this.clusterType, that.clusterType) - && Objects.equal(this.hypervisor, that.hypervisor) - && Objects.equal(this.managedState, that.managedState) - && Objects.equal(this.name, that.name) - && Objects.equal(this.podId, that.podId) - && Objects.equal(this.podName, that.podName) - && Objects.equal(this.zoneId, that.zoneId) - && Objects.equal(this.zoneName, that.zoneName); - } - - protected ToStringHelper string() { - return MoreObjects.toStringHelper(this) - .add("id", id).add("allocationState", allocationState).add("clusterType", clusterType).add("hypervisor", hypervisor) - .add("managedState", managedState).add("name", name).add("podId", podId).add("podName", podName).add("zoneId", zoneId).add("zoneName", zoneName); - } - - @Override - public String toString() { - return string().toString(); - } - - @Override - public int compareTo(Cluster other) { - return this.id.compareTo(other.id); - } -}
