I'm working with the Google Cloud Platform (GCP) Compute Engine API in Java and encountering an issue when trying to filter operations based on startTime and endTime within a specified time range. The code snippet I'm using is as follows:
Compute compute = (Compute) GcpServiceClientUtility.getGoogleCloudServiceClient(GcpService.COMPUTE, credentialDetails);
assert compute != null;
// Fetch operations within the specified time range for a specific project
String filter = String.format("startTime eq %s",
"2023-11-28T03:36:48.839-08:00");
OperationList operationList = compute.globalOperations().list(GcpConfigService.getKeyValueFromFile(credentialDetails, PROJECT_ID)).setFilter(filter).execute();
for (Operation operation : operationList.getItems()) {
log.info(operation.getName() + ": " + operation.getTargetLink() + " " + operation.getOperationType());
}
However, I'm encountering the following error:
Invalid value for field 'filter': 'startTime ge \"2023-11-28T03:36:48Z\"'. Invalid list filter expression.
It seems that the issue arises when trying to filter operations based on a time range using the startTime
field. I've tried using the ge
(greater than or equal) operator to specify a range but without success.
How can I properly filter operations in GCP Compute Engine API using startTime
and endTime
within a specific time range?