Skip to content

Commit 912ec8b

Browse files
committed
Fix Compute operations issues
- Fix javadoc errors - Fix OperationId and Operation tests - Fix RegionOperationId equals
1 parent 231fe42 commit 912ec8b

File tree

10 files changed

+240
-270
lines changed

10 files changed

+240
-270
lines changed

gcloud-java-compute/src/main/java/com/google/gcloud/compute/Compute.java

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,16 @@ enum OperationField {
244244
NAME("name"),
245245
OPERATION_TYPE("operationType"),
246246
PROGRESS("progress"),
247+
REGION("region"),
247248
SELF_LINK("selfLink"),
248249
START_TIME("startTime"),
249250
STATUS("status"),
250251
STATUS_MESSAGE("statusMessage"),
251-
REGION("region"),
252252
TARGET_ID("targetId"),
253253
TARGET_LINK("targetLink"),
254254
USER("user"),
255-
WARNINGS("warnings");
255+
WARNINGS("warnings"),
256+
ZONE("zone");
256257

257258
private final String selector;
258259

@@ -292,7 +293,7 @@ enum ComparisonOperator {
292293
EQ,
293294

294295
/**
295-
* Defines an inequality filter.
296+
* Defines a not-equals filter.
296297
*/
297298
NE
298299
}
@@ -350,7 +351,7 @@ public static DiskTypeFilter equals(DiskTypeField field, String value) {
350351
}
351352

352353
/**
353-
* Returns an equality filter for the given field and string value. For string fields,
354+
* Returns a not-equals filter for the given field and string value. For string fields,
354355
* {@code value} is interpreted as a regular expression using RE2 syntax. {@code value} must
355356
* match the entire field.
356357
*
@@ -368,7 +369,7 @@ public static DiskTypeFilter equals(DiskTypeField field, long value) {
368369
}
369370

370371
/**
371-
* Returns an inequality filter for the given field and long value.
372+
* Returns a not-equals filter for the given field and long value.
372373
*/
373374
public static DiskTypeFilter notEquals(DiskTypeField field, long value) {
374375
return new DiskTypeFilter(checkNotNull(field), ComparisonOperator.NE, value);
@@ -398,7 +399,7 @@ public static MachineTypeFilter equals(MachineTypeField field, String value) {
398399
}
399400

400401
/**
401-
* Returns an equality filter for the given field and string value. For string fields,
402+
* Returns a not-equals filter for the given field and string value. For string fields,
402403
* {@code value} is interpreted as a regular expression using RE2 syntax. {@code value} must
403404
* match the entire field.
404405
*
@@ -416,7 +417,7 @@ public static MachineTypeFilter equals(MachineTypeField field, long value) {
416417
}
417418

418419
/**
419-
* Returns an inequality filter for the given field and long value.
420+
* Returns a not-equals filter for the given field and long value.
420421
*/
421422
public static MachineTypeFilter notEquals(MachineTypeField field, long value) {
422423
return new MachineTypeFilter(checkNotNull(field), ComparisonOperator.NE, value);
@@ -446,7 +447,7 @@ public static RegionFilter equals(RegionField field, String value) {
446447
}
447448

448449
/**
449-
* Returns an equality filter for the given field and string value. For string fields,
450+
* Returns a not-equals filter for the given field and string value. For string fields,
450451
* {@code value} is interpreted as a regular expression using RE2 syntax. {@code value} must
451452
* match the entire field.
452453
*
@@ -480,7 +481,7 @@ public static ZoneFilter equals(ZoneField field, String value) {
480481
}
481482

482483
/**
483-
* Returns an equality filter for the given field and string value. For string fields,
484+
* Returns a not-equals filter for the given field and string value. For string fields,
484485
* {@code value} is interpreted as a regular expression using RE2 syntax. {@code value} must
485486
* match the entire field.
486487
*
@@ -514,7 +515,7 @@ public static OperationFilter equals(OperationField field, String value) {
514515
}
515516

516517
/**
517-
* Returns an equality filter for the given field and string value. For string fields,
518+
* Returns a not-equals filter for the given field and string value. For string fields,
518519
* {@code value} is interpreted as a regular expression using RE2 syntax. {@code value} must
519520
* match the entire field.
520521
*
@@ -532,7 +533,7 @@ public static OperationFilter equals(OperationField field, long value) {
532533
}
533534

534535
/**
535-
* Returns an inequality filter for the given field and long value.
536+
* Returns a not-equals filter for the given field and long value.
536537
*/
537538
public static OperationFilter notEquals(OperationField field, long value) {
538539
return new OperationFilter(checkNotNull(field), ComparisonOperator.NE, value);
@@ -546,7 +547,7 @@ public static OperationFilter equals(OperationField field, int value) {
546547
}
547548

548549
/**
549-
* Returns an inequality filter for the given field and integer value.
550+
* Returns a not-equals filter for the given field and integer value.
550551
*/
551552
public static OperationFilter notEquals(OperationField field, int value) {
552553
return new OperationFilter(checkNotNull(field), ComparisonOperator.NE, value);
@@ -566,8 +567,8 @@ private DiskTypeOption(ComputeRpc.Option option, Object value) {
566567

567568
/**
568569
* Returns an option to specify the disk type's fields to be returned by the RPC call. If this
569-
* option is not provided all disk type's fields are returned. {@code DiskTypeOption.fields} can
570-
* be used to specify only the fields of interest. {@link DiskType#diskTypeId()} is always
570+
* option is not provided, all disk type's fields are returned. {@code DiskTypeOption.fields}
571+
* can be used to specify only the fields of interest. {@link DiskType#diskTypeId()} is always
571572
* returned, even if not specified.
572573
*/
573574
public static DiskTypeOption fields(DiskTypeField... fields) {
@@ -587,7 +588,7 @@ private DiskTypeListOption(ComputeRpc.Option option, Object value) {
587588
}
588589

589590
/**
590-
* Returns an option to specify a filter to the disk types being listed.
591+
* Returns an option to specify a filter on the disk types being listed.
591592
*/
592593
public static DiskTypeListOption filter(DiskTypeFilter filter) {
593594
return new DiskTypeListOption(ComputeRpc.Option.FILTER, filter.toPb());
@@ -609,9 +610,9 @@ public static DiskTypeListOption startPageToken(String pageToken) {
609610

610611
/**
611612
* Returns an option to specify the disk type's fields to be returned by the RPC call. If this
612-
* option is not provided all disk type's fields are returned. {@code DiskTypeListOption.fields}
613-
* can be used to specify only the fields of interest. {@link DiskType#diskTypeId()} is always
614-
* returned, even if not specified.
613+
* option is not provided, all disk type's fields are returned.
614+
* {@code DiskTypeListOption.fields} can be used to specify only the fields of interest.
615+
* {@link DiskType#diskTypeId()} is always returned, even if not specified.
615616
*/
616617
public static DiskTypeListOption fields(DiskTypeField... fields) {
617618
StringBuilder builder = new StringBuilder();
@@ -632,7 +633,7 @@ private DiskTypeAggregatedListOption(ComputeRpc.Option option, Object value) {
632633
}
633634

634635
/**
635-
* Returns an option to specify a filter to the disk types being listed.
636+
* Returns an option to specify a filter on the disk types being listed.
636637
*/
637638
public static DiskTypeAggregatedListOption filter(DiskTypeFilter filter) {
638639
return new DiskTypeAggregatedListOption(ComputeRpc.Option.FILTER, filter.toPb());
@@ -666,7 +667,7 @@ private MachineTypeOption(ComputeRpc.Option option, Object value) {
666667

667668
/**
668669
* Returns an option to specify the machine type's fields to be returned by the RPC call. If
669-
* this option is not provided all machine type's fields are returned.
670+
* this option is not provided, all machine type's fields are returned.
670671
* {@code MachineTypeOption.fields} can be used to specify only the fields of interest.
671672
* {@link MachineType#machineTypeId()} is always returned, even if not specified.
672673
*/
@@ -687,7 +688,7 @@ private MachineTypeListOption(ComputeRpc.Option option, Object value) {
687688
}
688689

689690
/**
690-
* Returns an option to specify a filter to the machine types being listed.
691+
* Returns an option to specify a filter on the machine types being listed.
691692
*/
692693
public static MachineTypeListOption filter(MachineTypeFilter filter) {
693694
return new MachineTypeListOption(ComputeRpc.Option.FILTER, filter.toPb());
@@ -709,7 +710,7 @@ public static MachineTypeListOption startPageToken(String pageToken) {
709710

710711
/**
711712
* Returns an option to specify the machine type's fields to be returned by the RPC call. If
712-
* this option is not provided all machine type's fields are returned.
713+
* this option is not provided, all machine type's fields are returned.
713714
* {@code MachineTypeListOption.fields} can be used to specify only the fields of interest.
714715
* {@link MachineType#machineTypeId()} is always returned, even if not specified.
715716
*/
@@ -732,7 +733,7 @@ private MachineTypeAggregatedListOption(ComputeRpc.Option option, Object value)
732733
}
733734

734735
/**
735-
* Returns an option to specify a filter to the machine types being listed.
736+
* Returns an option to specify a filter on the machine types being listed.
736737
*/
737738
public static MachineTypeAggregatedListOption filter(MachineTypeFilter filter) {
738739
return new MachineTypeAggregatedListOption(ComputeRpc.Option.FILTER, filter.toPb());
@@ -766,7 +767,7 @@ private RegionOption(ComputeRpc.Option option, Object value) {
766767

767768
/**
768769
* Returns an option to specify the region's fields to be returned by the RPC call. If this
769-
* option is not provided all region's fields are returned. {@code RegionOption.fields} can be
770+
* option is not provided, all region's fields are returned. {@code RegionOption.fields} can be
770771
* used to specify only the fields of interest. {@link Region#regionId()} is always
771772
* returned, even if not specified.
772773
*/
@@ -787,7 +788,7 @@ private RegionListOption(ComputeRpc.Option option, Object value) {
787788
}
788789

789790
/**
790-
* Returns an option to specify a filter to the regions being listed.
791+
* Returns an option to specify a filter on the regions being listed.
791792
*/
792793
public static RegionListOption filter(RegionFilter filter) {
793794
return new RegionListOption(ComputeRpc.Option.FILTER, filter.toPb());
@@ -809,7 +810,7 @@ public static RegionListOption startPageToken(String pageToken) {
809810

810811
/**
811812
* Returns an option to specify the region's fields to be returned by the RPC call. If this
812-
* option is not provided all region's fields are returned. {@code RegionListOption.fields} can
813+
* option is not provided, all region's fields are returned. {@code RegionListOption.fields} can
813814
* be used to specify only the fields of interest. {@link Region#regionId()} is always
814815
* returned, even if not specified.
815816
*/
@@ -833,7 +834,7 @@ private ZoneOption(ComputeRpc.Option option, Object value) {
833834

834835
/**
835836
* Returns an option to specify the zone's fields to be returned by the RPC call. If this option
836-
* is not provided all zone's fields are returned. {@code ZoneOption.fields} can be used to
837+
* is not provided, all zone's fields are returned. {@code ZoneOption.fields} can be used to
837838
* specify only the fields of interest. {@link Zone#zoneId()} is always returned, even if
838839
* not specified.
839840
*/
@@ -854,7 +855,7 @@ private ZoneListOption(ComputeRpc.Option option, Object value) {
854855
}
855856

856857
/**
857-
* Returns an option to specify a filter to the zones being listed.
858+
* Returns an option to specify a filter on the zones being listed.
858859
*/
859860
public static ZoneListOption filter(ZoneFilter filter) {
860861
return new ZoneListOption(ComputeRpc.Option.FILTER, filter.toPb());
@@ -876,7 +877,7 @@ public static ZoneListOption startPageToken(String pageToken) {
876877

877878
/**
878879
* Returns an option to specify the zone's fields to be returned by the RPC call. If this option
879-
* is not provided all zone's fields are returned. {@code ZoneListOption.fields} can be used to
880+
* is not provided, all zone's fields are returned. {@code ZoneListOption.fields} can be used to
880881
* specify only the fields of interest. {@link Zone#zoneId()} is always returned, even if
881882
* not specified.
882883
*/
@@ -900,9 +901,9 @@ private LicenseOption(ComputeRpc.Option option, Object value) {
900901

901902
/**
902903
* Returns an option to specify the license's fields to be returned by the RPC call. If this
903-
* option is not provided all license's fields are returned. {@code LicenseOption.fields} can be
904-
* used to specify only the fields of interest. {@link License#licenseId()} is always returned,
905-
* even if not specified.
904+
* option is not provided, all license's fields are returned. {@code LicenseOption.fields} can
905+
* be used to specify only the fields of interest. {@link License#licenseId()} is always
906+
* returned, even if not specified.
906907
*/
907908
public static LicenseOption fields(LicenseField... fields) {
908909
return new LicenseOption(ComputeRpc.Option.FIELDS, LicenseField.selector(fields));
@@ -922,7 +923,7 @@ private OperationOption(ComputeRpc.Option option, Object value) {
922923

923924
/**
924925
* Returns an option to specify the operation's fields to be returned by the RPC call. If this
925-
* option is not provided all operation's fields are returned. {@code OperationOption.fields}
926+
* option is not provided, all operation's fields are returned. {@code OperationOption.fields}
926927
* can be used to specify only the fields of interest. {@link Operation#operationId()} is
927928
* always returned, even if not specified.
928929
*/
@@ -943,7 +944,7 @@ private OperationListOption(ComputeRpc.Option option, Object value) {
943944
}
944945

945946
/**
946-
* Returns an option to specify a filter to the operations being listed.
947+
* Returns an option to specify a filter on the operations being listed.
947948
*/
948949
public static OperationListOption filter(OperationFilter filter) {
949950
return new OperationListOption(ComputeRpc.Option.FILTER, filter.toPb());
@@ -965,7 +966,7 @@ public static OperationListOption startPageToken(String pageToken) {
965966

966967
/**
967968
* Returns an option to specify the operation's fields to be returned by the RPC call. If this
968-
* option is not provided all operation's fields are returned.
969+
* option is not provided, all operation's fields are returned.
969970
* {@code OperationListOption.fields} can be used to specify only the fields of interest.
970971
* {@link Operation#operationId()} is always returned, even if not specified.
971972
*/

gcloud-java-compute/src/main/java/com/google/gcloud/compute/ComputeImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public Page<Operation> nextPage() {
195195

196196
private static class ZoneOperationPageFetcher implements NextPageFetcher<Operation> {
197197

198-
private static final long serialVersionUID = 4111705358926164078L;
198+
private static final long serialVersionUID = -9012504536518197793L;
199199
private final Map<ComputeRpc.Option, ?> requestOptions;
200200
private final ComputeOptions serviceOptions;
201201
private final String zone;

gcloud-java-compute/src/main/java/com/google/gcloud/compute/Operation.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838

3939
/**
4040
* Google Compute Engine operations. Operation identity can be obtained via {@link #operationId()}.
41-
* For global operations {@link #operationId()} returns an {@link GlobalOperationId}, for region
42-
* operations {@link #operationId()} returns a {@link RegionOperationId}, for zone operations
43-
* {@link #operationId()} returns a {@link ZoneOperationId}. To get an {@code Operation} object with
44-
* the most recent information use {@link #reload(Compute.OperationOption...)}.
41+
* {@link #operationId()} returns {@link GlobalOperationId} for global operations,
42+
* {@link RegionOperationId} for region operations, and {@link ZoneOperationId} for zone operations.
43+
* To get an {@code Operation} object with the most recent information use
44+
* {@link #reload(Compute.OperationOption...)}.
4545
*/
4646
public final class Operation implements Serializable {
4747

@@ -71,7 +71,7 @@ public final class Operation implements Serializable {
7171
private final String description;
7272

7373
/**
74-
* Types of operations.
74+
* Status of an operation.
7575
*/
7676
public enum Status {
7777
PENDING,
@@ -286,9 +286,6 @@ public int hashCode() {
286286
}
287287
}
288288

289-
/**
290-
* Builder for Compute Engine operations.
291-
*/
292289
static final class Builder {
293290

294291
private Compute compute;
@@ -310,7 +307,6 @@ static final class Builder {
310307
private List<OperationWarning> warnings;
311308
private Integer httpErrorStatusCode;
312309
private String httpErrorMessage;
313-
314310
private String description;
315311

316312
Builder(Compute compute) {
@@ -460,10 +456,7 @@ Builder description(String description) {
460456
return this;
461457
}
462458

463-
/**
464-
* Creates an object.
465-
*/
466-
public Operation build() {
459+
Operation build() {
467460
return new Operation(this);
468461
}
469462
}
@@ -515,8 +508,8 @@ public Long creationTimestamp() {
515508

516509
/**
517510
* Returns the operation's identity. This method returns an {@link GlobalOperationId} for global
518-
* operations, returns a {@link RegionOperationId} for region operations and returns a
519-
* {@link ZoneOperationId} for zone operations.
511+
* operations, a {@link RegionOperationId} for region operations and a {@link ZoneOperationId} for
512+
* zone operations.
520513
*
521514
* @see <a href="https://www.ietf.org/rfc/rfc1035.txt">RFC1035</a>
522515
*/
@@ -658,7 +651,7 @@ public boolean exists() throws ComputeException {
658651
/**
659652
* Checks if this operation has completed its execution, either failing or succeeding. If the
660653
* operation does not exist this method returns {@code false}. To correctly wait for operation's
661-
* completion check that the operation exists first, using {@link #exists()}:
654+
* completion, check that the operation exists first using {@link #exists()}:
662655
* <pre> {@code
663656
* if (operation.exists()) {
664657
* while(!operation.isDone()) {

gcloud-java-compute/src/main/java/com/google/gcloud/compute/OperationId.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public interface OperationId {
3232
String operation();
3333

3434
/**
35-
* Returns a fully qualified URL to the entity.
35+
* Returns a fully qualified URL to the operation.
3636
*/
3737
String selfLink();
3838
}

gcloud-java-compute/src/main/java/com/google/gcloud/compute/RegionOperationId.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ public int hashCode() {
6262

6363
@Override
6464
public boolean equals(Object obj) {
65-
return obj instanceof RegionOperationId && baseEquals((RegionOperationId) obj);
65+
return obj instanceof RegionOperationId
66+
&& baseEquals((RegionOperationId) obj)
67+
&& Objects.equals(operation, ((RegionOperationId) obj).operation);
6668
}
6769

6870
@Override

0 commit comments

Comments
 (0)