You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2014/12/23 05:26:47 UTC
[23/51] [partial] stratos git commit: dropping jclouds 1.8.0 clone
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceTemplate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceTemplate.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceTemplate.java
deleted file mode 100644
index e86bed2..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceTemplate.java
+++ /dev/null
@@ -1,445 +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.googlecomputeengine.domain;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface.AccessConfig.Type;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-/**
- * Optional information for creating an instance.
- */
-public class InstanceTemplate {
-
- protected String name;
- protected String description;
- protected URI machineType;
- protected URI image;
- protected Set<Instance.ServiceAccount> serviceAccounts = Sets.newLinkedHashSet();
-
- protected transient List<PersistentDisk> disks = Lists.newArrayList();
- protected transient Set<NetworkInterface> networkInterfaces = Sets.newLinkedHashSet();
- protected transient Map<String, String> metadata = Maps.newLinkedHashMap();
- protected transient String machineTypeName;
-
-
- protected InstanceTemplate(URI machineType) {
- this.machineType = checkNotNull(machineType, "machineType");
- }
-
- protected InstanceTemplate(String machineTypeName) {
- this.machineTypeName = checkNotNull(machineTypeName, "machineTypeName");
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getName()
- */
- public InstanceTemplate name(String name) {
- this.name = name;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getDescription()
- */
- public InstanceTemplate description(String description) {
- this.description = description;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getImage()
- */
- public InstanceTemplate image(URI image) {
- this.image = image;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getMachineType()
- */
- public InstanceTemplate machineType(URI machineType) {
- this.machineType = machineType;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getMachineType()
- */
- public InstanceTemplate machineType(String machineTypeName) {
- this.machineTypeName = machineTypeName;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
- */
- public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source) {
- this.disks.add(new PersistentDisk(mode, source, null, false, false));
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
- */
- public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source, Boolean deleteOnTerminate) {
- this.disks.add(new PersistentDisk(mode, source, null, deleteOnTerminate, false));
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
- */
- public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source, String deviceName, Boolean deleteOnTerminate) {
- this.disks.add(new PersistentDisk(mode, source, deviceName, deleteOnTerminate, false));
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
- */
- public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source, String deviceName,
- Boolean deleteOnTerminate, Boolean boot) {
- this.disks.add(new PersistentDisk(mode, source, deviceName, deleteOnTerminate, boot));
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
- */
- public InstanceTemplate disks(List<PersistentDisk> disks) {
- this.disks = Lists.newArrayList();
- this.disks.addAll(checkNotNull(disks, "disks"));
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getNetworkInterfaces()
- */
- public InstanceTemplate addNetworkInterface(URI network) {
- this.networkInterfaces.add(new NetworkInterface(checkNotNull(network, "network"), null, null));
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getNetworkInterfaces()
- */
- public InstanceTemplate addNetworkInterface(URI network, Type type) {
- this.networkInterfaces.add(new NetworkInterface(checkNotNull(network, "network"), null,
- ImmutableSet.of(Instance.NetworkInterface.AccessConfig.builder()
- .type(type)
- .build())));
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getNetworkInterfaces()
- */
- public InstanceTemplate addNetworkInterface(NetworkInterface networkInterface) {
- this.networkInterfaces.add(networkInterface);
- return this;
- }
-
- public InstanceTemplate networkInterfaces(Set<NetworkInterface> networkInterfaces) {
- this.networkInterfaces = Sets.newLinkedHashSet(networkInterfaces);
- return this;
- }
-
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getMetadata()
- */
- public InstanceTemplate addMetadata(String key, String value) {
- this.metadata.put(checkNotNull(key, "key"), checkNotNull(value, "value of %", key));
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getMetadata()
- */
- public InstanceTemplate metadata(Map<String, String> metadata) {
- this.metadata = Maps.newLinkedHashMap();
- this.metadata.putAll(checkNotNull(metadata, "metadata"));
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getServiceAccounts()
- */
- public InstanceTemplate addServiceAccount(Instance.ServiceAccount serviceAccount) {
- this.serviceAccounts.add(checkNotNull(serviceAccount, "serviceAccount"));
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getServiceAccounts()
- */
- public InstanceTemplate serviceAccounts(Set<Instance.ServiceAccount> serviceAccounts) {
- this.serviceAccounts = Sets.newLinkedHashSet();
- this.serviceAccounts.addAll(checkNotNull(serviceAccounts, "serviceAccounts"));
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getDescription()
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
- */
- public List<PersistentDisk> getDisks() {
- return disks;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getImage()
- */
- public URI getImage() {
- return image;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getMachineType()
- */
- public URI getMachineType() {
- return machineType;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getMachineType()
- */
- public String getMachineTypeName() {
- return machineTypeName;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getMetadata()
- */
- public Map<String, String> getMetadata() {
- return metadata;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getNetworkInterfaces()
- */
- public Set<NetworkInterface> getNetworkInterfaces() {
- return networkInterfaces;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getServiceAccounts()
- */
- public Set<Instance.ServiceAccount> getServiceAccounts() {
- return serviceAccounts;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Instance#getName()
- */
- public String getName() {
- return name;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static InstanceTemplate fromInstanceTemplate(InstanceTemplate instanceTemplate) {
- return Builder.fromInstanceTemplate(instanceTemplate);
- }
-
- public static class Builder {
-
- public InstanceTemplate forMachineType(URI machineType) {
- return new InstanceTemplate(machineType);
- }
-
- public InstanceTemplate forMachineType(String machineTypeName) {
- return new InstanceTemplate(machineTypeName);
- }
-
- public static InstanceTemplate fromInstanceTemplate(InstanceTemplate instanceTemplate) {
- return InstanceTemplate.builder()
- .forMachineType(instanceTemplate.getMachineType())
- .networkInterfaces(instanceTemplate.getNetworkInterfaces())
- .name(instanceTemplate.getName())
- .description(instanceTemplate.getDescription())
- .image(instanceTemplate.getImage())
- .disks(instanceTemplate.getDisks())
- .metadata(instanceTemplate.getMetadata())
- .serviceAccounts(instanceTemplate.getServiceAccounts());
- }
- }
-
-
- public static class PersistentDisk {
-
- public enum Mode {
- READ_WRITE,
- READ_ONLY
- }
-
- public PersistentDisk(Mode mode, URI source, String deviceName, Boolean deleteOnTerminate,
- Boolean boot) {
- this.mode = checkNotNull(mode, "mode");
- this.source = checkNotNull(source, "source");
- this.deviceName = deviceName;
- this.deleteOnTerminate = checkNotNull(deleteOnTerminate, "deleteOnTerminate");
- this.boot = checkNotNull(boot, "boot");
- }
-
- private final Mode mode;
- private final URI source;
- private final Boolean deleteOnTerminate;
- private final String deviceName;
- private final Boolean boot;
-
- /**
- * @return the mode in which to attach this disk, either READ_WRITE or READ_ONLY.
- */
- public Mode getMode() {
- return mode;
- }
-
- /**
- * @return the URL of the persistent disk resource.
- */
- public URI getSource() {
- return source;
- }
-
- /**
- * @return Must be unique within the instance when specified. This represents a unique
- * device name that is reflected into the /dev/ tree of a Linux operating system running within the
- * instance. If not specified, a default will be chosen by the system.
- */
- public String getDeviceName() {
- return deviceName;
- }
-
-
- /**
- * @return If true, delete the disk and all its data when the associated instance is deleted.
- */
- public boolean isDeleteOnTerminate() {
- return deleteOnTerminate;
- }
-
- /**
- * @return If true, boot from this disk.
- */
- public boolean isBoot() {
- return boot;
- }
- }
-
- public static class NetworkInterface {
-
- private final URI network;
- private final String networkIP;
- private final Set<Instance.NetworkInterface.AccessConfig> accessConfigs;
-
- public NetworkInterface(URI network, String networkIP, Set<Instance.NetworkInterface.AccessConfig>
- accessConfigs) {
- this.networkIP = networkIP;
- this.network = network;
- this.accessConfigs = accessConfigs != null ? accessConfigs : ImmutableSet.<Instance.NetworkInterface.AccessConfig>of();
- }
-
- public Set<Instance.NetworkInterface.AccessConfig> getAccessConfigs() {
- return accessConfigs;
- }
-
- public URI getNetwork() {
- return network;
- }
-
- public String getNetworkIP() {
- return networkIP;
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object instanceof InstanceTemplate) {
- final InstanceTemplate other = InstanceTemplate.class.cast(object);
- return equal(description, other.description)
- && equal(image, other.image)
- && equal(disks, other.disks)
- && equal(networkInterfaces, other.networkInterfaces)
- && equal(metadata, other.metadata)
- && equal(serviceAccounts, other.serviceAccounts);
- } else {
- return false;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(description, image, disks, networkInterfaces, metadata, serviceAccounts);
- }
-
- /**
- * {@inheritDoc}
- */
- protected Objects.ToStringHelper string() {
- Objects.ToStringHelper toString = Objects.toStringHelper("")
- .omitNullValues();
- toString.add("description", description);
- if (disks.size() > 0)
- toString.add("disks", disks);
- if (metadata.size() > 0)
- toString.add("metadata", metadata);
- if (serviceAccounts.size() > 0)
- toString.add("serviceAccounts", serviceAccounts);
- toString.add("image", image);
- toString.add("networkInterfaces", networkInterfaces);
- return toString;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/ListPage.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/ListPage.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/ListPage.java
deleted file mode 100644
index 63107e7..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/ListPage.java
+++ /dev/null
@@ -1,179 +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.googlecomputeengine.domain;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.googlecomputeengine.domain.Resource.Kind;
-
-import java.beans.ConstructorProperties;
-import java.net.URI;
-import java.util.Iterator;
-
-import org.jclouds.collect.IterableWithMarker;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * The collection returned from any <code>listFirstPage()</code> method.
- */
-public class ListPage<T> extends IterableWithMarker<T> {
-
- private final Kind kind;
- private final String id;
- private final URI selfLink;
- private final String nextPageToken;
- private final Iterable<T> items;
-
- @ConstructorProperties({
- "kind", "id", "selfLink", "nextPageToken", "items"
- })
- protected ListPage(Kind kind, String id, URI selfLink, String nextPageToken, Iterable<T> items) {
- this.id = checkNotNull(id, "id");
- this.kind = checkNotNull(kind, "kind of %id", id);
- this.selfLink = checkNotNull(selfLink, "selfLink of %id", id);
- this.nextPageToken = nextPageToken;
- this.items = items != null ? ImmutableSet.copyOf(items) : ImmutableSet.<T>of();
- }
-
- public Kind getKind() {
- return kind;
- }
-
- public String getId() {
- return id;
- }
-
- public URI getSelfLink() {
- return selfLink;
- }
-
- @Override
- public Optional<Object> nextMarker() {
- return Optional.<Object>fromNullable(nextPageToken);
- }
-
- @Override
- public Iterator<T> iterator() {
- return checkNotNull(items, "items").iterator();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(kind, id);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- ListPage<?> that = ListPage.class.cast(obj);
- return equal(this.kind, that.kind)
- && equal(this.id, that.id);
- }
-
- /**
- * {@inheritDoc}
- */
- protected Objects.ToStringHelper string() {
- return toStringHelper(this)
- .omitNullValues()
- .add("kind", kind)
- .add("id", id)
- .add("selfLink", selfLink)
- .add("nextPageToken", nextPageToken)
- .add("items", items);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static <T> Builder<T> builder() {
- return new Builder<T>();
- }
-
- public Builder<T> toBuilder() {
- return new Builder<T>().fromPagedList(this);
- }
-
- public static final class Builder<T> {
-
- private Kind kind;
- private String id;
- private URI selfLink;
- private String nextPageToken;
- private ImmutableSet.Builder<T> items = ImmutableSet.builder();
-
- public Builder<T> kind(Kind kind) {
- this.kind = kind;
- return this;
- }
-
- public Builder<T> id(String id) {
- this.id = id;
- return this;
- }
-
- public Builder<T> selfLink(URI selfLink) {
- this.selfLink = selfLink;
- return this;
- }
-
- public Builder<T> addItem(T item) {
- this.items.add(item);
- return this;
- }
-
- public Builder<T> items(Iterable<T> items) {
- this.items.addAll(items);
- return this;
- }
-
- public Builder<T> nextPageToken(String nextPageToken) {
- this.nextPageToken = nextPageToken;
- return this;
- }
-
- public ListPage<T> build() {
- return new ListPage<T>(kind, id, selfLink, nextPageToken, items.build());
- }
-
- public Builder<T> fromPagedList(ListPage<T> in) {
- return this
- .kind(in.getKind())
- .id(in.getId())
- .selfLink(in.getSelfLink())
- .nextPageToken((String) in.nextMarker().orNull())
- .items(in);
-
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineType.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineType.java
deleted file mode 100644
index 1c59ac7..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineType.java
+++ /dev/null
@@ -1,360 +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.googlecomputeengine.domain;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Optional.fromNullable;
-import static com.google.common.base.Preconditions.checkNotNull;
-import java.beans.ConstructorProperties;
-import java.net.URI;
-import java.util.Date;
-import java.util.List;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-
-/**
- * Represents a machine type used to host an instance.
- *
- * @see <a href="https://developers.google.com/compute/docs/reference/v1/machineTypes"/>
- */
-@Beta
-public final class MachineType extends Resource {
-
- private final Integer guestCpus;
- private final Integer memoryMb;
- private final Integer imageSpaceGb;
- private final List<ScratchDisk> scratchDisks;
- private final Integer maximumPersistentDisks;
- private final Long maximumPersistentDisksSizeGb;
- private final String zone;
- private final Optional<Deprecated> deprecated;
-
- @ConstructorProperties({
- "id", "creationTimestamp", "selfLink", "name", "description", "guestCpus", "memoryMb",
- "imageSpaceGb", "scratchDisks", "maximumPersistentDisks", "maximumPersistentDisksSizeGb", "zone",
- "deprecated"
- })
- private MachineType(String id, Date creationTimestamp, URI selfLink, String name, String description,
- int guestCpus, int memoryMb, int imageSpaceGb, List<ScratchDisk> scratchDisks,
- int maximumPersistentDisks, long maximumPersistentDisksSizeGb, String zone,
- @Nullable Deprecated deprecated) {
- super(Kind.MACHINE_TYPE, id, creationTimestamp, selfLink, name, description);
- this.guestCpus = checkNotNull(guestCpus, "guestCpus of %s", name);
- this.memoryMb = checkNotNull(memoryMb, "memoryMb of %s", name);
- this.imageSpaceGb = checkNotNull(imageSpaceGb, "imageSpaceGb of %s", name);
- this.scratchDisks = scratchDisks == null ? ImmutableList.<ScratchDisk>of() : scratchDisks;
- this.maximumPersistentDisks = checkNotNull(maximumPersistentDisks, "maximumPersistentDisks of %s", name);
- this.maximumPersistentDisksSizeGb = maximumPersistentDisksSizeGb;
- this.zone = checkNotNull(zone, "zone of %s", name);
- this.deprecated = fromNullable(deprecated);
- }
-
- /**
- * @return count of CPUs exposed to the instance.
- */
- public int getGuestCpus() {
- return guestCpus;
- }
-
- /**
- * @return physical memory assigned to the instance, defined in MB.
- */
- public int getMemoryMb() {
- return memoryMb;
- }
-
- /**
- * @return space allotted for the image, defined in GB.
- */
- public int getImageSpaceGb() {
- return imageSpaceGb;
- }
-
- /**
- * @return extended scratch disks assigned to the instance.
- */
- public List<ScratchDisk> getScratchDisks() {
- return scratchDisks;
- }
-
- /**
- * @return maximum persistent disks allowed.
- */
- public int getMaximumPersistentDisks() {
- return maximumPersistentDisks;
- }
-
- /**
- * @return maximum total persistent disks size (GB) allowed.
- */
- public long getMaximumPersistentDisksSizeGb() {
- return maximumPersistentDisksSizeGb;
- }
-
- /**
- * @return the zones that this machine type can run in.
- */
- public String getZone() {
- return zone;
- }
-
- /**
- * @return the deprecation information for this machine type
- */
- public Optional<Deprecated> getDeprecated() {
- return deprecated;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- MachineType that = MachineType.class.cast(obj);
- return equal(this.kind, that.kind)
- && equal(this.name, that.name)
- && equal(this.zone, that.zone);
- }
-
- /**
- * {@inheritDoc}
- */
- protected Objects.ToStringHelper string() {
- return super.string()
- .add("guestCpus", guestCpus)
- .add("memoryMb", memoryMb)
- .add("imageSpaceGb", imageSpaceGb)
- .add("scratchDisks", scratchDisks)
- .add("maximumPersistentDisks", maximumPersistentDisks)
- .add("maximumPersistentDisksSizeGb", maximumPersistentDisksSizeGb)
- .add("zone", zone)
- .add("deprecated", deprecated.orNull());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder().fromMachineType(this);
- }
-
- public static final class Builder extends Resource.Builder<Builder> {
-
- private Integer guestCpus;
- private Integer memoryMb;
- private Integer imageSpaceGb;
- private ImmutableList.Builder<ScratchDisk> scratchDisks = ImmutableList.builder();
- private Integer maximumPersistentDisks;
- private Long maximumPersistentDisksSizeGb;
- private String zone;
- private Deprecated deprecated;
-
- /**
- * @see MachineType#getGuestCpus()
- */
- public Builder guestCpus(int guesCpus) {
- this.guestCpus = guesCpus;
- return this;
- }
-
- /**
- * @see MachineType#getMemoryMb()
- */
- public Builder memoryMb(int memoryMb) {
- this.memoryMb = memoryMb;
- return this;
- }
-
- /**
- * @see MachineType#getImageSpaceGb()
- */
- public Builder imageSpaceGb(int imageSpaceGb) {
- this.imageSpaceGb = imageSpaceGb;
- return this;
- }
-
- /**
- * @see MachineType#getScratchDisks()
- */
- public Builder addScratchDisk(int diskGb) {
- this.scratchDisks.add(ScratchDisk.builder().diskGb(diskGb).build());
- return this;
- }
-
- /**
- * @see MachineType#getScratchDisks()
- */
- public Builder scratchDisks(List<ScratchDisk> scratchDisks) {
- this.scratchDisks.addAll(scratchDisks);
- return this;
- }
-
- /**
- * @see MachineType#getMaximumPersistentDisks()
- */
- public Builder maximumPersistentDisks(int maximumPersistentDisks) {
- this.maximumPersistentDisks = maximumPersistentDisks;
- return this;
- }
-
- /**
- * @see MachineType#getMaximumPersistentDisksSizeGb()
- */
- public Builder maximumPersistentDisksSizeGb(long maximumPersistentDisksSizeGb) {
- this.maximumPersistentDisksSizeGb = maximumPersistentDisksSizeGb;
- return this;
- }
-
- /**
- * @see MachineType#getZone()
- */
- public Builder zone(String zone) {
- this.zone = zone;
- return this;
- }
-
- /**
- * @see MachineType#getDeprecated()
- */
- public Builder deprecated(Deprecated deprecated) {
- this.deprecated = deprecated;
- return this;
- }
-
- @Override
- protected Builder self() {
- return this;
- }
-
- public MachineType build() {
- return new MachineType(id, creationTimestamp, selfLink, name, description, guestCpus, memoryMb,
- imageSpaceGb, scratchDisks.build(), maximumPersistentDisks, maximumPersistentDisksSizeGb,
- zone, deprecated);
- }
-
-
- public Builder fromMachineType(MachineType in) {
- return super.fromResource(in).memoryMb(in.getMemoryMb()).imageSpaceGb(in.getImageSpaceGb()).scratchDisks(in
- .getScratchDisks()).maximumPersistentDisks(in.getMaximumPersistentDisks())
- .maximumPersistentDisksSizeGb(in.getMaximumPersistentDisksSizeGb()).zone(in.getZone())
- .deprecated(in.getDeprecated().orNull());
- }
- }
-
- /**
- * An scratch disk of a MachineType
- */
- public static final class ScratchDisk {
-
- private final int diskGb;
-
- @ConstructorProperties({
- "diskGb"
- })
- private ScratchDisk(int diskGb) {
- this.diskGb = diskGb;
- }
-
- /**
- * @return size of the scratch disk, defined in GB.
- */
- public int getDiskGb() {
- return diskGb;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(diskGb);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- ScratchDisk that = ScratchDisk.class.cast(obj);
- return equal(this.diskGb, that.diskGb);
- }
-
- /**
- * {@inheritDoc}
- */
- protected Objects.ToStringHelper string() {
- return toStringHelper(this)
- .add("diskGb", diskGb);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return builder().fromScratchDisk(this);
- }
-
- public static class Builder {
-
- private int diskGb;
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.MachineType.ScratchDisk#getDiskGb()
- */
- public Builder diskGb(int diskGb) {
- this.diskGb = diskGb;
- return this;
- }
-
- public ScratchDisk build() {
- return new ScratchDisk(diskGb);
- }
-
- public Builder fromScratchDisk(ScratchDisk in) {
- return new Builder().diskGb(in.getDiskGb());
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineTypeInZone.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineTypeInZone.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineTypeInZone.java
deleted file mode 100644
index 0a4b5fb..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/MachineTypeInZone.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecomputeengine.domain;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-public class MachineTypeInZone extends SlashEncodedIds {
- protected final MachineType machineType;
-
- public MachineTypeInZone(MachineType machineType, String zoneId) {
- super(zoneId, checkNotNull(machineType, "machineType").getName());
- this.machineType = machineType;
- }
-
- public MachineType getMachineType() {
- return machineType;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- MachineTypeInZone that = MachineTypeInZone.class.cast(obj);
- return equal(this.machineType, that.machineType)
- && equal(this.firstId, that.firstId)
- && equal(this.secondId, that.secondId);
- }
-
- @Override
- public String toString() {
- return "[machineType=" + machineType + ", zoneId=" + firstId + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Metadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Metadata.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Metadata.java
deleted file mode 100644
index 53a8cfb..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Metadata.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.googlecomputeengine.domain;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-
-import java.beans.ConstructorProperties;
-import java.util.Map;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Metadata for an instance or project, with their fingerprint.
- */
-public class Metadata {
- @Nullable
- private final String fingerprint;
- private final Map<String, String> items;
-
- @ConstructorProperties({"fingerprint", "items"})
- public Metadata(@Nullable String fingerprint, @Nullable Map<String, String> items) {
- this.fingerprint = fingerprint;
- this.items = items == null ? ImmutableMap.<String, String>of() : items;
- }
-
- /**
- * @return an optional map of metadata key/value pairs for this instance/project
- */
- public Map<String, String> getItems() {
- return items;
- }
-
- /**
- * Gets the fingerprint for the items - needed for updating them.
- *
- * @return the fingerprint string for the items.
- */
- public String getFingerprint() {
- return fingerprint;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(fingerprint, items);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- Metadata that = Metadata.class.cast(obj);
- return equal(this.items, that.items)
- && equal(this.fingerprint, that.fingerprint);
- }
-
- /**
- * {@inheritDoc}
- */
- protected Objects.ToStringHelper string() {
- return toStringHelper(this)
- .add("items", items)
- .add("fingerprint", fingerprint);
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static final class Builder {
-
- private ImmutableMap.Builder<String, String> items = ImmutableMap.builder();
- private String fingerprint;
-
- /**
- * @see Metadata#getItems()
- */
- public Builder addItem(String key, String value) {
- this.items.put(key, value);
- return this;
- }
-
- /**
- * @see Metadata#getItems()
- */
- public Builder items(Map<String, String> items) {
- this.items.putAll(items);
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Metadata#getFingerprint()
- */
- public Builder fingerprint(String fingerprint) {
- this.fingerprint = fingerprint;
- return this;
- }
-
- public Metadata build() {
- return new Metadata(this.fingerprint, this.items.build());
- }
-
- public Builder fromMetadata(Metadata in) {
- return this.fingerprint(in.getFingerprint())
- .items(in.getItems());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Network.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Network.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Network.java
deleted file mode 100644
index 0919c89..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Network.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecomputeengine.domain;
-
-
-import static com.google.common.base.Optional.fromNullable;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-import java.net.URI;
-import java.util.Date;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-
-/**
- * Represents a network used to enable instance communication.
- *
- * @see <a href="https://developers.google.com/compute/docs/reference/v1/networks"/>
- */
-@Beta
-public final class Network extends Resource {
-
- private final String IPv4Range;
- private final Optional<String> gatewayIPv4;
-
- @ConstructorProperties({
- "id", "creationTimestamp", "selfLink", "name", "description", "IPv4Range",
- "gatewayIPv4"
- })
- protected Network(String id, Date creationTimestamp, URI selfLink, String name, String description,
- String IPv4Range, String gatewayIPv4) {
- super(Kind.NETWORK, id, creationTimestamp, selfLink, name, description);
- this.IPv4Range = checkNotNull(IPv4Range);
- this.gatewayIPv4 = fromNullable(gatewayIPv4);
- }
-
- /**
- * @return Required; The range of internal addresses that are legal on this network. This range is a CIDR
- * specification, for example: 192.168.0.0/16.
- */
- public String getIPv4Range() {
- return IPv4Range;
- }
-
- /**
- * This must be within the range specified by IPv4Range, and is typically the first usable address in that range.
- * If not specified, the default value is the first usable address in IPv4Range.
- *
- * @return an optional address that is used for default routing to other networks.
- */
- public Optional<String> getGatewayIPv4() {
- return gatewayIPv4;
- }
-
- /**
- * {@inheritDoc}
- */
- protected Objects.ToStringHelper string() {
- return super.string()
- .omitNullValues()
- .add("IPv4Range", IPv4Range)
- .add("gatewayIPv4", gatewayIPv4.orNull());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder().fromNetwork(this);
- }
-
- public static final class Builder extends Resource.Builder<Builder> {
-
- private String IPv4Range;
- private String gatewayIPv4;
-
- /**
- * @see Network#getIPv4Range()
- */
- public Builder IPv4Range(String IPv4Range) {
- this.IPv4Range = IPv4Range;
- return this;
- }
-
- /**
- * @see Network#getGatewayIPv4()
- */
- public Builder gatewayIPv4(String gatewayIPv4) {
- this.gatewayIPv4 = gatewayIPv4;
- return this;
- }
-
- @Override
- protected Builder self() {
- return this;
- }
-
- public Network build() {
- return new Network(super.id, super.creationTimestamp, super.selfLink, super.name,
- super.description, IPv4Range, gatewayIPv4);
- }
-
- public Builder fromNetwork(Network in) {
- return super.fromResource(in);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java
deleted file mode 100644
index deab873..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java
+++ /dev/null
@@ -1,556 +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.googlecomputeengine.domain;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Optional.fromNullable;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-import java.net.URI;
-import java.util.Date;
-import java.util.List;
-
-import org.jclouds.http.HttpResponse;
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-
-/**
- * Describes an operation being executed on some Resource
- *
- * @see <a href="https://developers.google.com/compute/docs/reference/v1/operations"/>
- */
-@Beta
-public class Operation extends Resource {
-
- public static enum Status {
- PENDING,
- RUNNING,
- DONE
- }
-
- private final URI targetLink;
- private final Optional<String> targetId;
- private final Optional<String> clientOperationId;
- private final Status status;
- private final Optional<String> statusMessage;
- private final String user;
- private final Optional<Integer> progress;
- private final Date insertTime;
- private final Optional<Date> startTime;
- private final Optional<Date> endTime;
- private final Optional<HttpResponse> httpError;
- private final String operationType;
- private final List<Error> errors;
- private final Optional<URI> zone;
- private final Optional<URI> region;
-
- protected Operation(String id, Date creationTimestamp, URI selfLink, String name, String description,
- URI targetLink, String targetId, String clientOperationId, Status status,
- String statusMessage, String user, Integer progress, Date insertTime, Date startTime,
- Date endTime, Integer httpErrorStatusCode, String httpErrorMessage, String operationType,
- @Nullable List<Error> errors, URI region, URI zone) {
- super(Kind.OPERATION, id, creationTimestamp, selfLink, name, description);
- this.targetLink = checkNotNull(targetLink, "targetLink of %s", name);
- this.targetId = fromNullable(targetId);
- this.clientOperationId = fromNullable(clientOperationId);
- this.status = checkNotNull(status, "status of %s", name);
- this.statusMessage = fromNullable(statusMessage);
- this.user = checkNotNull(user, "user of %s", name);
- this.progress = fromNullable(progress);
- this.insertTime = checkNotNull(insertTime, "insertTime of %s", name);
- this.startTime = fromNullable(startTime);
- this.endTime = fromNullable(endTime);
- this.httpError = httpErrorStatusCode != null && httpErrorStatusCode != 0 ?
- Optional.of(HttpResponse.builder()
- .statusCode(httpErrorStatusCode)
- .message(httpErrorMessage)
- .build())
- : Optional.<HttpResponse>absent();
- this.operationType = checkNotNull(operationType, "insertTime of %s", name);
- this.errors = errors == null ? ImmutableList.<Error>of() : ImmutableList.copyOf(errors);
- this.region = fromNullable(region);
- this.zone = fromNullable(zone);
- }
-
- /**
- * @return URL of the resource the operation is mutating.
- */
- public URI getTargetLink() {
- return targetLink;
- }
-
- /**
- * @return An optional identifier specified by the client when the mutation was initiated. Must be unique for all
- * operation resources in the project.
- */
- public Optional<String> getClientOperationId() {
- return clientOperationId;
- }
-
- /**
- * @return unique target id which identifies a particular incarnation of the target.
- */
- public Optional<String> getTargetId() {
- return targetId;
- }
-
- /**
- * @return region this operation is in, if any.
- */
- public Optional<URI> getRegion() {
- return region;
- }
-
- /**
- * @return zone this operation is in, if any.
- */
- public Optional<URI> getZone() {
- return zone;
- }
-
- /**
- * @return Status of the operation. Can be one of the following: PENDING, RUNNING, or DONE.
- */
- public Status getStatus() {
- return status;
- }
-
- /**
- * @return An optional textual description of the current status of the operation.
- */
- public Optional<String> getStatusMessage() {
- return statusMessage;
- }
-
- /**
- * @return User who requested the operation, for example "user@example.com".
- */
- public String getUser() {
- return user;
- }
-
- /**
- * @return an optional progress indicator that ranges from 0 to 100. This should not be used to guess at when the
- * operation will be complete. This number should be monotonically increasing as the operation progresses
- * (output only).
- */
- public Optional<Integer> getProgress() {
- return progress;
- }
-
- /**
- * @return the time that this operation was requested.
- */
- public Date getInsertTime() {
- return insertTime;
- }
-
- /**
- * @return the time that this operation was started by the server.
- */
- public Optional<Date> getStartTime() {
- return startTime;
- }
-
- /**
- * @return the time that this operation was completed.
- */
- public Optional<Date> getEndTime() {
- return endTime;
- }
-
- /**
- * @return if operation fails, the HttpResponse with error status code returned and the message, e.g. NOT_FOUND.
- */
- public Optional<HttpResponse> getHttpError() {
- return httpError;
- }
-
- /**
- * @return type of the operation. Examples include insert, update, and delete.
- */
- public String getOperationType() {
- return operationType;
- }
-
- /**
- * @return if error occurred during processing of this operation, this field will be populated.
- */
- public List<Error> getErrors() {
- return errors;
- }
-
- /**
- * {@inheritDoc}
- */
- protected Objects.ToStringHelper string() {
- return super.string()
- .omitNullValues()
- .add("targetLink", targetLink)
- .add("targetId", targetId.orNull())
- .add("clientOperationId", clientOperationId.orNull())
- .add("status", status)
- .add("statusMessage", statusMessage.orNull())
- .add("user", user)
- .add("progress", progress.orNull())
- .add("insertTime", insertTime)
- .add("startTime", startTime.orNull())
- .add("endTime", endTime.orNull())
- .add("httpError", httpError.orNull())
- .add("operationType", operationType)
- .add("errors", errors)
- .add("region", region.orNull())
- .add("zone", zone.orNull());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder().fromOperation(this);
- }
-
- public static final class Builder extends Resource.Builder<Builder> {
-
- private URI targetLink;
- private String targetId;
- private String clientOperationId;
- private Status status;
- private String statusMessage;
- private String user;
- private Integer progress;
- private Date insertTime;
- private Date startTime;
- private Date endTime;
- private Integer httpErrorStatusCode;
- private String httpErrorMessage;
- private String operationType;
- private ImmutableList.Builder<Error> errors = ImmutableList.builder();
- private URI region;
- private URI zone;
-
- /**
- * @see Operation#getTargetLink()
- */
- public Builder targetLink(URI targetLink) {
- this.targetLink = targetLink;
- return self();
- }
-
- /**
- * @see Operation#getRegion()
- */
- public Builder region(URI region) {
- this.region = region;
- return self();
- }
-
- /**
- * @see Operation#getZone()
- */
- public Builder zone(URI zone) {
- this.zone = zone;
- return self();
- }
-
- /**
- * @see Operation#getTargetId()
- */
- public Builder targetId(String targetId) {
- this.targetId = targetId;
- return self();
- }
-
- /**
- * @see Operation#getClientOperationId()
- */
- public Builder clientOperationId(String clientOperationId) {
- this.clientOperationId = clientOperationId;
- return self();
- }
-
- /**
- * @see Operation#getStatus()
- */
- public Builder status(Status status) {
- this.status = status;
- return self();
- }
-
- /**
- * @see Operation#getStatusMessage()
- */
- public Builder statusMessage(String statusMessage) {
- this.statusMessage = statusMessage;
- return self();
- }
-
- /**
- * @see Operation#getUser()
- */
- public Builder user(String user) {
- this.user = user;
- return self();
- }
-
- /**
- * @see Operation#getProgress()
- */
- public Builder progress(Integer progress) {
- this.progress = progress;
- return self();
- }
-
- /**
- * @see Operation#getInsertTime()
- */
- public Builder insertTime(Date insertTime) {
- this.insertTime = insertTime;
- return self();
- }
-
- /**
- * @see Operation#getStartTime()
- */
- public Builder startTime(Date startTime) {
- this.startTime = startTime;
- return self();
- }
-
- /**
- * @see Operation#getEndTime()
- */
- public Builder endTime(Date endTime) {
- this.endTime = endTime;
- return self();
- }
-
- /**
- * @see Operation#getHttpError()
- */
- public Builder httpErrorStatusCode(Integer httpErrorStatusCode) {
- this.httpErrorStatusCode = httpErrorStatusCode;
- return self();
- }
-
- /**
- * @see Operation#getHttpError()
- */
- public Builder httpErrorMessage(String httpErrorMessage) {
- this.httpErrorMessage = httpErrorMessage;
- return self();
- }
-
- /**
- * @see Operation#getOperationType()
- */
- public Builder operationType(String operationType) {
- this.operationType = operationType;
- return self();
- }
-
- /**
- * @see Operation#getErrors()
- */
- public Builder errors(Iterable<Error> errors) {
- if (errors != null)
- this.errors.addAll(errors);
- return self();
- }
-
- /**
- * @see Operation#getErrors()
- */
- public Builder addError(Error error) {
- this.errors.add(error);
- return self();
- }
-
- @Override
- protected Builder self() {
- return this;
- }
-
- public Operation build() {
- return new Operation(super.id, super.creationTimestamp, super.selfLink, super.name,
- super.description, targetLink, targetId, clientOperationId, status, statusMessage, user, progress,
- insertTime, startTime, endTime, httpErrorStatusCode, httpErrorMessage, operationType,
- errors.build(), region, zone);
- }
-
- public Builder fromOperation(Operation in) {
- return super.fromResource(in)
- .targetLink(in.getTargetLink())
- .targetId(in.getTargetId().orNull())
- .clientOperationId(in.getClientOperationId().orNull())
- .status(in.getStatus())
- .statusMessage(in.getStatusMessage().orNull())
- .user(in.getUser())
- .progress(in.getProgress().get())
- .insertTime(in.getInsertTime())
- .startTime(in.getStartTime().orNull())
- .endTime(in.getEndTime().orNull())
- .httpErrorStatusCode(in.getHttpError().isPresent() ? in.getHttpError().get().getStatusCode() : null)
- .httpErrorMessage(in.getHttpError().isPresent() ? in.getHttpError().get().getMessage() : null)
- .operationType(in.getOperationType()).errors(in.getErrors())
- .zone(in.getZone().orNull()).region(in.getRegion().orNull());
- }
- }
-
- /**
- * A particular error for an operation including the details.
- */
- public static final class Error {
-
- private final String code;
- private final Optional<String> location;
- private final Optional<String> message;
-
- @ConstructorProperties({
- "code", "location", "message"
- })
- private Error(String code, String location, String message) {
- this.code = checkNotNull(code, "code");
- this.location = fromNullable(location);
- this.message = fromNullable(message);
- }
-
- /**
- * @return the error type identifier for this error.
- */
- public String getCode() {
- return code;
- }
-
- /**
- * @return indicates the field in the request which caused the error..
- */
- public Optional<String> getLocation() {
- return location;
- }
-
- /**
- * @return an optional, human-readable error message.
- */
- public Optional<String> getMessage() {
- return message;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(code, location, message);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- Error that = Error.class.cast(obj);
- return equal(this.code, that.code)
- && equal(this.location, that.location)
- && equal(this.message, that.message);
- }
-
- /**
- * {@inheritDoc}
- */
- protected Objects.ToStringHelper string() {
- return toStringHelper(this)
- .omitNullValues()
- .add("code", code)
- .add("location", location.orNull())
- .add("message", message.orNull());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return builder().fromOperationErrorDetail(this);
- }
-
- public static final class Builder {
-
- private String code;
- private String location;
- private String message;
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Operation.Error#getCode()
- */
- public Builder code(String code) {
- this.code = code;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Operation.Error#getLocation()
- */
- public Builder location(String location) {
- this.location = location;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Operation.Error#getMessage()
- */
- public Builder message(String message) {
- this.message = message;
- return this;
- }
-
- public Error build() {
- return new Error(code, location, message);
- }
-
- public Builder fromOperationErrorDetail(Error in) {
- return new Builder().code(in.getCode()).location(in.getLocation().orNull()).message
- (in.getMessage().orNull());
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java
deleted file mode 100644
index ac3867b..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Project.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.googlecomputeengine.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.net.URI;
-import java.util.Date;
-import java.util.Set;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * A Project resource is the root collection and settings resource for all Google Compute Engine resources.
- *
- * @see <a href="https://developers.google.com/compute/docs/projects"/>
- */
-@Beta
-public class Project extends Resource {
-
- private final Metadata commonInstanceMetadata;
- private final Set<Quota> quotas;
- private final Set<String> externalIpAddresses;
-
- protected Project(String id, Date creationTimestamp, URI selfLink, String name, String description,
- Metadata commonInstanceMetadata, Set<Quota> quotas, Set<String> externalIpAddresses) {
- super(Kind.PROJECT, id, creationTimestamp, selfLink, name, description);
- this.commonInstanceMetadata = checkNotNull(commonInstanceMetadata, "commonInstanceMetadata");
- this.quotas = quotas == null ? ImmutableSet.<Quota>of() : ImmutableSet.copyOf(quotas);
- this.externalIpAddresses = externalIpAddresses == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf
- (externalIpAddresses);
- }
-
- /**
- * @return metadata key/value pairs available to all instances contained in this project.
- */
- public Metadata getCommonInstanceMetadata() {
- return commonInstanceMetadata;
- }
-
- /**
- * @return quotas assigned to this project.
- */
- public Set<Quota> getQuotas() {
- return quotas;
- }
-
- /**
- * @return internet available IP addresses available for use in this project.
- */
- @Nullable
- public Set<String> getExternalIpAddresses() {
- return externalIpAddresses;
- }
-
- /**
- * {@inheritDoc}
- */
- protected Objects.ToStringHelper string() {
- return super.string()
- .add("commonInstanceMetadata", commonInstanceMetadata)
- .add("quotas", quotas)
- .add("externalIpAddresses", externalIpAddresses);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder().fromProject(this);
- }
-
- public static final class Builder extends Resource.Builder<Builder> {
-
- private Metadata commonInstanceMetadata;
- private ImmutableSet.Builder<Quota> quotas = ImmutableSet.builder();
- private ImmutableSet.Builder<String> externalIpAddresses = ImmutableSet.builder();
-
- /**
- * @see Project#getCommonInstanceMetadata()
- */
- public Builder commonInstanceMetadata(Metadata commonInstanceMetadata) {
- this.commonInstanceMetadata = commonInstanceMetadata;
- return this;
- }
-
- /**
- * @see Project#getQuotas()
- */
- public Builder addQuota(String metric, double usage, double limit) {
- this.quotas.add(Quota.builder().metric(metric).usage(usage).limit(limit).build());
- return this;
- }
-
- /**
- * @see Project#getQuotas()
- */
- public Builder quotas(Set<Quota> quotas) {
- this.quotas.addAll(checkNotNull(quotas));
- return this;
- }
-
- /**
- * @see Project#getExternalIpAddresses()
- */
- public Builder addExternalIpAddress(String externalIpAddress) {
- this.externalIpAddresses.add(checkNotNull(externalIpAddress, "externalIpAddress"));
- return this;
- }
-
- /**
- * @see Project#getExternalIpAddresses()
- */
- public Builder externalIpAddresses(Set<String> externalIpAddresses) {
- this.externalIpAddresses.addAll(checkNotNull(externalIpAddresses, "externalIpAddresses"));
- return this;
- }
-
- @Override
- protected Builder self() {
- return this;
- }
-
- public Project build() {
- return new Project(super.id, super.creationTimestamp, super.selfLink, super.name,
- super.description, commonInstanceMetadata, quotas.build(), externalIpAddresses.build());
- }
-
- public Builder fromProject(Project in) {
- return super.fromResource(in).commonInstanceMetadata(in.getCommonInstanceMetadata()).quotas(in.getQuotas())
- .externalIpAddresses(in.getExternalIpAddresses());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Quota.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Quota.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Quota.java
deleted file mode 100644
index 3c17130..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Quota.java
+++ /dev/null
@@ -1,152 +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.googlecomputeengine.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- * Quotas assigned to a given project or region.
- *
- * @see <a href="https://developers.google.com/compute/docs/reference/v1/projects#resource"/>
- */
-@Beta
-public class Quota {
- private String metric;
- private double usage;
- private double limit;
-
- @ConstructorProperties({
- "metric", "usage", "limit"
- })
- public Quota(String metric, Double usage, Double limit) {
- this.metric = metric != null ? metric : "undefined";
- this.usage = checkNotNull(usage, "usage");
- this.limit = checkNotNull(limit, "limit");
- }
-
- /**
- * @return name of the quota metric.
- */
- public String getMetric() {
- return metric;
- }
-
- /**
- * @return current usage of this metric.
- */
- public Double getUsage() {
- return usage;
- }
-
- /**
- * @return quota limit for this metric.
- */
- public Double getLimit() {
- return limit;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(metric);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || this.getClass() != obj.getClass()) return false;
- Quota that = Quota.class.cast(obj);
- return Objects.equal(this.metric, that.metric);
- }
-
- /**
- * {@inheritDoc}
- */
- public ToStringHelper string() {
- return Objects.toStringHelper(this)
- .omitNullValues()
- .add("metric", metric)
- .add("usage", usage)
- .add("limit", limit);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return builder().fromQuota(this);
- }
-
- public static class Builder {
-
- private String metric;
- private Double usage;
- private Double limit;
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Quota#getMetric()
- */
- public Builder metric(String metric) {
- this.metric = checkNotNull(metric, "metric");
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Quota#getUsage()
- */
- public Builder usage(Double usage) {
- this.usage = usage;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Quota#getLimit()
- */
- public Builder limit(Double limit) {
- this.limit = limit;
- return this;
- }
-
- public Quota build() {
- return new Quota(metric, usage, limit);
- }
-
- public Builder fromQuota(Quota quota) {
- return new Builder().metric(quota.getMetric()).usage(quota.getUsage()).limit(quota.getLimit());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java
deleted file mode 100644
index aa459bf..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java
+++ /dev/null
@@ -1,175 +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.googlecomputeengine.domain;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-import java.net.URI;
-import java.util.Date;
-import java.util.Set;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Represents a region resource.
- *
- * @see <a href="https://developers.google.com/compute/docs/reference/v1/regions"/>
- */
-@Beta
-public final class Region extends Resource {
-
- public enum Status {
- UP,
- DOWN
- }
-
- private final Status status;
- private final Set<URI> zones;
- private final Set<Quota> quotas;
-
- @ConstructorProperties({
- "id", "creationTimestamp", "selfLink", "name", "description", "status",
- "zones", "quotas"
- })
- private Region(String id, Date creationTimestamp, URI selfLink, String name, String description,
- Status status, Set<URI> zones, Set<Quota> quotas) {
- super(Kind.REGION, id, creationTimestamp, selfLink, name, description);
- this.status = checkNotNull(status, "status of %name", name);
- this.zones = zones == null ? ImmutableSet.<URI>of() : ImmutableSet
- .copyOf(zones);
- this.quotas = quotas == null ? ImmutableSet.<Quota>of() : ImmutableSet.copyOf(quotas);
- }
-
- /**
- * @return Status of the region. "UP" or "DOWN".
- */
- public Status getStatus() {
- return status;
- }
-
- /**
- * @return the zones that can be used in this region.
- */
- @Nullable
- public Set<URI> getZones() {
- return zones;
- }
-
- /**
- * @return quotas assigned to this project.
- */
- public Set<Quota> getQuotas() {
- return quotas;
- }
-
-
- /**
- * {@inheritDoc}
- */
- protected Objects.ToStringHelper string() {
- return super.string()
- .add("status", status)
- .add("zones", zones)
- .add("quotas", quotas);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder().fromRegion(this);
- }
-
- public static final class Builder extends Resource.Builder<Builder> {
-
- private Status status;
- private ImmutableSet.Builder<URI> zones = ImmutableSet.builder();
- private ImmutableSet.Builder<Quota> quotas = ImmutableSet.builder();
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.Region#getStatus()
- */
- public Builder status(Status status) {
- this.status = status;
- return this;
- }
-
- /**
- * @see Region#getZones()
- */
- public Builder zone(URI zone) {
- this.zones.add(checkNotNull(zone, "zone"));
- return this;
- }
-
- /**
- * @see Region#getZones()
- */
- public Builder zones(Set<URI> zones) {
- this.zones.addAll(checkNotNull(zones, "zones"));
- return this;
- }
-
- /**
- * @see Region#getQuotas()
- */
- public Builder addQuota(String metric, double usage, double limit) {
- this.quotas.add(Quota.builder().metric(metric).usage(usage).limit(limit).build());
- return this;
- }
-
- /**
- * @see Region#getQuotas()
- */
- public Builder quotas(Set<Quota> quotas) {
- this.quotas.addAll(checkNotNull(quotas));
- return this;
- }
-
- @Override
- protected Builder self() {
- return this;
- }
-
- public Region build() {
- return new Region(super.id, super.creationTimestamp, super.selfLink, super.name,
- super.description, status, zones.build(), quotas.build());
- }
-
- public Builder fromRegion(Region in) {
- return super.fromResource(in)
- .status(in.getStatus())
- .zones(in.getZones())
- .quotas(in.getQuotas());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/a9834e9e/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java
deleted file mode 100644
index 4d0a1c8..0000000
--- a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java
+++ /dev/null
@@ -1,283 +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.googlecomputeengine.domain;
-
-import static com.google.common.base.Objects.ToStringHelper;
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Optional.fromNullable;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-import java.net.URI;
-import java.util.Date;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.CaseFormat;
-import com.google.common.base.Joiner;
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-import com.google.common.base.Splitter;
-import com.google.common.collect.Iterables;
-
-/**
- * Base class for Google Compute Engine resources.
- */
-@Beta
-public class Resource {
-
- public enum Kind {
- ADDRESS,
- ADDRESS_LIST,
- DISK,
- DISK_LIST,
- FIREWALL,
- FIREWALL_LIST,
- IMAGE,
- IMAGE_LIST,
- OPERATION,
- OPERATION_LIST,
- INSTANCE,
- INSTANCE_LIST,
- MACHINE_TYPE,
- MACHINE_TYPE_LIST,
- PROJECT,
- NETWORK,
- NETWORK_LIST,
- REGION,
- REGION_LIST,
- ROUTE,
- ROUTE_LIST,
- SNAPSHOT,
- SNAPSHOT_LIST,
- ZONE,
- ZONE_LIST;
-
- public String value() {
- return Joiner.on("#").join("compute", CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()));
- }
-
- @Override
- public String toString() {
- return value();
- }
-
- public static Kind fromValue(String kind) {
- return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat
- .UPPER_UNDERSCORE,
- Iterables.getLast(Splitter.on("#").split(checkNotNull(kind,
- "kind")))));
- }
- }
-
- protected final Kind kind;
- protected final String id;
- protected final Optional<Date> creationTimestamp;
- protected final URI selfLink;
- protected final String name;
- protected final Optional<String> description;
-
- @ConstructorProperties({
- "kind", "id", "creationTimestamp", "selfLink", "name", "description"
- })
- protected Resource(Kind kind, String id, Date creationTimestamp, URI selfLink, String name,
- String description) {
- this.kind = checkNotNull(kind, "kind");
- this.id = checkNotNull(id, "id");
- this.creationTimestamp = fromNullable(creationTimestamp);
- this.selfLink = checkNotNull(selfLink, "selfLink");
- this.name = checkNotNull(name, "name");
- this.description = fromNullable(description);
- }
-
- /**
- * @return the Type of the resource
- */
- public Kind getKind() {
- return kind;
- }
-
- /**
- * @return unique identifier for the resource; defined by the server.
- */
- public String getId() {
- return id;
- }
-
- /**
- * @return creation timestamp in RFC3339 text format.
- */
- public Optional<Date> getCreationTimestamp() {
- return creationTimestamp;
- }
-
- /**
- * @return server defined URL for the resource.
- */
- public URI getSelfLink() {
- return selfLink;
- }
-
- /**
- * @return name of the resource.
- */
- public String getName() {
- return name;
- }
-
- /**
- * @return an optional textual description of the resource.
- */
- @Nullable
- public Optional<String> getDescription() {
- return description;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(kind, name);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- Resource that = Resource.class.cast(obj);
- return equal(this.kind, that.kind)
- && equal(this.name, that.name);
- }
-
- /**
- * {@inheritDoc}
- */
- protected ToStringHelper string() {
- return toStringHelper(this)
- .omitNullValues()
- .add("kind", kind)
- .add("id", id)
- .add("name", name)
- .add("creationTimestamp", creationTimestamp.orNull())
- .add("selfLink", selfLink)
- .add("name", name)
- .add("description", description.orNull());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder<?> builder() {
- return new ConcreteBuilder();
- }
-
- public Builder<?> toBuilder() {
- return new ConcreteBuilder().fromResource(this);
- }
-
- public abstract static class Builder<T extends Builder<T>> {
-
- protected abstract T self();
-
- protected Kind kind;
- protected String id;
- protected Date creationTimestamp;
- protected URI selfLink;
- protected String name;
- protected String description;
-
- /**
- * @see Resource#getKind()
- */
- protected T kind(Kind kind) {
- this.kind = kind;
- return self();
- }
-
- /**
- * @see Resource#getId()
- */
- public T id(String id) {
- this.id = id;
- return self();
- }
-
- /**
- * @see Resource#getCreationTimestamp()
- */
- public T creationTimestamp(Date creationTimestamp) {
- this.creationTimestamp = creationTimestamp;
- return self();
- }
-
- /**
- * @see Resource#getSelfLink()
- */
- public T selfLink(URI selfLink) {
- this.selfLink = selfLink;
- return self();
- }
-
- /**
- * @see Resource#getName()
- */
- public T name(String name) {
- this.name = name;
- return self();
- }
-
- /**
- * @see Resource#getDescription()
- */
- public T description(String description) {
- this.description = description;
- return self();
- }
-
- public Resource build() {
- return new Resource(kind, id, creationTimestamp, selfLink, name, description);
- }
-
- public T fromResource(Resource in) {
- return this
- .kind(in.getKind())
- .id(in.getId())
- .creationTimestamp(in.getCreationTimestamp().orNull())
- .selfLink(in.getSelfLink())
- .name(in.getName())
- .description(in.getDescription().orNull());
- }
- }
-
- private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
- @Override
- protected ConcreteBuilder self() {
- return this;
- }
- }
-}