diff --git a/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Compute.java b/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Compute.java index 5cdb7eb0e85e..dbc2f0d49366 100644 --- a/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Compute.java +++ b/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Compute.java @@ -232,7 +232,6 @@ static String selector(LicenseField... fields) { */ enum OperationField { CLIENT_OPERATION_ID("clientOperationId"), - CREATION_TIMESTAMP("creationTimestamp"), DESCRIPTION("description"), END_TIME("endTime"), ERROR("error"), diff --git a/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Operation.java b/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Operation.java index 78afc170f671..2b35dac3fd2b 100644 --- a/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Operation.java +++ b/gcloud-java-compute/src/main/java/com/google/gcloud/compute/Operation.java @@ -52,7 +52,6 @@ public class Operation implements Serializable { private final ComputeOptions options; private final String id; private final OperationId operationId; - private final Long creationTimestamp; private final String clientOperationId; private final String operationType; private final String targetLink; @@ -296,7 +295,6 @@ static final class Builder { private Compute compute; private String id; - private Long creationTimestamp; private OperationId operationId; private String clientOperationId; private String operationType; @@ -324,9 +322,6 @@ static final class Builder { if (operationPb.getId() != null) { id = operationPb.getId().toString(); } - if (operationPb.getCreationTimestamp() != null) { - creationTimestamp = TIMESTAMP_FORMATTER.parseMillis(operationPb.getCreationTimestamp()); - } if (RegionOperationId.matchesUrl(operationPb.getSelfLink())) { operationId = RegionOperationId.fromUrl(operationPb.getSelfLink()); } else if (ZoneOperationId.matchesUrl(operationPb.getSelfLink())) { @@ -372,11 +367,6 @@ Builder id(String id) { return this; } - Builder creationTimestamp(Long creationTimestamp) { - this.creationTimestamp = creationTimestamp; - return this; - } - Builder operationId(OperationId operationId) { this.operationId = checkNotNull(operationId); return this; @@ -471,7 +461,6 @@ private Operation(Builder builder) { this.compute = checkNotNull(builder.compute); this.options = compute.options(); this.id = builder.id; - this.creationTimestamp = builder.creationTimestamp; this.operationId = checkNotNull(builder.operationId); this.clientOperationId = builder.clientOperationId; this.operationType = builder.operationType; @@ -505,13 +494,6 @@ public String id() { return id; } - /** - * Returns the creation timestamp in milliseconds since epoch. - */ - public Long creationTimestamp() { - return creationTimestamp; - } - /** * Returns the operation's identity. This method returns an {@link GlobalOperationId} for global * operations, a {@link RegionOperationId} for region operations and a {@link ZoneOperationId} for @@ -658,23 +640,21 @@ public boolean exists() throws ComputeException { /** * Checks if this operation has completed its execution, either failing or succeeding. If the - * operation does not exist this method returns {@code false}. To correctly wait for operation's - * completion, check that the operation exists first using {@link #exists()}: + * operation does not exist this method returns {@code true}. You can wait for operation + * completion with: *
 {@code
-   * if (operation.exists()) {
-   *   while(!operation.isDone()) {
-   *     Thread.sleep(1000L);
-   *   }
+   * while(!operation.isDone()) {
+   *   Thread.sleep(1000L);
    * }}
* - * @return {@code true} if this operation is in {@link Operation.Status#DONE} state, {@code false} - * if the state is not {@link Operation.Status#DONE} or the operation does not exist + * @return {@code true} if this operation is in {@link Operation.Status#DONE} state or if it does + * not exist, {@code false} if the state is not {@link Operation.Status#DONE} * @throws ComputeException upon failure */ public boolean isDone() throws ComputeException { Operation operation = compute.get(operationId, Compute.OperationOption.fields(Compute.OperationField.STATUS)); - return operation != null && operation.status() == Status.DONE; + return operation == null || operation.status() == Status.DONE; } /** @@ -705,7 +685,6 @@ public String toString() { return MoreObjects.toStringHelper(this) .add("id", id) .add("operationsId", operationId) - .add("creationTimestamp", creationTimestamp) .add("clientOperationId", clientOperationId) .add("operationType", operationType) .add("targetLink", targetLink) @@ -743,9 +722,6 @@ com.google.api.services.compute.model.Operation toPb() { if (id != null) { operationPb.setId(new BigInteger(id)); } - if (creationTimestamp != null) { - operationPb.setCreationTimestamp(TIMESTAMP_FORMATTER.print(creationTimestamp)); - } operationPb.setName(operationId.operation()); operationPb.setClientOperationId(clientOperationId); switch (operationId.type()) { diff --git a/gcloud-java-compute/src/test/java/com/google/gcloud/compute/ComputeImplTest.java b/gcloud-java-compute/src/test/java/com/google/gcloud/compute/ComputeImplTest.java index e193be1d8da5..edd8b2bd0cef 100644 --- a/gcloud-java-compute/src/test/java/com/google/gcloud/compute/ComputeImplTest.java +++ b/gcloud-java-compute/src/test/java/com/google/gcloud/compute/ComputeImplTest.java @@ -427,7 +427,6 @@ public void setUp() { Compute otherService = options.toBuilder().build().service(); globalOperation = new Operation.Builder(otherService) .id(ID) - .creationTimestamp(CREATION_TIMESTAMP) .operationId(GLOBAL_OPERATION_ID) .clientOperationId(CLIENT_OPERATION_ID) .operationType(OPERATION_TYPE) @@ -448,7 +447,6 @@ public void setUp() { .build(); zoneOperation = new Operation.Builder(otherService) .id(ID) - .creationTimestamp(CREATION_TIMESTAMP) .operationId(ZONE_OPERATION_ID) .clientOperationId(CLIENT_OPERATION_ID) .operationType(OPERATION_TYPE) @@ -469,7 +467,6 @@ public void setUp() { .build(); regionOperation = new Operation.Builder(otherService) .id(ID) - .creationTimestamp(CREATION_TIMESTAMP) .operationId(REGION_OPERATION_ID) .clientOperationId(CLIENT_OPERATION_ID) .operationType(OPERATION_TYPE) diff --git a/gcloud-java-compute/src/test/java/com/google/gcloud/compute/OperationTest.java b/gcloud-java-compute/src/test/java/com/google/gcloud/compute/OperationTest.java index 62899071ce32..450097c4ef30 100644 --- a/gcloud-java-compute/src/test/java/com/google/gcloud/compute/OperationTest.java +++ b/gcloud-java-compute/src/test/java/com/google/gcloud/compute/OperationTest.java @@ -89,7 +89,6 @@ private void initializeExpectedOperation(int optionsCalls) { replay(serviceMockReturnsOptions); globalOperation = new Operation.Builder(serviceMockReturnsOptions) .id(ID) - .creationTimestamp(CREATION_TIMESTAMP) .operationId(GLOBAL_OPERATION_ID) .clientOperationId(CLIENT_OPERATION_ID) .operationType(OPERATION_TYPE) @@ -110,7 +109,6 @@ private void initializeExpectedOperation(int optionsCalls) { .build(); zoneOperation = new Operation.Builder(serviceMockReturnsOptions) .id(ID) - .creationTimestamp(CREATION_TIMESTAMP) .operationId(ZONE_OPERATION_ID) .clientOperationId(CLIENT_OPERATION_ID) .operationType(OPERATION_TYPE) @@ -131,7 +129,6 @@ private void initializeExpectedOperation(int optionsCalls) { .build(); regionOperation = new Operation.Builder(serviceMockReturnsOptions) .id(ID) - .creationTimestamp(CREATION_TIMESTAMP) .operationId(REGION_OPERATION_ID) .clientOperationId(CLIENT_OPERATION_ID) .operationType(OPERATION_TYPE) @@ -157,7 +154,6 @@ private void initializeOperation() { operation = new Operation.Builder(compute) .id(ID) .operationId(GLOBAL_OPERATION_ID) - .creationTimestamp(CREATION_TIMESTAMP) .clientOperationId(CLIENT_OPERATION_ID) .operationType(OPERATION_TYPE) .targetLink(TARGET_LINK) @@ -183,7 +179,6 @@ public void tearDown() throws Exception { } private void assertEqualsCommonFields(Operation operation) { - assertEquals(CREATION_TIMESTAMP, operation.creationTimestamp()); assertEquals(ID, operation.id()); assertEquals(CLIENT_OPERATION_ID, operation.clientOperationId()); assertEquals(OPERATION_TYPE, operation.operationType()); @@ -205,7 +200,6 @@ private void assertEqualsCommonFields(Operation operation) { } private void assertNullCommonFields(Operation operation) { - assertNull(operation.creationTimestamp()); assertNull(operation.id()); assertNull(operation.clientOperationId()); assertNull(operation.operationType()); @@ -358,7 +352,7 @@ public void testIsDone_NotExists() throws Exception { expect(compute.get(GLOBAL_OPERATION_ID, expectedOptions)).andReturn(null); replay(compute); initializeOperation(); - assertFalse(operation.isDone()); + assertTrue(operation.isDone()); verify(compute); } @@ -401,7 +395,6 @@ public void testReloadWithOptions() throws Exception { private void compareOperation(Operation expected, Operation value) { assertEquals(expected, value); assertEquals(expected.compute().options(), value.compute().options()); - assertEquals(expected.creationTimestamp(), value.creationTimestamp()); assertEquals(expected.operationId(), value.operationId()); assertEquals(expected.clientOperationId(), value.clientOperationId()); assertEquals(expected.operationType(), value.operationType()); diff --git a/gcloud-java-compute/src/test/java/com/google/gcloud/compute/it/ITComputeTest.java b/gcloud-java-compute/src/test/java/com/google/gcloud/compute/it/ITComputeTest.java index a2f472cdcbb8..39fdb622a59d 100644 --- a/gcloud-java-compute/src/test/java/com/google/gcloud/compute/it/ITComputeTest.java +++ b/gcloud-java-compute/src/test/java/com/google/gcloud/compute/it/ITComputeTest.java @@ -502,7 +502,6 @@ public void testListGlobalOperationsWithSelectedFields() { assertNull(operation.operationType()); assertNull(operation.targetLink()); assertNull(operation.targetId()); - assertNull(operation.creationTimestamp()); assertNull(operation.operationType()); assertNull(operation.status()); assertNull(operation.statusMessage()); @@ -564,7 +563,6 @@ public void testListRegionOperationsWithSelectedFields() { assertNull(operation.operationType()); assertNull(operation.targetLink()); assertNull(operation.targetId()); - assertNull(operation.creationTimestamp()); assertNull(operation.operationType()); assertNull(operation.status()); assertNull(operation.statusMessage()); @@ -628,7 +626,6 @@ public void testListZoneOperationsWithSelectedFields() { assertNull(operation.operationType()); assertNull(operation.targetLink()); assertNull(operation.targetId()); - assertNull(operation.creationTimestamp()); assertNull(operation.operationType()); assertNull(operation.status()); assertNull(operation.statusMessage());