Helpers#

Helper functions for dealing with Cloud Datastore’s Protobuf API.

The non-private functions are part of the API.

class google.cloud.datastore.helpers.GeoPoint(latitude, longitude)[source]#

Bases: object

Simple container for a geo point value.

Parameters:
  • latitude (float) – Latitude of a point.
  • longitude (float) – Longitude of a point.
to_protobuf()[source]#

Convert the current object to protobuf.

Return type:google.type.latlng_pb2.LatLng.
Returns:The current point as a protobuf.
google.cloud.datastore.helpers.entity_from_protobuf(pb)[source]#

Factory method for creating an entity based on a protobuf.

The protobuf should be one returned from the Cloud Datastore Protobuf API.

Parameters:pb (entity_pb2.Entity) – The Protobuf representing the entity.
Return type:google.cloud.datastore.entity.Entity
Returns:The entity derived from the protobuf.
google.cloud.datastore.helpers.entity_to_protobuf(entity)[source]#

Converts an entity into a protobuf.

Parameters:entity (google.cloud.datastore.entity.Entity) – The entity to be turned into a protobuf.
Return type:entity_pb2.Entity
Returns:The protobuf representing the entity.
google.cloud.datastore.helpers.key_from_protobuf(pb)[source]#

Factory method for creating a key based on a protobuf.

The protobuf should be one returned from the Cloud Datastore Protobuf API.

Parameters:pb (entity_pb2.Key) – The Protobuf representing the key.
Return type:google.cloud.datastore.key.Key
Returns:a new Key instance