From 541e280c72ff411302cc6917b527c2cdeeddccd6 Mon Sep 17 00:00:00 2001 From: dfirova <93149631+dfirova@users.noreply.github.com> Date: Mon, 12 Sep 2022 22:56:13 +0300 Subject: [PATCH] fix(samples): removed add time from lro. (#530) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/java-retail/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes # ☕️ If you write sample code, please follow the [samples format]( https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md). --- .../src/main/java/product/AddFulfillmentPlaces.java | 11 ++--------- .../main/java/product/RemoveFulfillmentPlaces.java | 12 +++--------- .../src/main/java/product/SetInventory.java | 10 ---------- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/samples/interactive-tutorials/src/main/java/product/AddFulfillmentPlaces.java b/samples/interactive-tutorials/src/main/java/product/AddFulfillmentPlaces.java index df1080f6..2c6a63cc 100644 --- a/samples/interactive-tutorials/src/main/java/product/AddFulfillmentPlaces.java +++ b/samples/interactive-tutorials/src/main/java/product/AddFulfillmentPlaces.java @@ -23,9 +23,7 @@ import com.google.cloud.ServiceOptions; import com.google.cloud.retail.v2.AddFulfillmentPlacesRequest; import com.google.cloud.retail.v2.ProductServiceClient; -import com.google.protobuf.Timestamp; import java.io.IOException; -import java.time.Instant; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -47,22 +45,17 @@ public static void main(String[] args) throws IOException, InterruptedException public static void addFulfillmentPlaces(String productName, String placeId) throws IOException, InterruptedException { - Timestamp currentDate = - Timestamp.newBuilder() - .setSeconds(Instant.now().getEpochSecond()) - .setNanos(Instant.now().getNano()) - .build(); - System.out.printf("Add fulfilment places with current date: %s", currentDate); + System.out.println("Add fulfilment places"); AddFulfillmentPlacesRequest addFulfillmentPlacesRequest = AddFulfillmentPlacesRequest.newBuilder() .setProduct(productName) .setType("pickup-in-store") .addPlaceIds(placeId) - .setAddTime(currentDate) .setAllowMissing(true) .build(); + System.out.println("Add fulfillment request " + addFulfillmentPlacesRequest); // Initialize client that will be used to send requests. This client only diff --git a/samples/interactive-tutorials/src/main/java/product/RemoveFulfillmentPlaces.java b/samples/interactive-tutorials/src/main/java/product/RemoveFulfillmentPlaces.java index a5eac37d..35e7b8f0 100644 --- a/samples/interactive-tutorials/src/main/java/product/RemoveFulfillmentPlaces.java +++ b/samples/interactive-tutorials/src/main/java/product/RemoveFulfillmentPlaces.java @@ -23,9 +23,7 @@ import com.google.cloud.ServiceOptions; import com.google.cloud.retail.v2.ProductServiceClient; import com.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest; -import com.google.protobuf.Timestamp; import java.io.IOException; -import java.time.Instant; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -48,21 +46,17 @@ public static void main(String[] args) throws IOException, InterruptedException // remove fulfillment places to product public static void removeFulfillmentPlaces(String productName, String storeId) throws IOException, InterruptedException { - Timestamp currentDate = - Timestamp.newBuilder() - .setSeconds(Instant.now().getEpochSecond()) - .setNanos(Instant.now().getNano()) - .build(); - System.out.printf("Remove fulfilment places with current date: %s", currentDate); + System.out.println("Remove fulfilment places with current date"); + RemoveFulfillmentPlacesRequest removeFulfillmentRequest = RemoveFulfillmentPlacesRequest.newBuilder() .setProduct(productName) .setType("pickup-in-store") .addPlaceIds(storeId) - .setRemoveTime(currentDate) .setAllowMissing(true) .build(); + System.out.println("Remove fulfillment request " + removeFulfillmentRequest); // Initialize client that will be used to send requests. This client only diff --git a/samples/interactive-tutorials/src/main/java/product/SetInventory.java b/samples/interactive-tutorials/src/main/java/product/SetInventory.java index 379dc31c..0a16d408 100644 --- a/samples/interactive-tutorials/src/main/java/product/SetInventory.java +++ b/samples/interactive-tutorials/src/main/java/product/SetInventory.java @@ -29,9 +29,7 @@ import com.google.cloud.retail.v2.SetInventoryRequest; import com.google.protobuf.FieldMask; import com.google.protobuf.Int32Value; -import com.google.protobuf.Timestamp; import java.io.IOException; -import java.time.Instant; import java.util.Arrays; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -57,13 +55,6 @@ public static void setInventory(String productName) throws IOException, Interrup float originalPrice = 20.0f; float cost = 8.0f; - // The request timestamp - Timestamp requestTime = - Timestamp.newBuilder() - .setSeconds(Instant.now().getEpochSecond()) - .setNanos(Instant.now().getNano()) - .build(); - FieldMask setMask = FieldMask.newBuilder() .addAllPaths( @@ -97,7 +88,6 @@ public static void setInventory(String productName) throws IOException, Interrup SetInventoryRequest setInventoryRequest = SetInventoryRequest.newBuilder() .setInventory(product) - .setSetTime(requestTime) .setAllowMissing(true) .setSetMask(setMask) .build();