@@ -161,7 +161,6 @@ enum ZoneField {
161161 CREATION_TIMESTAMP ("creationTimestamp" ),
162162 DESCRIPTION ("description" ),
163163 ID ("id" ),
164- MAINTENANCE_WINDOWS ("maintenanceWindows" ),
165164 NAME ("name" ),
166165 REGION ("region" ),
167166 SELF_LINK ("selfLink" ),
@@ -917,6 +916,54 @@ public static ImageFilter notEquals(ImageField field, long value) {
917916 }
918917 }
919918
919+ /**
920+ * Class for filtering disk lists.
921+ */
922+ class DiskFilter extends ListFilter {
923+
924+ private static final long serialVersionUID = 5856790665396877913L ;
925+
926+ private DiskFilter (DiskField field , ComparisonOperator operator , Object value ) {
927+ super (field .selector (), operator , value );
928+ }
929+
930+ /**
931+ * Returns an equals filter for the given field and string value. For string fields,
932+ * {@code value} is interpreted as a regular expression using RE2 syntax. {@code value} must
933+ * match the entire field.
934+ *
935+ * @see <a href="https://github.com/google/re2/wiki/Syntax">RE2</a>
936+ */
937+ public static DiskFilter equals (DiskField field , String value ) {
938+ return new DiskFilter (checkNotNull (field ), ComparisonOperator .EQ , checkNotNull (value ));
939+ }
940+
941+ /**
942+ * Returns a not-equals filter for the given field and string value. For string fields,
943+ * {@code value} is interpreted as a regular expression using RE2 syntax. {@code value} must
944+ * match the entire field.
945+ *
946+ * @see <a href="https://github.com/google/re2/wiki/Syntax">RE2</a>
947+ */
948+ public static DiskFilter notEquals (DiskField field , String value ) {
949+ return new DiskFilter (checkNotNull (field ), ComparisonOperator .NE , checkNotNull (value ));
950+ }
951+
952+ /**
953+ * Returns an equals filter for the given field and long value.
954+ */
955+ public static DiskFilter equals (DiskField field , long value ) {
956+ return new DiskFilter (checkNotNull (field ), ComparisonOperator .EQ , value );
957+ }
958+
959+ /**
960+ * Returns a not-equals filter for the given field and long value.
961+ */
962+ public static DiskFilter notEquals (DiskField field , long value ) {
963+ return new DiskFilter (checkNotNull (field ), ComparisonOperator .NE , value );
964+ }
965+ }
966+
920967 /**
921968 * Class for specifying disk type get options.
922969 */
@@ -1585,6 +1632,112 @@ public static ImageListOption fields(ImageField... fields) {
15851632 }
15861633 }
15871634
1635+ /**
1636+ * Class for specifying disk get options.
1637+ */
1638+ class DiskOption extends Option {
1639+
1640+ private static final long serialVersionUID = -4354796876226661667L ;
1641+
1642+ private DiskOption (ComputeRpc .Option option , Object value ) {
1643+ super (option , value );
1644+ }
1645+
1646+ /**
1647+ * Returns an option to specify the disk's fields to be returned by the RPC call. If this option
1648+ * is not provided, all disk's fields are returned. {@code DiskOption.fields} can be used to
1649+ * specify only the fields of interest. {@link Disk#diskId()},
1650+ * {@link DiskConfiguration#diskType()} and either
1651+ * {@link SnapshotDiskConfiguration#sourceSnapshot()} or
1652+ * {@link ImageDiskConfiguration#sourceImage()} are always returned, even if not specified.
1653+ */
1654+ public static DiskOption fields (DiskField ... fields ) {
1655+ return new DiskOption (ComputeRpc .Option .FIELDS , DiskField .selector (fields ));
1656+ }
1657+ }
1658+
1659+ /**
1660+ * Class for specifying disk list options.
1661+ */
1662+ class DiskListOption extends Option {
1663+
1664+ private static final long serialVersionUID = -5148497888688645905L ;
1665+
1666+ private DiskListOption (ComputeRpc .Option option , Object value ) {
1667+ super (option , value );
1668+ }
1669+
1670+ /**
1671+ * Returns an option to specify a filter on the disks being listed.
1672+ */
1673+ public static DiskListOption filter (DiskFilter filter ) {
1674+ return new DiskListOption (ComputeRpc .Option .FILTER , filter .toPb ());
1675+ }
1676+
1677+ /**
1678+ * Returns an option to specify the maximum number of disks returned per page. {@code pageSize}
1679+ * must be between 0 and 500 (inclusive). If not specified 500 is used.
1680+ */
1681+ public static DiskListOption pageSize (long pageSize ) {
1682+ return new DiskListOption (ComputeRpc .Option .MAX_RESULTS , pageSize );
1683+ }
1684+
1685+ /**
1686+ * Returns an option to specify the page token from which to start listing disks.
1687+ */
1688+ public static DiskListOption pageToken (String pageToken ) {
1689+ return new DiskListOption (ComputeRpc .Option .PAGE_TOKEN , pageToken );
1690+ }
1691+
1692+ /**
1693+ * Returns an option to specify the disk's fields to be returned by the RPC call. If this option
1694+ * is not provided, all disk's fields are returned. {@code DiskListOption.fields} can be used to
1695+ * specify only the fields of interest. {@link Disk#diskId()},
1696+ * {@link DiskConfiguration#diskType()} and either
1697+ * {@link SnapshotDiskConfiguration#sourceSnapshot()} or
1698+ * {@link ImageDiskConfiguration#sourceImage()} are always returned, even if not specified.
1699+ */
1700+ public static DiskListOption fields (DiskField ... fields ) {
1701+ StringBuilder builder = new StringBuilder ();
1702+ builder .append ("items(" ).append (DiskField .selector (fields )).append ("),nextPageToken" );
1703+ return new DiskListOption (ComputeRpc .Option .FIELDS , builder .toString ());
1704+ }
1705+ }
1706+
1707+ /**
1708+ * Class for specifying disk aggregated list options.
1709+ */
1710+ class DiskAggregatedListOption extends Option {
1711+
1712+ private static final long serialVersionUID = 1163784797870242766L ;
1713+
1714+ private DiskAggregatedListOption (ComputeRpc .Option option , Object value ) {
1715+ super (option , value );
1716+ }
1717+
1718+ /**
1719+ * Returns an option to specify a filter on the disks being listed.
1720+ */
1721+ public static DiskAggregatedListOption filter (DiskFilter filter ) {
1722+ return new DiskAggregatedListOption (ComputeRpc .Option .FILTER , filter .toPb ());
1723+ }
1724+
1725+ /**
1726+ * Returns an option to specify the maximum number of disks returned per page. {@code pageSize}
1727+ * must be between 0 and 500 (inclusive). If not specified 500 is used.
1728+ */
1729+ public static DiskAggregatedListOption pageSize (long pageSize ) {
1730+ return new DiskAggregatedListOption (ComputeRpc .Option .MAX_RESULTS , pageSize );
1731+ }
1732+
1733+ /**
1734+ * Returns an option to specify the page token from which to start listing disks.
1735+ */
1736+ public static DiskAggregatedListOption pageToken (String pageToken ) {
1737+ return new DiskAggregatedListOption (ComputeRpc .Option .PAGE_TOKEN , pageToken );
1738+ }
1739+ }
1740+
15881741 /**
15891742 * Returns the requested disk type or {@code null} if not found.
15901743 *
@@ -1770,8 +1923,7 @@ public static ImageListOption fields(ImageField... fields) {
17701923 /**
17711924 * Creates a new snapshot.
17721925 *
1773- * @return a zone operation if the create request was issued correctly, {@code null} if
1774- * {@code snapshot.sourceDisk} was not found
1926+ * @return a zone operation for snapshot creation
17751927 * @throws ComputeException upon failure
17761928 */
17771929 Operation create (SnapshotInfo snapshot , OperationOption ... options );
@@ -1868,4 +2020,51 @@ public static ImageListOption fields(ImageField... fields) {
18682020 */
18692021 Operation deprecate (ImageId image , DeprecationStatus <ImageId > deprecationStatus ,
18702022 OperationOption ... options );
2023+
2024+ /**
2025+ * Returns the requested disk or {@code null} if not found.
2026+ *
2027+ * @throws ComputeException upon failure
2028+ */
2029+ Disk get (DiskId diskId , DiskOption ... options );
2030+
2031+ /**
2032+ * Creates a new disk.
2033+ *
2034+ * @return a zone operation for disk's creation
2035+ * @throws ComputeException upon failure
2036+ */
2037+ Operation create (DiskInfo disk , OperationOption ... options );
2038+
2039+ /**
2040+ * Lists disks for the provided zone.
2041+ *
2042+ * @throws ComputeException upon failure
2043+ */
2044+ Page <Disk > listDisks (String zone , DiskListOption ... options );
2045+
2046+ /**
2047+ * Lists disks for all zones.
2048+ *
2049+ * @throws ComputeException upon failure
2050+ */
2051+ Page <Disk > listDisks (DiskAggregatedListOption ... options );
2052+
2053+ /**
2054+ * Deletes the requested disk.
2055+ *
2056+ * @return a zone operation if the request was issued correctly, {@code null} if the disk was not
2057+ * found
2058+ * @throws ComputeException upon failure
2059+ */
2060+ Operation delete (DiskId disk , OperationOption ... options );
2061+
2062+ /**
2063+ * Resizes the disk to the requested size. The new size must be larger than the previous one.
2064+ *
2065+ * @return a zone operation if the request was issued correctly, {@code null} if the disk was not
2066+ * found
2067+ * @throws ComputeException upon failure or if the new disk size is smaller than the previous one
2068+ */
2069+ Operation resize (DiskId disk , long sizeGb , OperationOption ... options );
18712070}
0 commit comments