@@ -582,7 +582,7 @@ class DiskTypeFilter extends ListFilter {
582
582
583
583
private static final long serialVersionUID = 4847837203592234453L ;
584
584
585
- DiskTypeFilter (DiskTypeField field , ComparisonOperator operator , Object value ) {
585
+ private DiskTypeFilter (DiskTypeField field , ComparisonOperator operator , Object value ) {
586
586
super (field .selector (), operator , value );
587
587
}
588
588
@@ -630,7 +630,7 @@ class MachineTypeFilter extends ListFilter {
630
630
631
631
private static final long serialVersionUID = 7346062041571853235L ;
632
632
633
- MachineTypeFilter (MachineTypeField field , ComparisonOperator operator , Object value ) {
633
+ private MachineTypeFilter (MachineTypeField field , ComparisonOperator operator , Object value ) {
634
634
super (field .selector (), operator , value );
635
635
}
636
636
@@ -678,7 +678,7 @@ class RegionFilter extends ListFilter {
678
678
679
679
private static final long serialVersionUID = 4464892812442567172L ;
680
680
681
- RegionFilter (RegionField field , ComparisonOperator operator , Object value ) {
681
+ private RegionFilter (RegionField field , ComparisonOperator operator , Object value ) {
682
682
super (field .selector (), operator , value );
683
683
}
684
684
@@ -712,7 +712,7 @@ class ZoneFilter extends ListFilter {
712
712
713
713
private static final long serialVersionUID = -3927428278548808737L ;
714
714
715
- ZoneFilter (ZoneField field , ComparisonOperator operator , Object value ) {
715
+ private ZoneFilter (ZoneField field , ComparisonOperator operator , Object value ) {
716
716
super (field .selector (), operator , value );
717
717
}
718
718
@@ -746,7 +746,7 @@ class OperationFilter extends ListFilter {
746
746
747
747
private static final long serialVersionUID = -3202249202748346427L ;
748
748
749
- OperationFilter (OperationField field , ComparisonOperator operator , Object value ) {
749
+ private OperationFilter (OperationField field , ComparisonOperator operator , Object value ) {
750
750
super (field .selector (), operator , value );
751
751
}
752
752
@@ -794,7 +794,7 @@ class AddressFilter extends ListFilter {
794
794
795
795
private static final long serialVersionUID = -227481644259653765L ;
796
796
797
- AddressFilter (AddressField field , ComparisonOperator operator , Object value ) {
797
+ private AddressFilter (AddressField field , ComparisonOperator operator , Object value ) {
798
798
super (field .selector (), operator , value );
799
799
}
800
800
@@ -821,6 +821,54 @@ public static AddressFilter notEquals(AddressField field, String value) {
821
821
}
822
822
}
823
823
824
+ /**
825
+ * Class for filtering snapshot lists.
826
+ */
827
+ class SnapshotFilter extends ListFilter {
828
+
829
+ private static final long serialVersionUID = 8757711630092406747L ;
830
+
831
+ private SnapshotFilter (SnapshotField field , ComparisonOperator operator , Object value ) {
832
+ super (field .selector (), operator , value );
833
+ }
834
+
835
+ /**
836
+ * Returns an equals filter for the given field and string value. For string fields,
837
+ * {@code value} is interpreted as a regular expression using RE2 syntax. {@code value} must
838
+ * match the entire field.
839
+ *
840
+ * @see <a href="https://github.com/google/re2/wiki/Syntax">RE2</a>
841
+ */
842
+ public static SnapshotFilter equals (SnapshotField field , String value ) {
843
+ return new SnapshotFilter (checkNotNull (field ), ComparisonOperator .EQ , checkNotNull (value ));
844
+ }
845
+
846
+ /**
847
+ * Returns a not-equals filter for the given field and string value. For string fields,
848
+ * {@code value} is interpreted as a regular expression using RE2 syntax. {@code value} must
849
+ * match the entire field.
850
+ *
851
+ * @see <a href="https://github.com/google/re2/wiki/Syntax">RE2</a>
852
+ */
853
+ public static SnapshotFilter notEquals (SnapshotField field , String value ) {
854
+ return new SnapshotFilter (checkNotNull (field ), ComparisonOperator .NE , checkNotNull (value ));
855
+ }
856
+
857
+ /**
858
+ * Returns an equals filter for the given field and long value.
859
+ */
860
+ public static SnapshotFilter equals (SnapshotField field , long value ) {
861
+ return new SnapshotFilter (checkNotNull (field ), ComparisonOperator .EQ , value );
862
+ }
863
+
864
+ /**
865
+ * Returns a not-equals filter for the given field and long value.
866
+ */
867
+ public static SnapshotFilter notEquals (SnapshotField field , long value ) {
868
+ return new SnapshotFilter (checkNotNull (field ), ComparisonOperator .NE , value );
869
+ }
870
+ }
871
+
824
872
/**
825
873
* Class for specifying disk type get options.
826
874
*/
@@ -863,6 +911,7 @@ public static DiskTypeListOption filter(DiskTypeFilter filter) {
863
911
864
912
/**
865
913
* Returns an option to specify the maximum number of disk types returned per page.
914
+ * {@code pageSize} must be between 0 and 500 (inclusive). If not specified 500 is used.
866
915
*/
867
916
public static DiskTypeListOption pageSize (long pageSize ) {
868
917
return new DiskTypeListOption (ComputeRpc .Option .MAX_RESULTS , pageSize );
@@ -908,6 +957,7 @@ public static DiskTypeAggregatedListOption filter(DiskTypeFilter filter) {
908
957
909
958
/**
910
959
* Returns an option to specify the maximum number of disk types returned per page.
960
+ * {@code pageSize} must be between 0 and 500 (inclusive). If not specified 500 is used.
911
961
*/
912
962
public static DiskTypeAggregatedListOption pageSize (long pageSize ) {
913
963
return new DiskTypeAggregatedListOption (ComputeRpc .Option .MAX_RESULTS , pageSize );
@@ -963,6 +1013,7 @@ public static MachineTypeListOption filter(MachineTypeFilter filter) {
963
1013
964
1014
/**
965
1015
* Returns an option to specify the maximum number of machine types returned per page.
1016
+ * {@code pageSize} must be between 0 and 500 (inclusive). If not specified 500 is used.
966
1017
*/
967
1018
public static MachineTypeListOption pageSize (long pageSize ) {
968
1019
return new MachineTypeListOption (ComputeRpc .Option .MAX_RESULTS , pageSize );
@@ -1008,6 +1059,7 @@ public static MachineTypeAggregatedListOption filter(MachineTypeFilter filter) {
1008
1059
1009
1060
/**
1010
1061
* Returns an option to specify the maximum number of machine types returned per page.
1062
+ * {@code pageSize} must be between 0 and 500 (inclusive). If not specified 500 is used.
1011
1063
*/
1012
1064
public static MachineTypeAggregatedListOption pageSize (long pageSize ) {
1013
1065
return new MachineTypeAggregatedListOption (ComputeRpc .Option .MAX_RESULTS , pageSize );
@@ -1063,6 +1115,7 @@ public static RegionListOption filter(RegionFilter filter) {
1063
1115
1064
1116
/**
1065
1117
* Returns an option to specify the maximum number of regions returned per page.
1118
+ * {@code pageSize} must be between 0 and 500 (inclusive). If not specified 500 is used.
1066
1119
*/
1067
1120
public static RegionListOption pageSize (long pageSize ) {
1068
1121
return new RegionListOption (ComputeRpc .Option .MAX_RESULTS , pageSize );
@@ -1130,6 +1183,7 @@ public static ZoneListOption filter(ZoneFilter filter) {
1130
1183
1131
1184
/**
1132
1185
* Returns an option to specify the maximum number of zones returned per page.
1186
+ * {@code pageSize} must be between 0 and 500 (inclusive). If not specified 500 is used.
1133
1187
*/
1134
1188
public static ZoneListOption pageSize (long pageSize ) {
1135
1189
return new ZoneListOption (ComputeRpc .Option .MAX_RESULTS , pageSize );
@@ -1219,6 +1273,7 @@ public static OperationListOption filter(OperationFilter filter) {
1219
1273
1220
1274
/**
1221
1275
* Returns an option to specify the maximum number of operations returned per page.
1276
+ * {@code pageSize} must be between 0 and 500 (inclusive). If not specified 500 is used.
1222
1277
*/
1223
1278
public static OperationListOption pageSize (long pageSize ) {
1224
1279
return new OperationListOption (ComputeRpc .Option .MAX_RESULTS , pageSize );
@@ -1286,6 +1341,7 @@ public static AddressListOption filter(AddressFilter filter) {
1286
1341
1287
1342
/**
1288
1343
* Returns an option to specify the maximum number of addresses returned per page.
1344
+ * {@code pageSize} must be between 0 and 500 (inclusive). If not specified 500 is used.
1289
1345
*/
1290
1346
public static AddressListOption pageSize (long pageSize ) {
1291
1347
return new AddressListOption (ComputeRpc .Option .MAX_RESULTS , pageSize );
@@ -1331,6 +1387,7 @@ public static AddressAggregatedListOption filter(AddressFilter filter) {
1331
1387
1332
1388
/**
1333
1389
* Returns an option to specify the maximum number of addresses returned per page.
1390
+ * {@code pageSize} must be between 0 and 500 (inclusive). If not specified 500 is used.
1334
1391
*/
1335
1392
public static AddressAggregatedListOption pageSize (long pageSize ) {
1336
1393
return new AddressAggregatedListOption (ComputeRpc .Option .MAX_RESULTS , pageSize );
@@ -1344,6 +1401,74 @@ public static AddressAggregatedListOption pageToken(String pageToken) {
1344
1401
}
1345
1402
}
1346
1403
1404
+ /**
1405
+ * Class for specifying snapshot get options.
1406
+ */
1407
+ class SnapshotOption extends Option {
1408
+
1409
+ private static final long serialVersionUID = -3505179459035500945L ;
1410
+
1411
+ private SnapshotOption (ComputeRpc .Option option , Object value ) {
1412
+ super (option , value );
1413
+ }
1414
+
1415
+ /**
1416
+ * Returns an option to specify the snapshot's fields to be returned by the RPC call. If this
1417
+ * option is not provided, all the snapshot's fields are returned. {@code SnapshotOption.fields}
1418
+ * can be used to specify only the fields of interest. {@link Snapshot#snapshotId()} is always
1419
+ * returned, even if not specified.
1420
+ */
1421
+ public static SnapshotOption fields (SnapshotField ... fields ) {
1422
+ return new SnapshotOption (ComputeRpc .Option .FIELDS , SnapshotField .selector (fields ));
1423
+ }
1424
+ }
1425
+
1426
+ /**
1427
+ * Class for specifying snapshot list options.
1428
+ */
1429
+ class SnapshotListOption extends Option {
1430
+
1431
+ private static final long serialVersionUID = 8278588147660831257L ;
1432
+
1433
+ private SnapshotListOption (ComputeRpc .Option option , Object value ) {
1434
+ super (option , value );
1435
+ }
1436
+
1437
+ /**
1438
+ * Returns an option to specify a filter on the snapshots being listed.
1439
+ */
1440
+ public static SnapshotListOption filter (SnapshotFilter filter ) {
1441
+ return new SnapshotListOption (ComputeRpc .Option .FILTER , filter .toPb ());
1442
+ }
1443
+
1444
+ /**
1445
+ * Returns an option to specify the maximum number of snapshots returned per page.
1446
+ * {@code pageSize} must be between 0 and 500 (inclusive). If not specified 500 is used.
1447
+ */
1448
+ public static SnapshotListOption pageSize (long pageSize ) {
1449
+ return new SnapshotListOption (ComputeRpc .Option .MAX_RESULTS , pageSize );
1450
+ }
1451
+
1452
+ /**
1453
+ * Returns an option to specify the page token from which to start listing snapshots.
1454
+ */
1455
+ public static SnapshotListOption pageToken (String pageToken ) {
1456
+ return new SnapshotListOption (ComputeRpc .Option .PAGE_TOKEN , pageToken );
1457
+ }
1458
+
1459
+ /**
1460
+ * Returns an option to specify the snapshot's fields to be returned by the RPC call. If this
1461
+ * option is not provided, all the snapshot's fields are returned.
1462
+ * {@code SnapshotListOption.fields} can be used to specify only the fields of interest.
1463
+ * {@link Snapshot#snapshotId()} is always returned, even if not specified.
1464
+ */
1465
+ public static SnapshotListOption fields (SnapshotField ... fields ) {
1466
+ StringBuilder builder = new StringBuilder ();
1467
+ builder .append ("items(" ).append (SnapshotField .selector (fields )).append ("),nextPageToken" );
1468
+ return new SnapshotListOption (ComputeRpc .Option .FIELDS , builder .toString ());
1469
+ }
1470
+ }
1471
+
1347
1472
/**
1348
1473
* Returns the requested disk type or {@code null} if not found.
1349
1474
*
@@ -1366,7 +1491,7 @@ public static AddressAggregatedListOption pageToken(String pageToken) {
1366
1491
Page <DiskType > listDiskTypes (String zone , DiskTypeListOption ... options );
1367
1492
1368
1493
/**
1369
- * Lists all disk types.
1494
+ * Lists the disk types in all zones .
1370
1495
*
1371
1496
* @throws ComputeException upon failure
1372
1497
*/
@@ -1394,7 +1519,7 @@ public static AddressAggregatedListOption pageToken(String pageToken) {
1394
1519
Page <MachineType > listMachineTypes (String zone , MachineTypeListOption ... options );
1395
1520
1396
1521
/**
1397
- * Lists all machine types.
1522
+ * Lists the machine types in all zones .
1398
1523
*
1399
1524
* @throws ComputeException upon failure
1400
1525
*/
@@ -1511,7 +1636,7 @@ public static AddressAggregatedListOption pageToken(String pageToken) {
1511
1636
Page <Address > listRegionAddresses (String region , AddressListOption ... options );
1512
1637
1513
1638
/**
1514
- * Lists all addresses.
1639
+ * Lists both global and region addresses.
1515
1640
*
1516
1641
* @throws ComputeException upon failure
1517
1642
*/
@@ -1525,4 +1650,53 @@ public static AddressAggregatedListOption pageToken(String pageToken) {
1525
1650
* @throws ComputeException upon failure
1526
1651
*/
1527
1652
Operation delete (AddressId addressId , OperationOption ... options );
1653
+
1654
+ /**
1655
+ * Creates a new snapshot.
1656
+ *
1657
+ * @return a zone operation if the create request was issued correctly, {@code null} if
1658
+ * {@code snapshot.sourceDisk} was not found
1659
+ * @throws ComputeException upon failure
1660
+ */
1661
+ Operation create (SnapshotInfo snapshot , OperationOption ... options );
1662
+
1663
+ /**
1664
+ * Returns the requested snapshot or {@code null} if not found.
1665
+ *
1666
+ * @throws ComputeException upon failure
1667
+ */
1668
+ Snapshot getSnapshot (String snapshot , SnapshotOption ... options );
1669
+
1670
+ /**
1671
+ * Lists snapshots.
1672
+ *
1673
+ * @throws ComputeException upon failure
1674
+ */
1675
+ Page <Snapshot > listSnapshots (SnapshotListOption ... options );
1676
+
1677
+ /**
1678
+ * Deletes the requested snapshot. Keep in mind that deleting a single snapshot might not
1679
+ * necessarily delete all the data for that snapshot. If any data for the snapshot that is marked
1680
+ * for deletion is needed for subsequent snapshots, the data will be moved to the next snapshot.
1681
+ *
1682
+ * @return a global operation if the request was issued correctly, {@code null} if the snapshot
1683
+ * was not found
1684
+ * @throws ComputeException upon failure
1685
+ * @see <a href="https://cloud.google.com/compute/docs/disks/persistent-disks#deleting_snapshot">
1686
+ * Deleting a snapshot</a>
1687
+ */
1688
+ Operation deleteSnapshot (SnapshotId snapshot , OperationOption ... options );
1689
+
1690
+ /**
1691
+ * Deletes the requested snapshot. Keep in mind that deleting a single snapshot might not
1692
+ * necessarily delete all the data for that snapshot. If any data on the snapshot that is marked
1693
+ * for deletion is needed for subsequent snapshots, the data will be moved to the next snapshot.
1694
+ *
1695
+ * @return a global operation if the request was issued correctly, {@code null} if the snapshot
1696
+ * was not found
1697
+ * @throws ComputeException upon failure
1698
+ * @see <a href="https://cloud.google.com/compute/docs/disks/persistent-disks#deleting_snapshot">
1699
+ * Deleting a snapshot</a>
1700
+ */
1701
+ Operation deleteSnapshot (String snapshot , OperationOption ... options );
1528
1702
}
0 commit comments