Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

fix(samples): removed add time from lro. #530

Merged
merged 2 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,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;

Expand All @@ -51,22 +49,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,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;

Expand All @@ -52,21 +50,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,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;
Expand All @@ -61,13 +59,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(
Expand Down Expand Up @@ -101,7 +92,6 @@ public static void setInventory(String productName) throws IOException, Interrup
SetInventoryRequest setInventoryRequest =
SetInventoryRequest.newBuilder()
.setInventory(product)
.setSetTime(requestTime)
.setAllowMissing(true)
.setSetMask(setMask)
.build();
Expand Down