Error when trying to update photo metadata using Street View Publish Service Client - Python

248 Views Asked by At

I have uploaded a couple of photos in Street View and I want to use the Python client library to update its metadata. Find below a snippet of my code:

from google.proto.streetview.publish.v1 import resources_pb2
from google.streetview.publish.v1 import street_view_publish_service_client as client
from google.protobuf import field_mask_pb2

streetview_client = client.StreetViewPublishServiceClient(credentials=credentials)

for photo in streetview_client.list_photos(0, ''):
    con = resources_pb2.Connection()
    target_id = resources_pb2.PhotoId()
    target_id.id = "photo_id"
    con.target.id = target_id.id
    photo.connections.extend([con])
    update_mask = field_mask_pb2.FieldMask()
    update_mask.FromJsonString("connections")
    response = streetview_client.update_photo(photo, update_mask)
    break

I want to connect both photos so I add the target id to the query photo and the field "connections" to the update_mask. The result after the update_photo call is the following error message:

google.gax.errors.RetryError: RetryError(Exception occurred in retry method that was not classified as transient, caused by <_Rendezvous of RPC that terminated with (StatusCode.INVALID_ARGUMENT, Empty level name is not accepted.)>)

Any hint?

1

There are 1 best solutions below

0
abielita On

In order to do a connections between two photos, you need to use Method: photos.batchUpdate. Connections should be set right under Photo. Also, be noted of the metadata of the Photo that you need to implement.

Here's a sample code snippet.

pose = resources_pb2.Pose(level=resources_pb2.Level(name="lvl", number=0))
connection1 = resources_pb2.Connection(target=resources_pb2.PhotoId(id="idOfConnection1"))
photo = resources_pb2.Photo(connections=[connection1], pose=pose)