http://git-wip-us.apache.org/repos/asf/stratos/blob/4203d59b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Snapshot.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Snapshot.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Snapshot.java new file mode 100644 index 0000000..69af275 --- /dev/null +++ b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Snapshot.java @@ -0,0 +1,135 @@ +/* + * 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; + +/** + * A Persistent Disk Snapshot resource. + * + * @see <a href="https://developers.google.com/compute/docs/reference/v1/snapshots"/> + */ +@Beta +public final class Snapshot extends AbstractDisk { + + private final Optional<URI> sourceDisk; + private final String sourceDiskId; + + @ConstructorProperties({ + "id", "creationTimestamp", "selfLink", "name", "description", "diskSizeGb", + "status", "sourceDisk", "sourceDiskId" + }) + private Snapshot(String id, Date creationTimestamp, URI selfLink, String name, String description, + Integer sizeGb, String status, URI sourceDisk, String sourceDiskId) { + super(Kind.SNAPSHOT, id, creationTimestamp, selfLink, name, description, sizeGb, status); + this.sourceDisk = fromNullable(sourceDisk); + this.sourceDiskId = checkNotNull(sourceDiskId, "sourceDiskId of %s", name); + } + + /** + * @return The source disk used to create this snapshot. Once the source disk + * has been deleted from the system, this field will be cleared, and will + * not be set even if a disk with the same name has been re-created (output only). + */ + public Optional<URI> getSourceDisk() { + return sourceDisk; + } + + /** + * @return The ID value of the disk used to create this snapshot. This value + * may be used to determine whether the snapshot was taken from the current + * or a previous instance of a given disk name. + */ + public String getSourceDiskId() { + return sourceDiskId; + } + + /** + * {@inheritDoc} + */ + protected Objects.ToStringHelper string() { + return super.string() + .omitNullValues() + .add("sourceDisk", sourceDisk.orNull()) + .add("sourceDiskId", sourceDiskId); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return string().toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromSnapshot(this); + } + + public static final class Builder extends AbstractDisk.Builder<Builder> { + + private URI sourceDisk; + private String sourceDiskId; + + /** + * @see Snapshot#getSourceDisk() + */ + public Builder sourceDisk(URI sourceDisk) { + this.sourceDisk = sourceDisk; + return this; + } + + /** + * @see Snapshot#getSourceDiskId() + */ + public Builder sourceDiskId(String sourceDiskId) { + this.sourceDiskId = sourceDiskId; + return this; + } + + @Override + protected Builder self() { + return this; + } + + public Snapshot build() { + return new Snapshot(super.id, super.creationTimestamp, super.selfLink, super.name, + super.description, super.sizeGb, super.status, sourceDisk, sourceDiskId); + } + + public Builder fromSnapshot(Snapshot in) { + return super.fromAbstractDisk(in) + .sourceDisk(in.getSourceDisk().orNull()) + .sourceDiskId(in.getSourceDiskId()); + } + + } + +}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4203d59b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java new file mode 100644 index 0000000..232386c --- /dev/null +++ b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java @@ -0,0 +1,334 @@ +/* + * 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.Set; + +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.ImmutableSet; + +/** + * Represents a zone resource. + * + * @see <a href="https://developers.google.com/compute/docs/reference/v1/zones"/> + */ +@Beta +public final class Zone extends Resource { + + public enum Status { + UP, + DOWN + } + + private final Status status; + private final Set<MaintenanceWindow> maintenanceWindows; + private final Set<String> availableMachineTypes; + + @ConstructorProperties({ + "id", "creationTimestamp", "selfLink", "name", "description", "status", "maintenanceWindows", + "availableMachineTypes" + }) + private Zone(String id, Date creationTimestamp, URI selfLink, String name, String description, + Status status, Set<MaintenanceWindow> maintenanceWindows, Set<String> availableMachineTypes) { + super(Kind.ZONE, id, creationTimestamp, selfLink, name, description); + this.status = checkNotNull(status, "status of %name", name); + this.maintenanceWindows = maintenanceWindows == null ? ImmutableSet.<MaintenanceWindow>of() : ImmutableSet + .copyOf(maintenanceWindows); + this.availableMachineTypes = availableMachineTypes == null ? ImmutableSet.<String>of() : ImmutableSet + .copyOf(availableMachineTypes); + } + + /** + * @return Status of the zone. "UP" or "DOWN". + */ + public Status getStatus() { + return status; + } + + /** + * @return scheduled maintenance windows for the zone. When the zone is in a maintenance window, + * all resources which reside in the zone will be unavailable. + */ + public Set<MaintenanceWindow> getMaintenanceWindows() { + return maintenanceWindows; + } + + /** + * @return the machine types that can be used in this zone. + */ + @Nullable + public Set<String> getAvailableMachineTypes() { + return availableMachineTypes; + } + + /** + * {@inheritDoc} + */ + protected Objects.ToStringHelper string() { + return super.string() + .add("status", status) + .add("maintenanceWindows", maintenanceWindows) + .add("availableMachineTypes", availableMachineTypes); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return string().toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromZone(this); + } + + public static final class Builder extends Resource.Builder<Builder> { + + private Status status; + private ImmutableSet.Builder<MaintenanceWindow> maintenanceWindows = ImmutableSet.builder(); + private ImmutableSet.Builder<String> availableMachineTypes = ImmutableSet.builder(); + + /** + * @see Zone#getStatus() + */ + public Builder status(Status status) { + this.status = status; + return this; + } + + /** + * @see Zone#getMaintenanceWindows() + */ + public Builder addMaintenanceWindow(MaintenanceWindow maintenanceWindow) { + this.maintenanceWindows.add(checkNotNull(maintenanceWindow, "maintenanceWindow")); + return this; + } + + /** + * @see Zone#getMaintenanceWindows() + */ + public Builder maintenanceWindows(Set<MaintenanceWindow> maintenanceWindows) { + this.maintenanceWindows.addAll(checkNotNull(maintenanceWindows, "maintenanceWindows")); + return this; + } + + /** + * @see Zone#getAvailableMachineTypes() + */ + public Builder addAvailableMachineType(String availableMachineType) { + this.availableMachineTypes.add(checkNotNull(availableMachineType, "availableMachineType")); + return this; + } + + /** + * @see Zone#getAvailableMachineTypes() + */ + public Builder availableMachineTypes(Set<String> availableMachineTypes) { + this.availableMachineTypes.addAll(checkNotNull(availableMachineTypes, "availableMachineTypes")); + return this; + } + + @Override + protected Builder self() { + return this; + } + + public Zone build() { + return new Zone(super.id, super.creationTimestamp, super.selfLink, super.name, + super.description, status, maintenanceWindows.build(), availableMachineTypes.build()); + } + + public Builder fromZone(Zone in) { + return super.fromResource(in) + .status(in.getStatus()) + .maintenanceWindows(in.getMaintenanceWindows()) + .availableMachineTypes(in.getAvailableMachineTypes()); + } + } + + /** + * Scheduled maintenance windows for the zone. When the zone is in a maintenance window, + * all resources which reside in the zone will be unavailable. + * + * @see <a href="https://developers.google.com/compute/docs/reference/v1/zones"/> + */ + public static final class MaintenanceWindow { + + private final String name; + private final Optional<String> description; + private final Date beginTime; + private final Date endTime; + + @ConstructorProperties({ + "name", "description", "beginTime", "endTime" + }) + private MaintenanceWindow(String name, String description, Date beginTime, Date endTime) { + this.name = checkNotNull(name, "name"); + this.description = fromNullable(description); + this.beginTime = checkNotNull(beginTime, "beginTime of %name", name); + this.endTime = checkNotNull(endTime, "endTime of %name", name); + } + + /** + * @return name of the maintenance window. + */ + public String getName() { + return name; + } + + /** + * @return textual description of the maintenance window. + */ + public Optional<String> getDescription() { + return description; + } + + /** + * @return begin time of the maintenance window. + */ + public Date getBeginTime() { + return beginTime; + } + + /** + * @return end time of the maintenance window. + */ + public Date getEndTime() { + return endTime; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return Objects.hashCode(name, description, beginTime, endTime); + } + + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + MaintenanceWindow that = MaintenanceWindow.class.cast(obj); + return equal(this.name, that.name) + && equal(this.beginTime, that.beginTime) + && equal(this.endTime, that.endTime); + } + + /** + * {@inheritDoc} + */ + protected Objects.ToStringHelper string() { + return toStringHelper(this) + .omitNullValues() + .add("name", name) + .add("description", description.orNull()) + .add("beginTime", beginTime) + .add("endTime", endTime); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return string().toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromZoneMaintenanceWindow(this); + } + + public static final class Builder { + + private String name; + private String description; + private Date beginTime; + private Date endTime; + + /** + * @see org.jclouds.googlecomputeengine.domain.Zone.MaintenanceWindow#getName() + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.Zone.MaintenanceWindow#getDescription() + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.Zone.MaintenanceWindow#getBeginTime() + */ + public Builder beginTime(Date beginTime) { + this.beginTime = beginTime; + return this; + } + + /** + * @see org.jclouds.googlecomputeengine.domain.Zone.MaintenanceWindow#getEndTime() + */ + public Builder endTime(Date endTime) { + this.endTime = endTime; + return this; + } + + + public MaintenanceWindow build() { + return new MaintenanceWindow(name, description, beginTime, endTime); + } + + public Builder fromZoneMaintenanceWindow(MaintenanceWindow in) { + return new Builder() + .name(in.getName()) + .description(in.getDescription().orNull()) + .beginTime(in.getBeginTime()) + .endTime(in.getEndTime()); + } + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/4203d59b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/internal/NetworkAndAddressRange.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/internal/NetworkAndAddressRange.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/internal/NetworkAndAddressRange.java new file mode 100644 index 0000000..66fbd66 --- /dev/null +++ b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/internal/NetworkAndAddressRange.java @@ -0,0 +1,91 @@ +/* + * 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.internal; + +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 org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.base.Optional; + +/** + * Container for network, IPv4 range and optional gateway, for creation caching + */ +public class NetworkAndAddressRange { + protected final String name; + protected final String ipV4Range; + protected final Optional<String> gateway; + + @ConstructorProperties({ + "name", "ipV4Range", "gateway" + }) + public NetworkAndAddressRange(String name, String ipV4Range, @Nullable String gateway) { + this.name = checkNotNull(name, "name"); + this.ipV4Range = checkNotNull(ipV4Range, "ipV4Range"); + this.gateway = fromNullable(gateway); + } + + public String getName() { + return name; + } + + public String getIpV4Range() { + return ipV4Range; + } + + @Nullable + public Optional<String> getGateway() { + return gateway; + } + + @Override + public int hashCode() { + // We only do hashcode/equals on name. + // the ip v4 range and gateway are included for creation rather than caching. + return Objects.hashCode(name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + NetworkAndAddressRange that = NetworkAndAddressRange.class.cast(obj); + return equal(this.name, that.name); + } + + protected ToStringHelper string() { + return toStringHelper(this) + .omitNullValues() + .add("name", name) + .add("ipV4Range", ipV4Range) + .add("gateway", gateway.orNull()); + } + + @Override + public String toString() { + return string().toString(); + } + + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/4203d59b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java new file mode 100644 index 0000000..40ec7dc --- /dev/null +++ b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java @@ -0,0 +1,187 @@ +/* + * 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.features; + +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; +import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.collect.PagedIterable; +import org.jclouds.googlecomputeengine.domain.Address; +import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.domain.Operation; +import org.jclouds.googlecomputeengine.functions.internal.ParseAddresses; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.oauth.v2.config.OAuthScopes; +import org.jclouds.oauth.v2.filters.OAuthAuthenticator; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.annotations.Transform; +import org.jclouds.rest.binders.BindToJsonPayload; + +/** + * Provides access to Addresses via their REST API. + * + * @see <a href="https://developers.google.com/compute/docs/reference/v1/addresses"/> + */ +@SkipEncoding({'/', '='}) +@RequestFilters(OAuthAuthenticator.class) +public interface AddressApi { + + /** + * Returns the specified address resource. + * + * @param region Name of the region the address is in. + * @param addressName name of the address resource to return. + * @return a Address resource. + */ + @Named("Addresss:get") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/regions/{region}/addresses/{address}") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Address getInRegion(@PathParam("region") String region, @PathParam("address") String addressName); + + /** + * Creates a address resource in the specified project specifying the size of the address. + * + * + * @param region the name of the region where the address is to be created. + * @param addressName the name of address. + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Addresss:insert") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("/regions/{region}/addresses") + @OAuthScopes({COMPUTE_SCOPE}) + @MapBinder(BindToJsonPayload.class) + Operation createInRegion(@PathParam("region") String region, @PayloadParam("name") String addressName); + + /** + * Deletes the specified address resource. + * + * @param region the region the address is in. + * @param addressName name of the address resource to delete. + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Addresss:delete") + @DELETE + @Consumes(MediaType.APPLICATION_JSON) + @Path("/regions/{region}/addresses/{address}") + @OAuthScopes(COMPUTE_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Operation deleteInRegion(@PathParam("region") String region, @PathParam("address") String addressName); + + /** + * @see org.jclouds.googlecomputeengine.features.AddressApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Addresss:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/regions/{region}/addresses") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseAddresses.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Address> listFirstPageInRegion(@PathParam("region") String region); + + /** + * @see org.jclouds.googlecomputeengine.features.AddressApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Addresss:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/regions/{region}/addresses") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseAddresses.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Address> listAtMarkerInRegion(@PathParam("region") String region, @QueryParam("pageToken") @Nullable String marker); + + /** + * Retrieves the listPage of address resources contained within the specified project and region. + * By default the listPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has + * not been set. + * + * @param region the region to search in + * @param marker marks the beginning of the next list page + * @param listOptions listing options + * @return a page of the listPage + * @see org.jclouds.googlecomputeengine.options.ListOptions + * @see org.jclouds.googlecomputeengine.domain.ListPage + */ + @Named("Addresss:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/regions/{region}/addresses") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseAddresses.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Address> listAtMarkerInRegion(@PathParam("region") String region, @QueryParam("pageToken") @Nullable String marker, ListOptions listOptions); + + /** + * A paged version of AddressApi#listPageInRegion(String) + * + * @param region the region to list in + * @return a Paged, Fluent Iterable that is able to fetch additional pages when required + * @see org.jclouds.collect.PagedIterable + * @see org.jclouds.googlecomputeengine.features.AddressApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Addresss:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/regions/{region}/addresses") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseAddresses.class) + @Transform(ParseAddresses.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Address> listInRegion(@PathParam("region") String region); + + @Named("Addresss:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/regions/{region}/addresses") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseAddresses.class) + @Transform(ParseAddresses.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Address> listInRegion(@PathParam("region") String region, ListOptions options); + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/4203d59b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java new file mode 100644 index 0000000..fa26c25 --- /dev/null +++ b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java @@ -0,0 +1,255 @@ +/* + * 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.features; + +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; +import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.collect.PagedIterable; +import org.jclouds.googlecomputeengine.domain.Disk; +import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.domain.Operation; +import org.jclouds.googlecomputeengine.functions.internal.ParseDisks; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.oauth.v2.config.OAuthScopes; +import org.jclouds.oauth.v2.filters.OAuthAuthenticator; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.annotations.Transform; +import org.jclouds.rest.binders.BindToJsonPayload; + +/** + * Provides access to Disks via their REST API. + * + * @see <a href="https://developers.google.com/compute/docs/reference/v1/disks"/> + */ +@SkipEncoding({'/', '='}) +@RequestFilters(OAuthAuthenticator.class) +public interface DiskApi { + + /** + * Returns the specified persistent disk resource. + * + * @param zone Name of the zone the disk is in. + * @param diskName name of the persistent disk resource to return. + * @return a Disk resource. + */ + @Named("Disks:get") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/disks/{disk}") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Disk getInZone(@PathParam("zone") String zone, @PathParam("disk") String diskName); + + /** + * Creates a persistent disk resource in the specified project specifying the size of the disk. + * + * @param diskName the name of disk. + * @param sizeGb the size of the disk + * @param zone the name of the zone where the disk is to be created. + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Disks:insert") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/disks") + @OAuthScopes({COMPUTE_SCOPE}) + @MapBinder(BindToJsonPayload.class) + Operation createInZone(@PayloadParam("name") String diskName, + @PayloadParam("sizeGb") int sizeGb, + @PathParam("zone") String zone); + + /** + * Creates a persistent disk resource from the specified image, in the specified project, + * specifying the size of the disk. + * + * @param sourceImage fully qualified URL for the image to be copied. + * @param diskName the name of disk. + * @param sizeGb the size of the disk + * @param zone the name of the zone where the disk is to be created. + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Disks:insert") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/disks") + @OAuthScopes({COMPUTE_SCOPE}) + @MapBinder(BindToJsonPayload.class) + Operation createFromImageWithSizeInZone(@QueryParam("sourceImage") String sourceImage, + @PayloadParam("name") String diskName, + @PayloadParam("sizeGb") int sizeGb, + @PathParam("zone") String zone); + + /** + * Creates a persistent disk resource from the specified image, in the specified project, + * with the default disk size. + * + * @param sourceImage fully qualified URL for the image to be copied. + * @param diskName the name of disk. + * @param zone the name of the zone where the disk is to be created. + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Disks:insert") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/disks") + @OAuthScopes({COMPUTE_SCOPE}) + @MapBinder(BindToJsonPayload.class) + Operation createFromImageInZone(@QueryParam("sourceImage") String sourceImage, + @PayloadParam("name") String diskName, + @PathParam("zone") String zone); + + /** + * Deletes the specified persistent disk resource. + * + * @param zone the zone the disk is in. + * @param diskName name of the persistent disk resource to delete. + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Disks:delete") + @DELETE + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/disks/{disk}") + @OAuthScopes(COMPUTE_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Operation deleteInZone(@PathParam("zone") String zone, @PathParam("disk") String diskName); + + /** + * @see DiskApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Disks:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/disks") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseDisks.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Disk> listFirstPageInZone(@PathParam("zone") String zone); + + /** + * @see DiskApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Disks:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/disks") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseDisks.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Disk> listAtMarkerInZone(@PathParam("zone") String zone, @QueryParam("pageToken") @Nullable String marker); + + /** + * Retrieves the listPage of persistent disk resources contained within the specified project and zone. + * By default the listPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has + * not been set. + * + * @param zone the zone to search in + * @param marker marks the beginning of the next list page + * @param listOptions listing options + * @return a page of the listPage + * @see ListOptions + * @see org.jclouds.googlecomputeengine.domain.ListPage + */ + @Named("Disks:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/disks") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseDisks.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Disk> listAtMarkerInZone(@PathParam("zone") String zone, @QueryParam("pageToken") @Nullable String marker, ListOptions listOptions); + + /** + * A paged version of DiskApi#listPageInZone(String) + * + * @param zone the zone to list in + * @return a Paged, Fluent Iterable that is able to fetch additional pages when required + * @see PagedIterable + * @see DiskApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Disks:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/disks") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseDisks.class) + @Transform(ParseDisks.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Disk> listInZone(@PathParam("zone") String zone); + + @Named("Disks:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/disks") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseDisks.class) + @Transform(ParseDisks.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Disk> listInZone(@PathParam("zone") String zone, ListOptions options); + + /** + * Create a snapshot of a given disk in a zone. + * + * @param zone the zone the disk is in. + * @param diskName the name of the disk. + * @param snapshotName the name for the snapshot to be craeted. + * + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Disks:createSnapshot") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/disks/{disk}/createSnapshot") + @OAuthScopes(COMPUTE_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + @MapBinder(BindToJsonPayload.class) + @Nullable + Operation createSnapshotInZone(@PathParam("zone") String zone, + @PathParam("disk") String diskName, + @PayloadParam("name") String snapshotName); + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/4203d59b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java new file mode 100644 index 0000000..677b56a --- /dev/null +++ b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java @@ -0,0 +1,227 @@ +/* + * 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.features; + +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE; + +import java.net.URI; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; +import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.collect.PagedIterable; +import org.jclouds.googlecomputeengine.domain.Firewall; +import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.domain.Operation; +import org.jclouds.googlecomputeengine.functions.internal.PATCH; +import org.jclouds.googlecomputeengine.functions.internal.ParseFirewalls; +import org.jclouds.googlecomputeengine.handlers.FirewallBinder; +import org.jclouds.googlecomputeengine.options.FirewallOptions; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.oauth.v2.config.OAuthScopes; +import org.jclouds.oauth.v2.filters.OAuthAuthenticator; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.annotations.Transform; +import org.jclouds.rest.binders.BindToJsonPayload; + +/** + * Provides access to Firewalls via their REST API. + * <p/> + * + * @see <a href="https://developers.google.com/compute/docs/reference/v1/firewalls"/> + */ +@SkipEncoding({'/', '='}) +@RequestFilters(OAuthAuthenticator.class) +public interface FirewallApi { + /** + * Returns the specified image resource. + * + * @param firewallName name of the firewall resource to return. + * @return an Firewall resource + */ + @Named("Firewalls:get") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/global/firewalls/{firewall}") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Firewall get(@PathParam("firewall") String firewallName); + + /** + * Creates a firewall resource in the specified project using the data included in the request. + * + * @param name the name of the firewall to be inserted. + * @param network the network to which to add the firewall + * @param firewallOptions the options of the firewall to add + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Firewalls:insert") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("/global/firewalls") + @OAuthScopes({COMPUTE_SCOPE}) + @MapBinder(FirewallBinder.class) + Operation createInNetwork(@PayloadParam("name") String name, + @PayloadParam("network") URI network, + @PayloadParam("options") FirewallOptions firewallOptions); + + /** + * Updates the specified firewall resource with the data included in the request. + * + * @param firewallName the name firewall to be updated. + * @param firewallOptions the new firewall. + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Firewalls:update") + @PUT + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("/global/firewalls/{firewall}") + @OAuthScopes({COMPUTE_SCOPE}) + Operation update(@PathParam("firewall") String firewallName, + @BinderParam(BindToJsonPayload.class) FirewallOptions firewallOptions); + + /** + * Updates the specified firewall resource, with patch semantics, with the data included in the request. + * + * @param firewallName the name firewall to be updated. + * @param firewallOptions the new firewall. + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Firewalls:patch") + @PATCH + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("/global/firewalls/{firewall}") + @OAuthScopes({COMPUTE_SCOPE}) + Operation patch(@PathParam("firewall") String firewallName, + @BinderParam(BindToJsonPayload.class) FirewallOptions firewallOptions); + + /** + * Deletes the specified image resource. + * + * @param firewallName name of the firewall resource to delete. + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. If the image did not exist the result is null. + */ + @Named("Firewalls:delete") + @DELETE + @Consumes(MediaType.APPLICATION_JSON) + @Path("/global/firewalls/{firewall}") + @OAuthScopes(COMPUTE_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + Operation delete(@PathParam("firewall") String firewallName); + + /** + * @see FirewallApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Firewalls:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/global/firewalls") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseFirewalls.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Firewall> listFirstPage(); + + /** + * @see FirewallApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Firewalls:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/global/firewalls") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseFirewalls.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Firewall> listAtMarker(@QueryParam("pageToken") @Nullable String marker); + + /** + * Retrieves the list of firewall resources available to the specified project. + * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not + * been set. + * + * @param marker marks the beginning of the next list page + * @param listOptions listing options + * @return a page of the list + * @see ListOptions + * @see org.jclouds.googlecomputeengine.domain.ListPage + */ + @Named("Firewalls:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/global/firewalls") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseFirewalls.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Firewall> listAtMarker(@QueryParam("pageToken") @Nullable String marker, ListOptions options); + + /** + * @see FirewallApi#list(org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Firewalls:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/global/firewalls") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseFirewalls.class) + @Transform(ParseFirewalls.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Firewall> list(); + + /** + * A paged version of FirewallApi#list() + * + * @return a Paged, Fluent Iterable that is able to fetch additional pages when required + * @see PagedIterable + * @see FirewallApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Firewalls:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/global/firewalls") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseFirewalls.class) + @Transform(ParseFirewalls.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Firewall> list(ListOptions options); +} http://git-wip-us.apache.org/repos/asf/stratos/blob/4203d59b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java new file mode 100644 index 0000000..af3221c --- /dev/null +++ b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java @@ -0,0 +1,158 @@ +/* + * 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.features; + +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; +import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.collect.PagedIterable; +import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.domain.Operation; +import org.jclouds.googlecomputeengine.functions.internal.ParseGlobalOperations; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.oauth.v2.config.OAuthScopes; +import org.jclouds.oauth.v2.filters.OAuthAuthenticator; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.annotations.Transform; + +/** + * Provides access to Global Operations via their REST API. + * + * @see <a href="https://developers.google.com/compute/docs/reference/v1/globalOperations"/> + */ +@SkipEncoding({'/', '='}) +@RequestFilters(OAuthAuthenticator.class) +public interface GlobalOperationApi { + + /** + * Retrieves the specified operation resource. + * + * @param operationName name of the operation resource to return. + * @return If successful, this method returns an Operation resource + */ + @Named("GlobalOperations:get") + @GET + @Path("/global/operations/{operation}") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + Operation get(@PathParam("operation") String operationName); + + /** + * Deletes the specified operation resource. + * + * @param operationName name of the operation resource to delete. + */ + @Named("GlobalOperations:delete") + @DELETE + @Path("/global/operations/{operation}") + @OAuthScopes(COMPUTE_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + void delete(@PathParam("operation") String operationName); + + /** + * @see org.jclouds.googlecomputeengine.features.GlobalOperationApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("GlobalOperations:list") + @GET + @Path("/global/operations") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @Consumes(MediaType.APPLICATION_JSON) + @ResponseParser(ParseGlobalOperations.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Operation> listFirstPage(); + + /** + * @see org.jclouds.googlecomputeengine.features.GlobalOperationApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("GlobalOperations:list") + @GET + @Path("/global/operations") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @Consumes(MediaType.APPLICATION_JSON) + @ResponseParser(ParseGlobalOperations.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Operation> listAtMarker(@QueryParam("pageToken") @Nullable String marker); + + /** + * Retrieves the listFirstPage of operation resources contained within the specified project. + * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() + * has not been set. + * + * @param marker marks the beginning of the next list page + * @param listOptions listing options + * @return a page of the list, starting at marker + * @see org.jclouds.googlecomputeengine.options.ListOptions + * @see org.jclouds.googlecomputeengine.domain.ListPage + */ + @Named("GlobalOperations:list") + @GET + @Path("/global/operations") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @Consumes(MediaType.APPLICATION_JSON) + @ResponseParser(ParseGlobalOperations.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Operation> listAtMarker(@QueryParam("pageToken") @Nullable String marker, + ListOptions listOptions); + + /** + * @see org.jclouds.googlecomputeengine.features.GlobalOperationApi#list(org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("GlobalOperations:list") + @GET + @Path("/global/operations") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @Consumes(MediaType.APPLICATION_JSON) + @ResponseParser(ParseGlobalOperations.class) + @Transform(ParseGlobalOperations.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Operation> list(); + + /** + * A paged version of GlobalOperationApi#listFirstPage() + * + * @return a Paged, Fluent Iterable that is able to fetch additional pages when required + * @see org.jclouds.collect.PagedIterable + * @see org.jclouds.googlecomputeengine.features.GlobalOperationApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("GlobalOperations:list") + @GET + @Path("/global/operations") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @Consumes(MediaType.APPLICATION_JSON) + @ResponseParser(ParseGlobalOperations.class) + @Transform(ParseGlobalOperations.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Operation> list(ListOptions listOptions); + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/4203d59b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java new file mode 100644 index 0000000..cbac67e --- /dev/null +++ b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java @@ -0,0 +1,167 @@ +/* + * 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.features; + +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; +import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.collect.PagedIterable; +import org.jclouds.googlecomputeengine.domain.Image; +import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.domain.Operation; +import org.jclouds.googlecomputeengine.functions.internal.ParseImages; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.oauth.v2.config.OAuthScopes; +import org.jclouds.oauth.v2.filters.OAuthAuthenticator; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.annotations.Transform; + +/** + * Provides access to Images via their REST API. + * <p/> + * + * @see <a href="https://developers.google.com/compute/docs/reference/v1/images"/> + */ +@SkipEncoding({'/', '='}) +@RequestFilters(OAuthAuthenticator.class) +public interface ImageApi { + /** + * Returns the specified image resource. + * + * @param imageName name of the image resource to return. + * @return an Image resource + */ + @Named("Images:get") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/global/images/{image}") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Image get(@PathParam("image") String imageName); + + /** + * Deletes the specified image resource. + * + * @param imageName name of the image resource to delete. + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. If the image did not exist the result is null. + */ + @Named("Images:delete") + @DELETE + @Consumes(MediaType.APPLICATION_JSON) + @Path("/global/images/{image}") + @OAuthScopes(COMPUTE_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Operation delete(@PathParam("image") String imageName); + + /** + * @see ImageApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Images:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/global/images") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseImages.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Image> listFirstPage(); + + /** + * @see ImageApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Images:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/global/images") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseImages.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Image> listAtMarker(@QueryParam("pageToken") @Nullable String marker); + + /** + * Retrieves the list of image resources available to the specified project. + * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not + * been set. + * + * @param marker marks the beginning of the next list page + * @param listOptions listing options + * @return a page of the list + * @see ListOptions + * @see org.jclouds.googlecomputeengine.domain.ListPage + */ + @Named("Images:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/global/images") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseImages.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Image> listAtMarker(@QueryParam("pageToken") @Nullable String marker, ListOptions listOptions); + + /** + * A paged version of ImageApi#list() + * + * @return a Paged, Fluent Iterable that is able to fetch additional pages when required + * @see PagedIterable + * @see ImageApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Images:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/global/images") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseImages.class) + @Transform(ParseImages.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Image> list(); + + /** + * A paged version of ImageApi#list() + * + * @return a Paged, Fluent Iterable that is able to fetch additional pages when required + * @see PagedIterable + * @see ImageApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Images:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/global/images") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseImages.class) + @Transform(ParseImages.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Image> list(ListOptions options); + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/4203d59b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java new file mode 100644 index 0000000..ab80fb5 --- /dev/null +++ b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java @@ -0,0 +1,381 @@ +/* + * 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.features; + +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE; + +import java.util.Map; +import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; +import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.collect.PagedIterable; +import org.jclouds.googlecomputeengine.domain.Instance; +import org.jclouds.googlecomputeengine.domain.InstanceTemplate; +import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.domain.Operation; +import org.jclouds.googlecomputeengine.functions.internal.ParseInstances; +import org.jclouds.googlecomputeengine.handlers.InstanceBinder; +import org.jclouds.googlecomputeengine.handlers.MetadataBinder; +import org.jclouds.googlecomputeengine.options.AttachDiskOptions; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.oauth.v2.config.OAuthScopes; +import org.jclouds.oauth.v2.filters.OAuthAuthenticator; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.annotations.Transform; +import org.jclouds.rest.binders.BindToJsonPayload; + +/** + * Provides access to Instances via their REST API. + * + * @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/> + * @see InstanceApi + */ +@SkipEncoding({'/', '='}) +@RequestFilters(OAuthAuthenticator.class) +public interface InstanceApi { + + /** + * Returns the specified instance resource. + * + * @param zone zone the instance is in. + * @param instanceName name of the instance resource to return. + * @return an Instance resource + */ + @Named("Instances:get") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/instances/{instance}") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Instance getInZone(@PathParam("zone") String zone, @PathParam("instance") String instanceName); + + /** + * Creates a instance resource in the specified project using the data included in the request. + * + * + * @param instanceName this name of the instance to be created + * @param zone the name of the zone where the instance will be created + * @param template the instance template + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Instances:insert") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/instances") + @OAuthScopes({COMPUTE_SCOPE}) + @MapBinder(InstanceBinder.class) + Operation createInZone(@PayloadParam("name") String instanceName, @PathParam("zone") String zone, + @PayloadParam("template") InstanceTemplate template); + + + /** + * Deletes the specified instance resource. + * + * @param zone the instance is in. + * @param instanceName name of the instance resource to delete. + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. If the instance did not exist the result is null. + */ + @Named("Instances:delete") + @DELETE + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/instances/{instance}") + @OAuthScopes(COMPUTE_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Operation deleteInZone(@PathParam("zone") String zone, @PathParam("instance") String instanceName); + + /** + * A paged version of InstanceApi#listInZone() + * + * @param zone zone instances are in + * @return a Paged, Fluent Iterable that is able to fetch additional pages when required + * @see PagedIterable + * @see InstanceApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Instances:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/instances") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseInstances.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Instance> listFirstPageInZone(@PathParam("zone") String zone); + + /** + * Retrieves the list of instance resources available to the specified project. + * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not + * been set. + * + * @param zone zone instances are in + * @param marker marks the beginning of the next list page + * @param listOptions listing options + * @return a page of the list + * @see ListOptions + * @see org.jclouds.googlecomputeengine.domain.ListPage + */ + @Named("Instances:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/instances") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseInstances.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Instance> listAtMarkerInZone(@PathParam("zone") String zone, @Nullable String marker, + ListOptions listOptions); + + /** + * @see InstanceApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Instances:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/instances") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseInstances.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<Instance> listAtMarkerInZone(@PathParam("zone") String zone, + @Nullable String marker); + + /** + * @see InstanceApi#listInZone(String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Instances:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/instances") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseInstances.class) + @Transform(ParseInstances.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Instance> listInZone(@PathParam("zone") String zone); + + /** + * @see InstanceApi#listInZone(String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("Instances:list") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/instances") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseInstances.class) + @Transform(ParseInstances.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<Instance> listInZone(@PathParam("zone") String zone, ListOptions options); + + /** + * Adds an access config to an instance's network interface. + * + * @param zone zone instance is in + * @param instanceName the instance name. + * @param accessConfig the AccessConfig to add. + * @param networkInterfaceName network interface name. + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Instances:addAccessConfig") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/instances/{instance}/addAccessConfig") + @OAuthScopes({COMPUTE_SCOPE}) + Operation addAccessConfigToNicInZone(@PathParam("zone") String zone, + @PathParam("instance") String instanceName, + @BinderParam(BindToJsonPayload.class) + Instance.NetworkInterface.AccessConfig accessConfig, + @QueryParam("network_interface") String networkInterfaceName); + + /** + * Deletes an access config from an instance's network interface. + * + * @param zone zone instance is in + * @param instanceName the instance name. + * @param accessConfigName the name of the access config to delete + * @param networkInterfaceName network interface name. + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Instances:deleteAccessConfig") + @DELETE + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/instances/{instance}/deleteAccessConfig") + @OAuthScopes(COMPUTE_SCOPE) + Operation deleteAccessConfigFromNicInZone(@PathParam("zone") String zone, + @PathParam("instance") String instanceName, + @QueryParam("access_config") String accessConfigName, + @QueryParam("network_interface") String networkInterfaceName); + + /** + * Returns the specified instance's serial port output. + * + * @param zone zone instance is in + * @param instanceName the instance name. + * @return if successful, this method returns a SerialPortOutput containing the instance's serial output. + */ + @Named("Instances:serialPort") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/instances/{instance}/serialPort") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + Instance.SerialPortOutput getSerialPortOutputInZone(@PathParam("zone") String zone, + @PathParam("instance") String instanceName); + + /** + * Hard-resets the instance. + * + * @param zone the zone the instance is in + * @param instanceName the instance name + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. If the instance did not exist the result is null. + */ + @Named("Instances:reset") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/instances/{instance}/reset") + @OAuthScopes(COMPUTE_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Operation resetInZone(@PathParam("zone") String zone, + @PathParam("instance") String instanceName); + + /** + * Attaches a disk to an instance + * + * @param zone The zone the instance is in. + * @param instanceName The instance name to attach to + * @param attachDiskOptions The options for attaching the disk. + * + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Instances:attachDisk") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/instances/{instance}/attachDisk") + @OAuthScopes(COMPUTE_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Operation attachDiskInZone(@PathParam("zone") String zone, + @PathParam("instance") String instanceName, + @BinderParam(BindToJsonPayload.class) AttachDiskOptions attachDiskOptions); + + /** + * Detaches an attached disk from an instance + * + * @param zone The zone the instance is in. + * @param instanceName The instance name to attach to + * @param deviceName The device name of the disk to detach. + * + * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to + * you, and look for the status field. + */ + @Named("Instances:detachDisk") + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Path("/zones/{zone}/instances/{instance}/detachDisk") + @OAuthScopes(COMPUTE_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Operation detachDiskInZone(@PathParam("zone") String zone, + @PathParam("instance") String instanceName, + @QueryParam("deviceName") String deviceName); + + /** + * Sets metadata for an instance using the data included in the request. + * <p/> + * NOTE: This *sets* metadata items on the project (vs *adding* items to metadata), + * if there are pre-existing metadata items that must be kept these must be fetched first and then re-set on the + * new Metadata, e.g. + * <pre><tt> + * Metadata.Builder current = instanceApi.getInZone("us-central1-a", "myInstance").getMetadata().toBuilder(); + * current.addItem("newItem","newItemValue"); + * instanceApi.setMetadataInZone("us-central1-a", "myInstance", current.build()); + * </tt></pre> + * + * @param zone The zone the instance is in + * @param instanceName The name of the instance + * @param metadata the metadata to set + * @param fingerprint The current fingerprint for the items + * + * @return an Operations resource. To check on the status of an operation, poll the Operations resource returned + * to you, and look for the status field. + */ + @Named("Instances:setMetadata") + @POST + @Path("/zones/{zone}/instances/{instance}/setMetadata") + @OAuthScopes(COMPUTE_SCOPE) + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + @MapBinder(MetadataBinder.class) + @Nullable + Operation setMetadataInZone(@PathParam("zone") String zone, + @PathParam("instance") String instanceName, + @PayloadParam("items") Map<String, String> metadata, + @PayloadParam("fingerprint") String fingerprint); + + /** + * Sets items for an instance + * + * @param zone The zone the instance is in + * @param instanceName the name of the instance + * @param items A set of items + * @param fingerprint The current fingerprint for the items + * @return an Operations resource. To check on the status of an operation, poll the Operations resource returned + * to you, and look for the status field. + */ + @Named("Instances:setTags") + @POST + @Path("/zones/{zone}/instances/{instance}/setTags") + @OAuthScopes(COMPUTE_SCOPE) + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + @MapBinder(BindToJsonPayload.class) + @Nullable + Operation setTagsInZone(@PathParam("zone") String zone, + @PathParam("instance") String instanceName, + @PayloadParam("items") Set<String> items, + @PayloadParam("fingerprint") String fingerprint); + +} + http://git-wip-us.apache.org/repos/asf/stratos/blob/4203d59b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java new file mode 100644 index 0000000..e88362b --- /dev/null +++ b/dependencies/jclouds/apis/gce/1.8.0-stratos/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java @@ -0,0 +1,143 @@ +/* + * 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.features; + +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404; +import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.collect.PagedIterable; +import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.domain.MachineType; +import org.jclouds.googlecomputeengine.functions.internal.ParseMachineTypes; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.oauth.v2.config.OAuthScopes; +import org.jclouds.oauth.v2.filters.OAuthAuthenticator; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.annotations.Transform; + +/** + * Provides access to MachineTypes via their REST API. + * + * @see <a href="https://developers.google.com/compute/docs/reference/v1/machineTypes"/> + */ +@SkipEncoding({'/', '='}) +@RequestFilters(OAuthAuthenticator.class) +@Consumes(MediaType.APPLICATION_JSON) +public interface MachineTypeApi { + + /** + * Returns the specified machine type resource + * + * @param zone the name of the zone the machine type is in + * @param machineTypeName name of the machine type resource to return. + * @return If successful, this method returns a MachineType resource + */ + @Named("MachineTypes:get") + @GET + @Path("/zones/{zone}/machineTypes/{machineType}") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @Fallback(NullOnNotFoundOr404.class) + MachineType getInZone(@PathParam("zone") String zone, @PathParam("machineType") String machineTypeName); + + /** + * @see MachineTypeApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("MachineTypes:list") + @GET + @Path("/zones/{zone}/machineTypes") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseMachineTypes.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<MachineType> listFirstPageInZone(@PathParam("zone") String zone); + + /** + * @see MachineTypeApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("MachineTypes:list") + @GET + @Path("/zones/{zone}/machineTypes") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseMachineTypes.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<MachineType> listAtMarkerInZone(@PathParam("zone") String zone, @QueryParam("pageToken") @Nullable String marker); + + /** + * Retrieves the list of machine type resources available to the specified project. + * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not + * been set. + * + * @param zone The name of the zone to list in. + * @param marker marks the beginning of the next list page + * @param listOptions listing options + * @return a page of the list + * @see ListOptions + * @see org.jclouds.googlecomputeengine.domain.ListPage + */ + @Named("MachineTypes:list") + @GET + @Path("/zones/{zone}/machineTypes") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseMachineTypes.class) + @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class) + ListPage<MachineType> listAtMarkerInZone(@PathParam("zone") String zone, + @QueryParam("pageToken") @Nullable String marker, + ListOptions listOptions); + + /** + * @see MachineTypeApi#listInZone(String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("MachineTypes:list") + @GET + @Path("/zones/{zone}/machineTypes") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseMachineTypes.class) + @Transform(ParseMachineTypes.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<MachineType> listInZone(@PathParam("zone") String zone); + + /** + * A paged version of MachineTypeApi#listInZone(String) + * + * @param zone the zone to list in + * @return a Paged, Fluent Iterable that is able to fetch additional pages when required + * @see PagedIterable + * @see MachineTypeApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions) + */ + @Named("MachineTypes:list") + @GET + @Path("/zones/{zone}/machineTypes") + @OAuthScopes(COMPUTE_READONLY_SCOPE) + @ResponseParser(ParseMachineTypes.class) + @Transform(ParseMachineTypes.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable<MachineType> listInZone(@PathParam("zone") String zone, ListOptions listOptions); + +}
